A lightweight, production-ready REST API for an invoicing SaaS designed for micro and small businesses. Built with Node.js, Express, and MongoDB.
- Authentication System: Secure user registration and login using JWT and bcrypt.
- Client Management: Full CRUD operations for managing clients.
- Invoice Tracking: Create, read, update, and delete invoices. Includes automatic subtotal, tax, and total calculations.
- Automated Status Logic: Invoices are automatically marked as "overdue" if their due date has passed and they remain unpaid.
- API Documentation: Interactive Swagger (OpenAPI 3.0) documentation available out of the box.
- Runtime: Node.js
- Framework: Express.js
- Database: MongoDB with Mongoose ODM
- Authentication: JSON Web Tokens (JWT) & bcryptjs
- Documentation: swagger-jsdoc & swagger-ui-express
server/
├── controllers/ # API request handlers and business logic
├── models/ # Mongoose schema definitions
├── routes/ # Express endpoint definitions
├── middleware/ # Custom HTTP middleware (auth, error handler)
├── config/ # Environment and database config files
├── utils/ # Helper utilities (JWT generation)
├── docs/ # Swagger configuration
├── app.js # Express app setup and middleware pipeline
└── server.js # Application entry point and server startup
- Node.js (v16+)
- MongoDB installed and running locally on the default port
27017(or modifyMONGODB_URIin.env).
- Clone or download the repository, then navigate to the backend directory:
cd Backend - Install the dependencies:
npm install
A .env.example file is provided. Create a new file named .env and configure your local environment variables:
PORT=5000
MONGODB_URI=mongodb://localhost:27017/invoicelite
JWT_SECRET=your_super_secret_jwt_key
JWT_EXPIRE=30dStart the development server with auto-reloading (nodemon):
npm run devOr start the server normally:
node server.jsThe server will be available at http://localhost:5000.
Interactive API documentation is generated automatically using Swagger. Once the server is running, you can explore the endpoints and test the API at:
http://localhost:5000/api/docs
ISC License