Skip to content

Mirudull-D/ServeSync

Repository files navigation

Serve Sync - Restaurant Management System

A full-featured restaurant management API built with Node.js, Express, TypeScript, and Prisma ORM with PostgreSQL.

Features

  • 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

Tech Stack

  • 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

Project Structure

├── 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

API Endpoints

Menu

  • GET /api/menu - Get all menu items
  • POST /api/menu - Create menu item
  • GET /api/menu/:id - Get menu item by ID
  • PUT /api/menu/:id - Update menu item
  • DELETE /api/menu/:id - Delete menu item

Tables

  • GET /api/table - Get all tables
  • POST /api/table - Create table
  • GET /api/table/:id - Get table by ID
  • PUT /api/table/:id - Update table
  • DELETE /api/table/:id - Delete table

Reservations

  • GET /api/reservation - Get all reservations
  • POST /api/reservation - Create reservation
  • GET /api/reservation/:id - Get reservation by ID
  • PUT /api/reservation/:id - Update reservation
  • DELETE /api/reservation/:id - Delete reservation

Orders

  • GET /api/order - Get all orders (with filters)
  • POST /api/order - Create order
  • GET /api/order/:id - Get order by ID
  • GET /api/order/number/:number - Get order by order number
  • PUT /api/order/:id/status - Update order status
  • PUT /api/order/:id/payment - Update payment status
  • DELETE /api/order/:id - Delete order

Order Items

  • PUT /api/orderItems/:id - Update order item
  • DELETE /api/orderItems/:id - Remove order item

Inventory

  • GET /api/inventory - Get all inventory items
  • POST /api/inventory - Create inventory item
  • GET /api/inventory/:id - Get inventory item by ID
  • PUT /api/inventory/:id - Update inventory item
  • DELETE /api/inventory/:id - Delete inventory item

Menu Ingredients

  • GET /api/menu-ingridents - Get menu-ingredient mappings
  • POST /api/menu-ingridents - Create menu-ingredient mapping
  • PUT /api/menu-ingridents/:id - Update mapping
  • DELETE /api/menu-ingridents/:id - Delete mapping

Installation

  1. Clone the repository
  2. Install dependencies:
    npm install
  3. Set up environment variables: Create a .env file in the root directory:
    DATABASE_URL="postgresql://user:password@localhost:5432/database_name"
    PORT=3000
    
  4. Run database migrations:
    npx prisma migrate dev
  5. Generate Prisma client:
    npx prisma generate

Usage

Development

npm run dev

Uses nodemon with tsx for hot-reload during development.

Production Build

npm run build
npm start

Database Schema

The 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

Environment Variables

Variable Description Default
DATABASE_URL PostgreSQL connection string Required
PORT Server port 3000

Scripts

  • npm run dev - Start development server with hot-reload
  • npm run build - Compile TypeScript to JavaScript
  • npm start - Run production build
  • npm test - Run tests (not implemented)

Dependencies

Production

  • 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

Development

  • 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

About

A full-featured restaurant management API built with Node.js, Express, TypeScript, and Prisma ORM with PostgreSQL.

Topics

Resources

Stars

Watchers

Forks

Contributors