Invoice management system for creating, tracking, and managing invoices with customer management, line items, payments, and PDF generation.
Documentation: See writeup.txt for architecture overview and ai_development.md for AI-accelerated development process. Additional docs listed below.
- Backend: Node.js + TypeScript + Express
- Frontend: Vue 3 + TypeScript + Vite
- Database: PostgreSQL 14+
- Auth: AWS Cognito (basic auth in dev)
- Storage: AWS S3
- PDF: Invoice-Generator.com API
- DDD: Bounded contexts (Customer, Invoice, Payment, User)
- CQRS: Separate command/query handlers
- VSA: Feature-based organization
src/
├── features/ # Feature-based organization (vertical slices)
├── domain/ # Domain entities, value objects
├── infrastructure/ # Database, external services
├── shared/ # Shared utilities, middleware, types
└── config/ # Configuration and environment validation
src/
├── features/ # Feature modules (auth, customers, invoices, payments)
├── shared/ # Shared components, composables, api, types
├── router/ # Vue Router configuration
├── stores/ # Pinia state management
└── assets/ # Static assets
- Node.js: v18+ (LTS recommended)
- PostgreSQL: v14+
- npm: v9+
- AWS Account (for Cognito and S3)
- Invoice-Generator.com Account (free tier available)
# Install backend dependencies
npm install
# Install frontend dependencies
cd invoice-frontend
npm install
cd ..# Install PostgreSQL (macOS with Homebrew)
brew install postgresql@14
brew services start postgresql@14
# Create database and user
psql postgresCREATE DATABASE invoice_db;
CREATE USER invoice_user WITH ENCRYPTED PASSWORD 'your_password';
GRANT ALL PRIVILEGES ON DATABASE invoice_db TO invoice_user;
\q- Create an RDS PostgreSQL instance (db.t3.micro for development)
- Configure security group to allow your IP
- Note the connection string
# Copy the example environment file
cp .env.example .env
# Edit .env with your actual credentials
nano .envRequired Configuration:
- Database: Update
DATABASE_URLwith your PostgreSQL credentials - AWS Cognito:
- Create a User Pool in AWS Cognito console
- Note the
User Pool IDandApp Client ID - Update
AWS_COGNITO_USER_POOL_IDandAWS_COGNITO_CLIENT_ID
- AWS S3:
- Create an S3 bucket for invoice PDFs
- Update
AWS_S3_BUCKET_NAME
- AWS Credentials: Update
AWS_ACCESS_KEY_IDandAWS_SECRET_ACCESS_KEY - Invoice Generator:
- Sign up at https://invoice-generator.com
- Get API key from Settings → API Keys
- Update
INVOICE_GENERATOR_API_KEY
# Run migrations to create tables
npm run migrate:up
# Verify tables were created
psql -d invoice_db -c "\dt"# Terminal 1: Start backend server
npm run dev
# Backend runs on http://localhost:3000
# Terminal 2: Start frontend dev server
cd invoice-frontend
npm run dev
# Frontend runs on http://localhost:5173# Build backend
npm run build
npm start
# Build frontend
cd invoice-frontend
npm run build
npm run previewnpm run dev- Start development server with hot reload (nodemon)npm run build- Build TypeScript to JavaScriptnpm start- Start production servernpm test- Run tests with Jestnpm run lint- Lint code with ESLintnpm run format- Format code with Prettiernpm run migrate:up- Run database migrationsnpm run migrate:down- Rollback last migrationnpm run migrate:create <name>- Create new migration file
npm run dev- Start Vite dev servernpm run build- Build for productionnpm run preview- Preview production buildnpm run type-check- Run TypeScript type checking
- Go to AWS Console → Cognito → User Pools
- Click "Create user pool"
- Configure:
- User attributes: Email (required, sign-in), Name (required)
- Password policy: Min 8 chars, uppercase, lowercase, numbers
- MFA: Optional (disabled for MVP)
- Token expiration: Access token 1 hour, Refresh token 30 days
- Create app client:
- Name:
invoice-mvp-client - No client secret (for SPA)
- Auth flows: ALLOW_USER_PASSWORD_AUTH, ALLOW_REFRESH_TOKEN_AUTH
- Name:
- Note User Pool ID and App Client ID
- Go to AWS Console → S3
- Create bucket:
- Name:
invoice-pdfs-dev(or your environment) - Region: Same as your application
- Block all public access: Enabled
- Versioning: Enabled
- Encryption: AES-256 or AWS-KMS
- Name:
- Configure IAM policy for your application user/role:
- Allow
s3:PutObject,s3:GetObjecton your bucket
- Allow
- Sign up at https://invoice-generator.com
- Navigate to Settings → API Keys
- Create new API key
- Note the API key (free tier: 100 invoices/month)
# Run all tests
npm test
# Run unit tests only
npm run test:unit
# Run integration tests only
npm run test:integration
# Run with coverage
npm run test:coverage
# Run performance tests
npm run test:perf
# Watch mode
npm run test:watch- Domain Layer: >90% coverage
- Application Layer: >85% coverage
- Integration Tests: 20+ tests
- Unit Tests: 100+ tests
- Overall Coverage: >80%
cd invoice-frontend
# Run E2E tests
npm run test:e2e
# Run E2E tests in headless mode
npm run test:e2e:ciOnce the backend is running, test the health endpoint:
curl http://localhost:3000/healthExpected response:
{
"status": "ok",
"timestamp": "2024-11-08T12:00:00.000Z"
}- writeup.txt - Architecture overview
- ai_development.md - AI-accelerated development process
- ARCHITECTURE.md - Detailed architecture documentation
- DEPLOYMENT.md - Deployment guide
- OPERATIONS.md - Operations guide
# Test PostgreSQL connection
psql -h localhost -U invoice_user -d invoice_db
# Check if PostgreSQL is running
brew services list # macOS# Find process using port 3000
lsof -i :3000
# Kill the process
kill -9 <PID># Clean build directory
rm -rf dist/
# Rebuild
npm run build