A full-featured restaurant management API built with Node.js, Express, TypeScript, and Prisma ORM with PostgreSQL.
- Menu Management - Create, update, and manage menu items with ingredients and pricing
- Table Management - Track table status (available, occupied, reserved) and capacity
- Reservation System - Handle customer reservations with date/time scheduling
- Order Management - Support for dine-in, takeaway, and delivery orders
- Order Items Tracking - Manage individual items within orders
- Inventory Management - Track ingredients with quantities, expiry dates, and restocking
- Daily Sales Reports - Automated daily analytics and reporting
- Runtime: Node.js
- Framework: Express 5
- Language: TypeScript
- ORM: Prisma 7 with PostgreSQL
- Validation: Zod
- Middleware: CORS, Helmet, Morgan, Compression
- Database Adapter: @prisma/adapter-pg with Accelerate extension
├── src/
│ ├── controllers/ # Request handlers
│ ├── routes/ # Express route definitions
│ ├── services/ # Business logic layer
│ ├── schema/ # Zod validation schemas
│ ├── middlewares/ # Custom middleware (validation, etc.)
│ ├── utils/ # Utilities (Prisma client, error handling)
│ ├── generated/ # Prisma generated client
│ ├── index.ts # Express app setup
│ └── types.ts # TypeScript type definitions
├── prisma/
│ ├── schema.prisma # Database schema
│ └── migrations/ # Database migrations
├── index.ts # Server entry point
└── package.json
GET /api/menu- Get all menu itemsPOST /api/menu- Create menu itemGET /api/menu/:id- Get menu item by IDPUT /api/menu/:id- Update menu itemDELETE /api/menu/:id- Delete menu item
GET /api/table- Get all tablesPOST /api/table- Create tableGET /api/table/:id- Get table by IDPUT /api/table/:id- Update tableDELETE /api/table/:id- Delete table
GET /api/reservation- Get all reservationsPOST /api/reservation- Create reservationGET /api/reservation/:id- Get reservation by IDPUT /api/reservation/:id- Update reservationDELETE /api/reservation/:id- Delete reservation
GET /api/order- Get all orders (with filters)POST /api/order- Create orderGET /api/order/:id- Get order by IDGET /api/order/number/:number- Get order by order numberPUT /api/order/:id/status- Update order statusPUT /api/order/:id/payment- Update payment statusDELETE /api/order/:id- Delete order
PUT /api/orderItems/:id- Update order itemDELETE /api/orderItems/:id- Remove order item
GET /api/inventory- Get all inventory itemsPOST /api/inventory- Create inventory itemGET /api/inventory/:id- Get inventory item by IDPUT /api/inventory/:id- Update inventory itemDELETE /api/inventory/:id- Delete inventory item
GET /api/menu-ingridents- Get menu-ingredient mappingsPOST /api/menu-ingridents- Create menu-ingredient mappingPUT /api/menu-ingridents/:id- Update mappingDELETE /api/menu-ingridents/:id- Delete mapping
- Clone the repository
- Install dependencies:
npm install
- Set up environment variables:
Create a
.envfile in the root directory:DATABASE_URL="postgresql://user:password@localhost:5432/database_name" PORT=3000 - Run database migrations:
npx prisma migrate dev
- Generate Prisma client:
npx prisma generate
npm run devUses nodemon with tsx for hot-reload during development.
npm run build
npm startThe system uses PostgreSQL with the following main models:
- MenuItem - Menu items with pricing, descriptions, and allergen info
- Table - Restaurant tables with capacity and status tracking
- Reservation - Customer reservations linked to tables
- Order - Orders with type (dine-in/takeaway/delivery) and payment status
- OrderItem - Individual items within an order
- Inventory - Ingredient inventory with quantities and expiry tracking
- MenuItem_Inventory - Many-to-many relationship between menu items and inventory
- DailySalesReport - Automated daily sales analytics
| Variable | Description | Default |
|---|---|---|
DATABASE_URL |
PostgreSQL connection string | Required |
PORT |
Server port | 3000 |
npm run dev- Start development server with hot-reloadnpm run build- Compile TypeScript to JavaScriptnpm start- Run production buildnpm test- Run tests (not implemented)
- express - Web framework
- cors - Cross-origin resource sharing
- helmet - Security headers
- morgan - HTTP request logger
- compression - Response compression
- zod - Schema validation
- @prisma/adapter-pg - PostgreSQL adapter
- @prisma/extension-accelerate - Prisma Accelerate extension
- typescript - TypeScript compiler
- tsx - TypeScript execution environment
- nodemon - Auto-restart during development
- dotenv - Environment variable loading
- prisma - ORM CLI and client
- @types/* - TypeScript type definitions