Skip to content

Latest commit

Β 

History

42 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🍽️ Delicia β€” Distributed Full‑Stack Food Ordering & Real-Time Logistics Platform

Delicia CI Pipeline License: MIT Node.js React Vite Docker Kafka Redis

Delicia is a production-grade, event-driven full-stack food delivery and logistics platform built on the MERN stack and enhanced with Apache Kafka, Redis Geospatial Indexing, Server-Sent Events (SSE), Docker, and OpenAI GPT.

It features an end-to-end customer ordering web application, an interactive driver tracking system, a secured administrative analytics dashboard, and automated event streaming for order allocation and real-time delivery tracking.


πŸ“‘ Table of Contents


⚑ Key Architecture & Highlights

  • Event-Driven Micro-Messaging (Apache Kafka): Decoupled event streaming pipeline utilizing kafkajs for handling order-allocated and driver-location-updates topics asynchronously.
  • Geospatial Nearest-Driver Matching (Redis): Uses Redis GEOSEARCH (FROMLONLAT radius querying) to compute proximity and automatically assign orders to the nearest available delivery partner.
  • Real-Time GPS Streaming (Server-Sent Events): Low-latency, unidirectional SSE channel (/api/order/track/:orderId) streaming live telemetry updates to the frontend map UI without client-side polling overhead.
  • Dual Payment Processing: Integrated with Stripe Checkout for online payments alongside Cash on Delivery (COD) checkout workflows and instant verification callbacks.
  • Containerized Infrastructure (Docker Compose): Single-command orchestration for Zookeeper, Apache Kafka, and Redis services.
  • Multi-Job Automated CI/CD Pipeline (GitHub Actions): Automated pipeline with live MongoDB container execution, Jest backend API test verification, and ESLint + Vite build validation for both frontend applications.
  • Analytics Engine (Recharts): Visual sales, revenue curves, order volumes, and categorical distributions in the Admin control panel.

πŸ› System Architecture Flow

flowchart TD
    subgraph Client Applications
        A[Customer Frontend - Vite/React]
        B[Admin Dashboard - Vite/React]
        S[Driver Telemetry Simulator]
    end

    subgraph Backend API Gateway
        API[Express.js REST API :4000]
        SSE[SSE Stream Engine]
    end

    subgraph Distributed Services
        K[Apache Kafka Broker :9092]
        R[(Redis 7.2 Cache & GeoIndex :6379)]
        M[(MongoDB Atlas Database)]
        OAI[OpenAI GPT API]
        ST[Stripe Payment Gateway]
    end

    A -->|Browse, Cart, Order, Auth| API
    A -->|Subscribe to Live Location| SSE
    B -->|Menu & Order CRUD, Analytics| API
    S -->|Push Live GPS Coordinates| API

    API -->|Persist Users, Orders, Menu| M
    API -->|Geospatial Radius Query & Caching| R
    API -->|Publish Location & Order Events| K
    API -->|Process Payments| ST
    API -->|Delicia AI Assistant Chat| OAI

    K -->|Consume Location Updates| SSE
    SSE -->|Stream Lat/Lon Coordinates| A
Loading

πŸ–ΌοΈ Application Screenshots

Customer Home & Food Discovery

Home Page

Category Filtering, Search & Menu Catalog

Menu Page

Cart, Pricing & Localized Checkout (β‚Ή INR)

Cart Page

Secured Admin Analytics & Operations Dashboard

Admin Dashboard

πŸ“Œ High-resolution images are located in the screenshots/ directory.


✨ Feature Breakdown

1. Customer Web Application

  • Interactive Menu & Category Filtering: Filter by Salad, Rolls, Deserts, Sandwich, Cake, Pure Veg, Pasta, Noodles, and more.
  • Dynamic Search & Filtering: Multi-condition search across dish names, descriptions, price boundaries, and bestseller chips.
  • Cart State Management: Persistent cart context with quantity controls, delivery charge computation, and instant total calculations.
  • Currency Localization: Complete support for Indian Rupees (β‚Ή INR) using Intl.NumberFormat("en-IN").
  • User Profile & Order Center: Dedicated user dashboard managing personal details, avatar uploads (multer), multi-address book, password updates, and historical orders.
  • Dual Payment Workflow: Seamless integration with Stripe Checkout and direct Cash on Delivery (COD) verification.

2. Real-Time Driver Tracking & Logistics

  • Proximity Allocation: Redis Geospatial GEOSEARCH automatically locates available drivers within a 10km radius upon payment confirmation.
  • Real-Time Map & Telemetry: Live order tracking interface (/tracking/:orderId) with Server-Sent Events (SSE) streaming live vehicle coordinates directly from Kafka events.
  • Driver Simulator: Built-in simulator script (simulate-driver.js) generating realistic GPS telemetry trajectories.

3. Admin Analytics & Operations Portal

  • Secured Authentication: JWT-protected admin portal with restricted role access.
  • Interactive Analytics (Recharts): Visual graphs displaying total revenue, active orders, user counts, item distribution, and daily performance metrics.
  • Menu Management (CRUD): Add dishes with custom image uploads via Multer, update menu pricing, and manage category listings.
  • Order Lifecycle Workflow: Real-time status management (Food Processing βž” Out for Delivery βž” Delivered).

4. AI Assistant & Support System

  • Delicia AI Chatbot: Built-in floating assistant powered by OpenAI GPT (/api/chat) offering personalized dish recommendations, order assistance, and FAQ resolution.
  • Partner & Franchise Portal: Application submission workflow (/partner) with document/resume attachment uploads and automated email notifications.
  • Contact & Inquiries: Customer support contact forms routed via Nodemailer.

🧰 Tech Stack & Tooling

Layer Technologies
Frontend (User & Admin) React 18, Vite, Tailwind CSS v4, Framer Motion, GSAP, Lucide Icons, Recharts, React Router v6, Axios, React Toastify
Backend API Node.js, Express.js (ES Modules), Mongoose, Multer, JWT, Bcrypt, CORS, Dotenv
Distributed Messaging & Cache Apache Kafka (kafkajs), Confluent Zookeeper, Redis 7.2 (ioredis Geospatial)
Real-Time Communication Server-Sent Events (SSE)
Database & Cloud MongoDB / MongoDB Atlas
Integrations & AI Stripe API, OpenAI GPT API, Nodemailer (SMTP)
DevOps & Infrastructure Docker, Docker Compose, GitHub Actions CI/CD
Testing & Quality Jest, Supertest, ESLint

πŸ”Œ API Reference

πŸ” Authentication & Profile (/api/user)

  • POST /api/user/register β€” Register new customer account
  • POST /api/user/login β€” Authenticate and return JWT token
  • GET /api/user/profile β€” Fetch current user profile (Authenticated)
  • PUT /api/user/updateprofile β€” Update name, phone, and profile details
  • PUT /api/user/changepassword β€” Update account security password
  • POST /api/user/upload-avatar β€” Upload profile avatar image (multipart/form-data)
  • GET /api/user/useraddresses β€” Retrieve saved delivery addresses
  • PUT /api/user/update-address β€” Add or modify saved delivery address

🍲 Food & Menu (/api/food)

  • GET /api/food/list β€” Retrieve menu items (supports search, category filter, sorting, pagination)
  • POST /api/food/add β€” Add new food dish with image file (multipart/form-data)
  • POST /api/food/remove β€” Delete food dish by ID

πŸ›’ Cart Operations (/api/cart)

  • POST /api/cart/get β€” Fetch user's cart contents
  • POST /api/cart/add β€” Add item / increment quantity in cart
  • POST /api/cart/remove β€” Decrement / remove item from cart

πŸ“¦ Orders & Tracking (/api/order)

  • POST /api/order/place β€” Place an order (generates Stripe checkout session or COD order)
  • POST /api/order/verify β€” Verify Stripe transaction, trigger Redis driver match & Kafka allocation
  • POST /api/order/userorders β€” Retrieve orders for authenticated user
  • GET /api/order/list β€” List all customer orders (Admin)
  • POST /api/order/status β€” Update order progress state (Admin)
  • GET /api/order/track/:orderId β€” SSE stream broadcasting live driver telemetry

πŸ›΅ Driver & Telemetry (/api/driver)

  • POST /api/driver/register β€” Register a delivery driver
  • POST /api/driver/location β€” Push GPS latitude/longitude (updates Redis Geo & Kafka stream)

πŸ“Š Admin, AI & Inquiries

  • POST /api/admin/login β€” Admin portal authentication
  • GET /api/dashboard/stats β€” High-level analytics metrics (Revenue, Orders, Category splits)
  • POST /api/chat β€” Query Delicia AI assistant (OpenAI GPT)
  • POST /api/contact β€” Submit customer support message (Nodemailer)
  • POST /api/partner β€” Submit partner/franchise application with documents

πŸ“ Repository Structure

Delicia/
β”œβ”€β”€ .github/
β”‚   └── workflows/
β”‚       └── ci.yml               # GitHub Actions CI Pipeline (Mongo, Jest, Lint, Build)
β”œβ”€β”€ admin/                       # Admin Analytics & Management Dashboard (Vite + React)
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/          # Navbar, Sidebar, UI components
β”‚   β”‚   └── pages/               # Dashboard (Charts), Add, List, Orders, Login
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.js
β”œβ”€β”€ backend/                     # Node.js Express REST API & Streaming Engine
β”‚   β”œβ”€β”€ config/                  # MongoDB, Kafka, and Redis client configurations
β”‚   β”œβ”€β”€ controllers/             # Business logic (User, Order, Food, Driver, Dashboard, etc.)
β”‚   β”œβ”€β”€ middleware/              # Auth verification & Multer file upload handlers
β”‚   β”œβ”€β”€ models/                  # Mongoose Schemas (User, Food, Order, Driver, Admin)
β”‚   β”œβ”€β”€ routes/                  # Express route declarations
β”‚   β”œβ”€β”€ tests/                   # Jest & Supertest automated API tests
β”‚   β”œβ”€β”€ uploads/                 # Static media storage for dishes & avatars
β”‚   β”œβ”€β”€ server.js                # Server entry point, SSE stream & OpenAI endpoint
β”‚   └── package.json
β”œβ”€β”€ frontend/                    # Customer-Facing Web Application (Vite + React)
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/          # Navbar, Footer, FoodDisplay, Chatbot, LoginPopup, etc.
β”‚   β”‚   β”œβ”€β”€ Context/             # React Context Store for Cart & Global State
β”‚   β”‚   β”œβ”€β”€ pages/               # Home, Cart, PlaceOrder, MyOrders, Dashboard, Tracking
β”‚   β”‚   └── assets/              # Icons, banners, and graphical assets
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.js
β”œβ”€β”€ screenshots/                 # Application preview screenshots
β”œβ”€β”€ docker-compose.yml           # Multi-container orchestration (Kafka, Zookeeper, Redis)
β”œβ”€β”€ simulate-driver.js           # Live driver GPS telemetry simulation script
└── README.md

βš™οΈ Getting Started & Local Setup

Prerequisites

  • Node.js: v18.x or higher
  • npm: v9.x or higher
  • Docker & Docker Compose: Installed and running (Docker Desktop)
  • MongoDB: Local instance or free MongoDB Atlas cluster

1. Clone Repository

git clone https://github.com/Vikaumar/Delicia.git
cd Delicia

2. Start Infrastructure (Docker Compose)

Launch Apache Kafka, Zookeeper, and Redis containers:

docker-compose up -d

Verify services are healthy:

  • Redis: localhost:6379
  • Kafka: localhost:9092
  • Zookeeper: localhost:2181

3. Backend Setup

cd backend
npm install

Create a .env file inside backend/ (refer to Environment Configuration):

# Start backend in development mode (with nodemon)
npm run dev

Backend runs on: http://localhost:4000


4. Frontend Setup

Open a new terminal:

cd frontend
npm install
npm run dev

Customer web application runs on: http://localhost:5173


5. Admin Dashboard Setup

Open a new terminal:

cd admin
npm install
npm run dev

Admin management dashboard runs on: http://localhost:5174


6. Simulate Driver Live Telemetry

To test real-time geospatial driver allocation and live map SSE streaming:

# In the root directory:
npm install axios
node simulate-driver.js

This registers a simulated delivery driver and pushes GPS coordinates to the backend every 2 seconds.


πŸ” Environment Configuration

Create a .env file in the backend/ directory:

# ─── Server & Ports ───
PORT=4000
NODE_ENV=development

# ─── Database ───
MONGO_URI=mongodb+srv://<username>:<password>@cluster.mongodb.net/Delicia?retryWrites=true&w=majority

# ─── Authentication ───
JWT_SECRET=your_jwt_secret_key_here

# ─── Stripe Payment Gateway ───
STRIPE_SECRET_KEY=sk_test_your_stripe_secret_key

# ─── OpenAI Chatbot Assistant ───
OPENAI_API_KEY=sk-proj-your_openai_api_key

# ─── Application URLs (CORS & Callbacks) ───
FRONTEND_URL=http://localhost:5173
ADMIN_URL=http://localhost:5174

# ─── Email & Notifications (Nodemailer SMTP) ───
SUPPORT_EMAIL=support@delicia.com
PARTNERS_EMAIL=partners@delicia.com
EMAIL_HOST=smtp.example.com
EMAIL_PORT=587
EMAIL_USER=your_email@example.com
EMAIL_PASS=your_email_password
EMAIL_FROM="Delicia Support <support@delicia.com>"

πŸ§ͺ Automated Testing & CI/CD

Running Backend Tests Locally

The project includes automated integration tests using Jest and Supertest:

cd backend
npm test

Continuous Integration (GitHub Actions)

The repository contains a robust CI workflow (.github/workflows/ci.yml) that automatically triggers on every push and pull request to main:

  1. Backend Integration Pipeline: Spins up a native mongo:latest service container and executes the Jest test suite.
  2. Frontend Quality Check: Executes ESLint analysis and verifies Vite production build bundle creation.
  3. Admin Portal Check: Executes ESLint validation and verifies Vite production build.

πŸ“œ License

This project is open source and available under the MIT License.


πŸ‘¨β€πŸ’» Author

Vikas Kumar

  • πŸŽ“ B.Tech CSE, IIIT Kota (3rd Year)
  • πŸ’Ό Aspiring Full‑Stack / Software Development Engineer
  • πŸ”— GitHub: @Vikaumar

⭐ If you find this project helpful, consider starring the repository!

Releases

Packages

Contributors

Languages