Skip to content

CallmeSen/CNPM-Final-Project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

116 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

frontend-cibackend-cideploy-k8s

πŸ• Fastie.Saigon – Food Delivery Microservices Platform

A comprehensive microservices-based food ordering and delivery platform built with modern technologies. Supports four distinct user roles with real-time tracking, secure payments, and complete observability.

Architecture License Node.js React MongoDB Kubernetes

πŸ“‹ Table of Contents

🎯 Overview

Fastie.Saigon is a full-featured food delivery platform that connects customers, restaurants, and delivery personnel through a seamless digital experience. The platform supports real-time order tracking, secure payment processing, and comprehensive analytics.

🎭 User Roles

  • πŸ‘€ Customers: Browse restaurants, place orders, track deliveries in real-time
  • πŸͺ Restaurant Admins: Manage menus, process orders, update order statuses
  • 🚴 Delivery Personnel: Accept deliveries, update locations, manage assignments
  • πŸ‘‘ Super Admin: Oversee all users, restaurants, and system operations

✨ Features

🍽️ Customer Features

  • Browse restaurants and menus with rich media
  • Advanced search and filtering by cuisine, price, rating
  • Shopping cart with real-time updates
  • Secure checkout with Stripe integration
  • Real-time order tracking with delivery personnel location
  • Order history and reordering
  • Customer reviews and ratings

πŸͺ Restaurant Features

  • Complete menu management (CRUD operations)
  • Order management with status updates
  • Real-time order notifications
  • Sales analytics and reporting
  • Customer feedback management
  • Restaurant profile customization

🚴 Delivery Features

  • Real-time delivery assignments
  • GPS location sharing
  • Order status updates
  • Delivery history and earnings tracking
  • Route optimization suggestions

πŸ‘‘ Admin Features

  • User management across all roles
  • Restaurant onboarding and approval
  • System-wide analytics and monitoring
  • Payment reconciliation
  • Customer support tools

πŸ—οΈ Architecture

Microservices Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Frontend Apps β”‚    β”‚  API Gateway    β”‚    β”‚   Monitoring    β”‚
β”‚                 β”‚    β”‚   (Nginx)       β”‚    β”‚   Stack         β”‚
β”‚ β€’ Client (3000) │◄──►│                 β”‚    β”‚ β€’ Prometheus    β”‚
β”‚ β€’ Admin (3001)  β”‚    β”‚ β€’ Load Balance  β”‚    β”‚ β€’ Grafana       β”‚
β”‚ β€’ Restaurant    β”‚    β”‚ β€’ SSL/TLS       β”‚    β”‚ β€’ Loki          β”‚
β”‚   (3002)        β”‚    β”‚ β€’ Rate Limiting β”‚    β”‚ β€’ Promtail      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                       β”‚                       β”‚
         β–Ό                       β–Ό                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Auth Service   β”‚    β”‚ Order Service   β”‚    β”‚Payment Service  β”‚
β”‚   (Port 5001)   β”‚    β”‚  (Port 5005)    β”‚    β”‚  (Port 5004)    β”‚
β”‚ β€’ JWT Auth      β”‚    β”‚ β€’ WebSocket     β”‚    β”‚ β€’ Stripe        β”‚
β”‚ β€’ User Mgmt     β”‚    β”‚ β€’ Real-time     β”‚    β”‚ β€’ Webhooks      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚ β€’ Order Logic   β”‚    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜             β”‚
                              β”‚                        β”‚
                              β–Ό                        β–Ό
                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                   β”‚Restaurant Serviceβ”‚    β”‚Delivery Service β”‚
                   β”‚  (Port 5002)     β”‚    β”‚  (Port 5003)    β”‚
                   β”‚ β€’ Menu Mgmt      β”‚    β”‚ β€’ GPS Tracking  β”‚
                   β”‚ β€’ File Upload    β”‚    β”‚ β€’ Real-time     β”‚
                   β”‚ β€’ Analytics      β”‚    β”‚ β€’ Assignments   β”‚
                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β–Ό
                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                   β”‚   Databases     β”‚
                   β”‚   (MongoDB)     β”‚
                   β”‚ β€’ Auth DB       β”‚
                   β”‚ β€’ Restaurant DB β”‚
                   β”‚ β€’ Order DB      β”‚
                   β”‚ β€’ Payment DB    β”‚
                   β”‚ β€’ Delivery DB   β”‚
                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Service Details

Service Port Technology Database Description
Auth Service 5001 NestJS + TypeScript MongoDB JWT authentication, user management
Restaurant Service 5002 Express.js MongoDB Menu management, file uploads
Order Service 5005 NestJS + WebSocket MongoDB Order processing, real-time updates
Payment Service 5004 Express.js MongoDB Stripe integration, webhooks
Delivery Service 5003 Express.js + Socket.IO MongoDB GPS tracking, delivery management
Client Frontend 3000 Next.js 15 + React 19 - Customer-facing application
Admin Frontend 3001 Next.js + React - Super admin dashboard
Restaurant Frontend 3002 Next.js + React - Restaurant management interface

πŸ› οΈ Tech Stack

Backend Services

  • Framework: NestJS, Express.js
  • Language: TypeScript, JavaScript
  • Database: MongoDB with Mongoose ODM
  • Authentication: JWT with Passport.js
  • Real-time: WebSocket (Socket.IO), Server-Sent Events
  • File Storage: Multer for uploads, local storage

Frontend Applications

  • Framework: Next.js 15 (App Router)
  • Language: TypeScript, JavaScript
  • UI Library: React 19
  • Styling: Tailwind CSS, Bootstrap 5
  • State Management: React Context, Custom Hooks
  • HTTP Client: Axios
  • Animations: Framer Motion

DevOps & Infrastructure

  • Containerization: Docker & Docker Compose
  • Orchestration: Kubernetes (K8s)
  • CI/CD: GitHub Actions
  • Monitoring: Prometheus + Grafana + Loki
  • Load Balancing: Nginx
  • Database: MongoDB with StatefulSets

External Services

  • Payment Processing: Stripe
  • Email Service: Resend
  • SMS Service: Twilio
  • Container Registry: Docker Hub

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ and npm
  • Docker and Docker Compose
  • MongoDB (local or cloud)
  • Git

1. Clone the Repository

git clone https://github.com/CallmeSen/CNPM-Final-Project.git
cd CNPM-Final-Project

2. Environment Setup

# Copy environment template
cp env.template .env

# Edit .env with your configuration
# Required: MongoDB URIs, JWT secret, Stripe keys, etc.

3. Local Development with Docker

# Start all services
docker-compose up --build

# Or start individual services
docker-compose up mongodb auth-service restaurant-service

4. Manual Development Setup

# Install dependencies for all services
npm run install:all

# Start MongoDB (if not using Docker)
mongod

# Start backend services
npm run dev:auth        # Port 5001
npm run dev:restaurant  # Port 5002
npm run dev:order       # Port 5005
npm run dev:payment     # Port 5004
npm run dev:delivery    # Port 5003

# Start frontend applications
cd frontend/client && npm run dev      # Port 3000
cd frontend/admin && npm run dev       # Port 3001
cd frontend/restaurant && npm run dev  # Port 3002

5. Access the Application

πŸ“– API Documentation

Authentication Endpoints

POST /api/auth/login
POST /api/auth/register
POST /api/auth/refresh
GET  /api/auth/profile

Restaurant Endpoints

GET    /api/restaurant
POST   /api/restaurant
GET    /api/restaurant/:id
PUT    /api/restaurant/:id
DELETE /api/restaurant/:id

# Menu Management
GET    /api/food-items
POST   /api/food-items
PUT    /api/food-items/:id
DELETE /api/food-items/:id

Order Endpoints

GET    /api/orders
POST   /api/orders
GET    /api/orders/:id
PUT    /api/orders/:id/status
WebSocket: /api/orders/events

Payment Endpoints

POST   /api/payment/create-session
POST   /api/payment/webhook
GET    /api/payment/status/:orderId

Delivery Endpoints

GET    /api/delivery/assignments
PUT    /api/delivery/:id/status
PUT    /api/delivery/:id/location
WebSocket: /api/delivery/tracking

🐳 Docker Deployment

Development Environment

# Start complete development stack
docker-compose up --build

# View logs
docker-compose logs -f

# Stop services
docker-compose down

Production Environment

# Build production images
docker-compose -f docker-compose.prod.yml build

# Deploy production stack
docker-compose -f docker-compose.prod.yml up -d

Individual Service Management

# Start specific service
docker-compose up auth-service

# Rebuild and restart service
docker-compose up --build --force-recreate auth-service

☸️ Kubernetes Deployment

Prerequisites

  • Kubernetes cluster (Docker Desktop, Minikube, or cloud)
  • kubectl configured
  • Docker Hub account for image registry

Automated Deployment (CI/CD)

# Push to main branch to trigger deployment
git add .
git commit -m "Deploy to production"
git push origin main

Manual Deployment

# Set Docker Hub credentials
kubectl create secret docker-registry dockerhub-secret \
  --docker-server=https://index.docker.io/v1/ \
  --docker-username=YOUR_USERNAME \
  --docker-password=YOUR_PASSWORD \

# Deploy to Kubernetes
kubectl apply -f infra/k8s/
kubectl apply -f infra/k8s/monitoring
kubectl apply -f infra/k8s/jobs

# Check deployment status
kubectl get pods -n cnpm-food-delivery
kubectl get services -n cnpm-food-delivery

πŸ“Š Monitoring & Observability

Included Monitoring Stack

  • Prometheus: Metrics collection and alerting
  • Grafana: Visualization dashboards
  • Loki: Log aggregation
  • Promtail: Log shipping from containers

Pre-configured Dashboards

  1. Backend Services Overview: Monitor all microservices
  2. Frontend Services Overview: Track frontend performance
  3. System Overview: Infrastructure metrics
  4. Loki Logs Dashboard: Centralized logging
  5. Node.js Application Dashboard: Runtime metrics

Access Monitoring

# Run the monitoring access script
.\start-k8s-port-forward.ps1

πŸ§ͺ Testing

Unit Tests

# Run tests for specific service
npm run tests:unit

# Run tests with coverage
npm run test:cov

# Run e2e tests
npm run test:e2e

Integration Tests

# Run load tests
npm run tests:intergration

🀝 Contributing

Development Workflow

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Code Standards

  • TypeScript: Strict mode enabled
  • ESLint: Airbnb config with React rules
  • Prettier: Code formatting
  • Husky: Pre-commit hooks for linting

Commit Convention

feat: add new payment method
fix: resolve order status bug
docs: update API documentation
style: format code with Prettier
refactor: optimize database queries
test: add unit tests for auth service

πŸ“„ License

This project is licensed under the GNU License - see the LICENSE file for details.

πŸ‘₯ Team


About

Microservices-based food delivery platform with three React frontends and five Node/Nest backend services (auth, restaurant, order, delivery, payment), Dockerized with MongoDB and Stripe integrations

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors