Skip to content

rxtech-lab/invoice-management-mcp

Repository files navigation

Invoice Management System

A comprehensive invoice management system built with Go and Next.js, featuring AI-powered search and Model Context Protocol (MCP) integration.

Features

  • πŸ“„ Invoice Management: Create, read, update, and delete invoices with detailed line items
  • 🏒 Company & Receiver Management: Organize vendors and invoice recipients
  • 🏷️ Categories & Tags: Flexible categorization and tagging system
  • πŸ“Š Analytics & Reporting: Built-in analytics and statistics dashboard
  • πŸ“€ File Upload: S3-compatible storage for invoice attachments
  • πŸ” AI-Powered Search: Intelligent search capabilities using AI SDK
  • πŸ€– MCP Server: Model Context Protocol integration for AI assistants
  • πŸ’± Currency Support: Multi-currency with exchange rate conversion
  • πŸ” OAuth Authentication: Secure authentication with JWT tokens
  • πŸ“± Responsive UI: Modern Next.js frontend with mobile support

Tech Stack

Backend

  • Go 1.25+: Main backend language
  • Fiber v2: Fast HTTP framework
  • GORM: ORM for database operations
  • Turso/SQLite: Database (supports both local SQLite and Turso)
  • AWS SDK v2: S3-compatible storage integration
  • MCP Go: Model Context Protocol server implementation
  • OpenAPI 3.0: API specification and code generation

Frontend

  • Next.js 16: React framework
  • TypeScript: Type-safe development
  • TanStack Query: Data fetching and caching
  • TanStack Table: Advanced table components
  • Shadcn UI: Component library
  • Tailwind CSS: Utility-first styling
  • React Hook Form: Form management with Zod validation
  • Recharts: Data visualization
  • AI SDK: AI-powered features

Getting Started

Prerequisites

  • Go 1.25 or higher
  • Node.js 20 or higher
  • Docker & Docker Compose (optional)
  • Bun or npm package manager

Environment Variables

Create a .env file in the root directory with the following variables:

# Server
PORT=8080

# Database (Turso) - Leave empty to use local SQLite
TURSO_DATABASE_URL=
TURSO_AUTH_TOKEN=

# S3-compatible storage
S3_ENDPOINT=your-s3-endpoint
S3_BUCKET=your-bucket-name
S3_ACCESS_KEY=your-access-key
S3_SECRET_KEY=your-secret-key
S3_REGION=us-east-1
S3_USE_PATH_STYLE=false

# Authentication
MCPROUTER_SERVER_URL=your-mcprouter-url
MCPROUTER_SERVER_API_KEY=your-api-key
OAUTH_SERVER_URL=your-oauth-server
OAUTH_ISSUER=your-oauth-issuer
OAUTH_AUDIENCE=your-oauth-audience

# File Server (for unlinking files)
FILE_SERVER_URL=your-file-server-url

Installation

Option 1: Using Docker Compose (Recommended)

# Start the application
docker-compose up -d

# View logs
docker-compose logs -f

# Stop the application
docker-compose down

Option 2: Local Development

Backend:

# Install dependencies
make deps

# Generate OpenAPI code
make generate

# Build the binary
make build

# Run the server
make run

# Or run with hot reload (requires air)
air

Frontend:

cd frontend

# Install dependencies
bun install

# Run development server
bun dev

# Build for production
bun build

Development Commands

Backend:

make deps           # Download and tidy dependencies
make build          # Build the binary
make run            # Run the server
make test           # Run tests
make test-e2e       # Run E2E tests
make test-coverage  # Run tests with coverage
make fmt            # Format code
make lint           # Lint code
make generate       # Generate OpenAPI code
make clean          # Clean build artifacts
make install-local  # Install binary to /usr/local/bin

Frontend:

bun dev     # Start development server
bun build   # Build for production
bun start   # Start production server
bun lint    # Run ESLint

Project Structure

.
β”œβ”€β”€ cmd/
β”‚   └── server/          # Main application entry point
β”œβ”€β”€ internal/
β”‚   β”œβ”€β”€ api/             # API server and handlers
β”‚   β”‚   β”œβ”€β”€ handlers/    # HTTP request handlers
β”‚   β”‚   β”œβ”€β”€ middleware/  # Middleware functions
β”‚   β”‚   └── generated/   # OpenAPI generated code
β”‚   β”œβ”€β”€ assets/          # Static assets and OpenAPI spec
β”‚   β”œβ”€β”€ mcp/             # Model Context Protocol server
β”‚   β”œβ”€β”€ models/          # Database models
β”‚   β”œβ”€β”€ services/        # Business logic services
β”‚   β”œβ”€β”€ tools/           # MCP tools implementation
β”‚   └── utils/           # Utility functions
β”œβ”€β”€ frontend/            # Next.js frontend application
β”‚   β”œβ”€β”€ app/             # Next.js app directory
β”‚   β”‚   β”œβ”€β”€ (auth)/      # Authentication pages
β”‚   β”‚   β”œβ”€β”€ (dashboard)/ # Dashboard pages
β”‚   β”‚   └── api/         # API routes
β”‚   β”œβ”€β”€ components/      # React components
β”‚   β”œβ”€β”€ hooks/           # Custom React hooks
β”‚   └── lib/             # Utility libraries and API clients
β”œβ”€β”€ e2e/                 # End-to-end tests
β”œβ”€β”€ k8s/                 # Kubernetes deployment configs
└── oapi-codegen/        # OpenAPI code generation configs

API Documentation

The API follows OpenAPI 3.0 specification. Key endpoints include:

  • /api/health - Health check
  • /api/categories - Category management
  • /api/companies - Company/vendor management
  • /api/receivers - Invoice receiver management
  • /api/tags - Tag management
  • /api/invoices - Invoice CRUD operations
  • /api/invoices/{id}/items - Invoice line items
  • /api/upload - File upload operations
  • /api/analytics/* - Analytics and statistics

Full API documentation is available in internal/assets/openapi.yaml.

MCP Server

This project includes a Model Context Protocol (MCP) server that allows AI assistants to interact with the invoice management system. The MCP server provides tools for:

  • Creating, reading, updating, and deleting invoices
  • Managing categories, companies, receivers, and tags
  • Uploading and managing files
  • Generating analytics and statistics

The MCP server is automatically started alongside the main API server.

Kubernetes Deployment

Kubernetes deployment configurations are available in the k8s/ directory:

cd k8s

# Apply all configurations
kubectl apply -k .

# Or apply individually
kubectl apply -f namespace.yaml
kubectl apply -f secrets.yaml
kubectl apply -f deployment.yaml
kubectl apply -f service.yaml
kubectl apply -f ingress.yaml
kubectl apply -f cluster-issuer.yaml

See k8s/README.md for detailed deployment instructions.

Testing

Unit Tests:

make test

E2E API Tests:

make test-e2e

Coverage Report:

make test-coverage

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is maintained by RxTech Lab.

Support

For issues and questions, please open an issue on GitHub.

Acknowledgments

Packages

 
 
 

Contributors

Languages