A technical assessment project for an e-invoicing platform that validates and submits invoices to a mocked government API.
jose and bcryptpg (no ORM)companies: Business entitiesusers: Company users with credentialsinvoices: Invoice records with processing statusinvoice_items: Line items for each invoiceprocessing_attempts: Append-only log of processing attemptscompany_id from JWTFOR UPDATE SKIP LOCKED for worker job claimingCopy .env.example to .env and configure:
DATABASE_URL=postgresql://postgres:password@host:6543/postgres
DATABASE_URL_DIRECT=postgresql://postgres:password@host:5432/postgres
JWT_SECRET=your-secret-key-here
GOV_API_URL=http://localhost:3000/api/mock-gov
GOV_API_KEY=your-gov-api-key
npm install
Configure environment variables (see above)
npm run migrate
npm run seed
Start the development server:
npm run dev
Start the background worker (in a separate terminal):
npm run worker
POST /api/v1/auth/login - User loginGET /api/health - Health checkGET /api/v1/invoices - List invoices (filtered by company)POST /api/v1/invoices - Create invoiceGET /api/v1/invoices/:id - Get invoice detailsPOST /api/v1/invoices/:id/retry - Retry failed invoicePOST /api/mock-gov/submit - Mock government API/ - Landing page/login - Login page/dashboard - Invoice dashboard with filters/invoices/create - Create invoice form/invoices/:id - Invoice details with processing timelineAfter running npm run seed, you can login with:
user1@acme.com / password123user2@beta.com / password123DATABASE_URL (port 6543): Transaction pooler for API routes (no prepared statements)DATABASE_URL_DIRECT (port 5432): Direct connection for worker and migrationsSELECT ... FOR UPDATE SKIP LOCKEDPROCESSING status with locked_until lease