A professional RESTful API built with Node.js, Express.js, and MongoDB for managing restaurant operations. The system provides authentication, menu management, table management, reservations, orders, inventory tracking, reporting, and health monitoring.
- 🔐 JWT Authentication & Authorization
- 👤 User Management
- 🍔 Menu Management
- 🪑 Table Management
- 📅 Reservation System
- 🛒 Order Management
- 📦 Inventory Management
- 📊 Reports API
- ❤️ Health Check Endpoint
- ✅ Request Validation using Zod
- 🚨 Centralized Error Handling
- 🍪 Cookie Authentication Support
- Node.js
- Express.js
- MongoDB
- Mongoose
- JWT Authentication
- Zod Validation
- bcrypt.js
- Cookie Parser
- CORS
src/
│
├── config/
│ └── db.js
│
├── controllers/
│ ├── health.controller.js
│ ├── inventory.controller.js
│ ├── menu.controller.js
│ ├── order.controller.js
│ ├── report.controller.js
│ ├── reservation.controller.js
│ ├── table.controller.js
│ └── user.controller.js
│
├── middleware/
│ ├── admin.middleware.js
│ ├── auth.middleware.js
│ └── validate.middleware.js
│
├── models/
│ ├── inventoryItem.model.js
│ ├── menuItem.model.js
│ ├── order.model.js
│ ├── reservation.model.js
│ ├── table.model.js
│ └── user.model.js
│
├── routes/
│
├── utils/
│
├── validations/
│
├── app.js
└── server.js
git clone https://github.com/abmdevx/restaurant-api.gitcd restaurant-apinpm installCreate a .env file using the provided .env.example.
Example:
PORT=5000
MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret
JWT_EXPIRES_IN=7dnpm run devProduction
npm start| Module | Description |
|---|---|
| Authentication | User login & registration |
| Users | Manage system users |
| Menu | Create and manage menu items |
| Tables | Restaurant table management |
| Reservations | Customer reservations |
| Orders | Place and manage orders |
| Inventory | Inventory stock management |
| Reports | Restaurant analytics and reports |
| Health | API status check |
The API uses JSON Web Tokens (JWT) for authentication.
Protected routes require a valid JWT.
Admin-only routes are secured using authorization middleware.
All incoming requests are validated using Zod, ensuring:
- Required fields
- Correct data types
- Cleaner API responses
- Better error handling
The project includes:
- Custom API Error class
- Async error wrapper
- Standardized API responses
- Centralized error handling middleware
npm run devRuns the server with Nodemon.
npm startRuns the production server.
Main packages used:
- Express.js
- Mongoose
- JWT
- bcryptjs
- Zod
- Cookie Parser
- CORS
- dotenv
Contributions are welcome.
- Fork the repository
- Create a feature branch
git checkout -b feature-name- Commit your changes
git commit -m "Add new feature"- Push the branch
git push origin feature-name- Open a Pull Request
This project is developed for educational and learning purposes. You are free to use, modify, and extend it for personal or academic projects.