A full-stack Invoice Generator web application built with the MERN Stack (MongoDB, Express, React, Node.js). The application allows users to create invoices, preview them, generate a PDF, and send the invoice directly to a client's email.
This project demonstrates full-stack development including authentication, REST API design, database integration, and email functionality.
**
- π§Ύ Invoice Generator
This application allows authenticated users to create professional invoices, preview them, and send them as PDF files directly to clients.
The goal of this project was to build a real-world business tool while demonstrating backend architecture, API development, authentication, and frontend state management.
- User registration
- Secure login using JWT authentication
- Protected routes using middleware
- Create invoices with multiple line items
- Automatically calculate subtotals, tax, and grand totals
- Edit and update existing invoices
- Preview invoices before sending
- Save invoices to MongoDB
- Generate invoice as a PDF
- Send invoice directly to client email via Resend
- Custom email message option
- Manage user information
- User-specific invoice storage
- Dynamic invoice form with real-time total calculation
- Invoice preview modal
- Clean and responsive interface
| Layer | Technologies |
|---|---|
| Frontend | React, TypeScript, Tailwind CSS, Context API |
| Backend | Node.js, Express.js, JWT Authentication, Resend |
| Database | MongoDB, Mongoose ODM |
| Tools | Git, GitHub, Postman, npm |
invoice-generator/
β
βββ frontend/
β βββ api/
β βββ assets/
β βββ components/
β βββ pages/
β βββ context/
β βββ utils/
β
βββ backend/
β βββ controllers/
β βββ models/
β βββ routes/
β βββ middleware/
β βββ utils/
β
βββ README.md
Make sure you have the following installed before running the project:
- Node.js v18 or higher
- npm v9 or higher
- [MongoDB]free MongoDB Atlas cluster
- A Gmail account with an App Password enabled (required for Resend)
git clone https://github.com/yourusername/invoice-generator.git
cd invoice-generatorcd backend
npm installcd ../frontend
npm installCopy the example env file and fill in your values (see Environment Variables):
cp backend/.env.example backend/.envFrom the backend/ directory:
cd ../backend
npm run devOpen a new terminal, then from the frontend/ directory:
cd frontend
npm run devThe frontend will run on http://localhost:5173 and the backend on http://localhost:5000.
Create a .env file inside the backend/ folder. An .env.example file is included for reference:
PORT=5000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret
RESEND_API_KEY=your_email@gmail.com
FRONTEND_URL=your_gmail_app_passwordAll protected routes require a valid JWT token passed in the Authorization header:
Authorization: Bearer <token>
| Method | Endpoint | Auth Required | Description |
|---|---|---|---|
POST |
/api/auth/register |
β | Register a new user |
POST |
/api/auth/login |
β | Log in and receive a JWT |
| Method | Endpoint | Auth Required | Description |
|---|---|---|---|
GET |
/api/users/profile |
β | Get the current user's profile |
PUT |
/api/users/profile |
β | Update the current user's profile |
| Method | Endpoint | Auth Required | Description |
|---|---|---|---|
GET |
/api/invoices |
β | Get all invoices for the authenticated user |
POST |
/api/invoices |
β | Create a new invoice |
GET |
/api/invoices/:id |
β | Get a single invoice by ID |
PUT |
/api/invoices/:id |
β | Update an existing invoice |
DELETE |
/api/invoices/:id |
β | Delete an invoice |
POST |
/api/invoices/:id/send |
β | Generate PDF and send invoice to client email |
- Full-stack MERN architecture
- REST API development
- JWT authentication and middleware-protected routes
- MongoDB schema design with Mongoose
- Email service integration with Resend
- PDF generation
- React state management with Context API
- Component-based frontend architecture
- TypeScript for type-safe frontend development
JWT errors / Unauthorized responses
- Make sure
JWT_SECRETin your.envmatches what was used to sign existing tokens. Changing it invalidates all active sessions.
Emails not sending
- Gmail requires an App Password, not your regular account password. Make sure 2-Step Verification is enabled on your Google account first.
- Check your spam folder if test emails are not arriving.
CORS errors in the browser
- Confirm the backend is running on the expected port and that your Express CORS configuration allows requests from the frontend origin (e.g.
http://localhost:5173).
npm run dev not found
- Check that you are in the correct directory (
backend/orfrontend/) before running the command.
- Invoice dashboard with analytics and charts
- Multiple invoice templates
- Invoice status tracking (Draft / Sent / Paid / Overdue)
- Search and filter invoices
Contributions are welcome! To get started:
- Fork the repository
- Create a new branch:
git checkout -b feature/your-feature-name - Make your changes and commit:
git commit -m 'Add some feature' - Push to your branch:
git push origin feature/your-feature-name - Open a Pull Request
Please make sure your code follows the existing style and that any new features are tested before submitting.
Your Name
- GitHub: @madbag
- LinkedIn: Madhushree B