AI Invoice Generator
- Tech stack
- Prerequisites
- Environment configuration
- Setup & Run (Development)
- Build & Run (Production)
- API Endpoints (overview)
- Database migrations & data shape notes
- Testing & linting
- Troubleshooting
- Contributing
- Backend: Node.js, Express, MongoDB (Mongoose)
- Frontend: React (Vite), TailwindCSS
- Auth: JSON Web Tokens (JWT)
- AI: Google GenAI client (optional - used for invoice extraction/AI-assisted features)
- Node.js v18+ (recommended)
- npm (or yarn)
- MongoDB (local, Docker, or a cloud provider like MongoDB Atlas)
You need to create .env files for the API (and optionally the client if you want environment-specific behavior).
Create a file at api/.env with the following variables:
PORT=5000
MONGO_URI=mongodb://localhost:27017/invoice-generator
JWT_SECRET=your_jwt_secret_here
GOOGLE_API_KEY=optional_google_genai_keyPORT— port to run the API on (default 5000)MONGO_URI— your MongoDB connection stringJWT_SECRET— secret used to sign JWT tokens for authGOOGLE_API_KEY— optional key for AI features
Vite exposes env variables prefixed with VITE_. Create client/.env for local dev if you want to point the frontend to a non-default API host.
VITE_API_BASE_URL=http://localhost:5000/apiIf you don't set this, the client uses relative paths configured in src/utils/axiosInstance.js.
From the repository root run the backend and the frontend in separate terminals.
cd api
npm install
npm run devnpm run devstarts the server withnodemonfor hot reload.
cd client
npm install
npm run dev- Open the URL Vite prints (usually
http://localhost:5173) to view the app.
Build the client and serve it with a static server, or host separately.
cd client
npm run buildcd api
npm install --production
npm startThe production flow depends on your hosting choice. You can also serve the client build from the API server by adding a static middleware — not included by default.
POST /api/auth/register— register new userPOST /api/auth/login— login and get JWTGET /api/invoices— list user's invoicesPOST /api/invoices— create invoiceGET /api/invoices/:id— get invoice by IDPATCH /api/invoices/:id— update invoiceDELETE /api/invoices/:id— delete invoice
Check api/src/controllers and api/src/routes for the exact implementations and request/response bodies.
- If the client can't reach the API, verify
VITE_API_BASE_URLor axios instance base url. - If JWT errors occur, ensure
JWT_SECRETin.envmatches and that tokens are sent in theAuthorization: Bearer <token>header. - If items are not returned, verify the API's
Invoicemodel hasitemsdefined as an array (seeapi/src/models/invoice.model.js).
- Fork the repo, create a branch, open a PR with clear changes and tests.