Skip to content

dmelloaries/Delivery-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

46 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Real-Time Order Delivery System

A modern, real-time order delivery management system with separate interfaces for users, delivery partners, and administrators. Built with React, Node.js, Express, MongoDB, and Socket.io for real-time updates.

πŸ“‹ Project Overview

The Real-Time Order Delivery System is a full-stack web application that facilitates seamless order management and delivery tracking. The system supports three types of users:

  • Users: Browse products, place orders, track deliveries in real-time, and manage their cart
  • Delivery Partners: Accept orders, update delivery status, and manage assigned deliveries
  • Admins: Monitor all orders, manage users and partners, and oversee the entire system

Key Features

  • πŸ” JWT-based authentication with role-based access control
  • πŸ”„ Real-time order status updates using Socket.io
  • πŸ›’ Shopping cart management with Zustand state management
  • πŸ“¦ Order tracking and management
  • πŸ‘₯ User and partner management for admins
  • 🐳 Fully containerized with Docker
  • 🌐 Nginx reverse proxy for efficient routing
  • πŸ“± Responsive UI built with React and Tailwind CSS

πŸ—οΈ System Architecture Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         Client Layer                           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”‚
β”‚  β”‚     User     β”‚  β”‚   Partner    β”‚  β”‚    Admin     β”‚          β”‚
β”‚  β”‚  Interface   β”‚  β”‚  Interface   β”‚  β”‚  Dashboard   β”‚          β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜          β”‚
β”‚         β”‚                  β”‚                  β”‚                β”‚
β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                β”‚
β”‚                            β”‚                                   β”‚
β”‚                   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”                          β”‚
β”‚                   β”‚  React Frontend β”‚                          β”‚
β”‚                   β”‚  (Vite + TS)    β”‚                          β”‚
β”‚                   β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Nginx Reverse  β”‚
                    β”‚     Proxy       β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                             β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚                  β”‚                  β”‚
    β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”
    β”‚   HTTP    β”‚    β”‚  WebSocket  β”‚   β”‚   Static    β”‚
    β”‚    API    β”‚    β”‚   Socket.io β”‚   β”‚   Assets    β”‚
    β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚                  β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚   Express Server  β”‚
          β”‚    (Node.js)      β”‚
          β”‚                   β”‚
          β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
          β”‚  β”‚   Routes    β”‚  β”‚
          β”‚  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€  β”‚
          β”‚  β”‚ Controllers β”‚  β”‚
          β”‚  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€  β”‚
          β”‚  β”‚ Middleware  β”‚  β”‚
          β”‚  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€  β”‚
          β”‚  β”‚ Validations β”‚  β”‚
          β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                    β”‚
          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”
          β”‚     MongoDB       β”‚
          β”‚    (Database)     β”‚
          β”‚                   β”‚
          β”‚  Collections:     β”‚
          β”‚  β€’ Users          β”‚
          β”‚  β€’ Partners       β”‚
          β”‚  β€’ Admins         β”‚
          β”‚  β€’ Orders         β”‚
          β”‚  β€’ Deliveries     β”‚
          β”‚  β€’ BlacklistTokensβ”‚
          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Stack Used

Frontend

  • Framework: React 19 with TypeScript
  • Build Tool: Vite
  • Routing: React Router DOM v7
  • State Management: Zustand
  • Styling: Tailwind CSS v4
  • UI Components: Radix UI primitives
  • Animations: Motion (Framer Motion)
  • Real-time: Socket.io Client
  • Icons: Lucide React, Radix Icons
  • Validation: Zod
  • HTTP Client: Fetch API

Backend

  • Runtime: Node.js
  • Framework: Express v5
  • Database: MongoDB with Mongoose ODM
  • Authentication: JWT (jsonwebtoken)
  • Password Hashing: bcrypt
  • Validation: Zod + express-validator
  • Real-time: Socket.io v4
  • CORS: cors middleware
  • Environment: dotenv

DevOps & Tools

  • Containerization: Docker & Docker Compose
  • Web Server: Nginx (reverse proxy)
  • Development: Nodemon (backend), Vite HMR (frontend)
  • API Testing: Postman (collection included)
  • Linting: ESLint

πŸ“ Folder Structure

Real-Time-Order-Delivery-System/
β”‚
β”œβ”€β”€ client/                          # Frontend React Application
β”‚   β”œβ”€β”€ public/                      # Static assets
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ assets/                  # Images, fonts, etc.
β”‚   β”‚   β”œβ”€β”€ components/              # React components
β”‚   β”‚   β”‚   β”œβ”€β”€ ui/                  # Reusable UI components (buttons, cards, etc.)
β”‚   β”‚   β”‚   β”œβ”€β”€ _admin/              # Admin-specific components
β”‚   β”‚   β”‚   β”œβ”€β”€ _partner/            # Partner-specific components
β”‚   β”‚   β”‚   β”œβ”€β”€ _user/               # User-specific components
β”‚   β”‚   β”‚   β”œβ”€β”€ Footer.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Header.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ OffersCard.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Products.tsx
β”‚   β”‚   β”‚   └── ProtectedRoute.tsx
β”‚   β”‚   β”œβ”€β”€ context/                 # State management (Zustand stores)
β”‚   β”‚   β”‚   β”œβ”€β”€ useCartStore.ts      # Shopping cart state
β”‚   β”‚   β”‚   └── useUserStore.ts      # User authentication state
β”‚   β”‚   β”œβ”€β”€ lib/                     # Utility functions
β”‚   β”‚   β”‚   β”œβ”€β”€ socket.ts            # Socket.io client configuration
β”‚   β”‚   β”‚   └── utils.ts             # Helper functions
β”‚   β”‚   β”œβ”€β”€ pages/                   # Page components
β”‚   β”‚   β”‚   β”œβ”€β”€ admin/               # Admin pages
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ AdminHome.tsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ AdminProfile.tsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ OrdersList.tsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ PartnersList.tsx
β”‚   β”‚   β”‚   β”‚   └── UsersList.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ partner/             # Partner pages
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ PartnerHome.tsx
β”‚   β”‚   β”‚   β”‚   └── PartnerOrders.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ user/                # User pages
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ UserCart.tsx
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ UserHome.tsx
β”‚   β”‚   β”‚   β”‚   └── UserOrders.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Home.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ LandingPage.tsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Login.tsx
β”‚   β”‚   β”‚   └── Register.tsx
β”‚   β”‚   β”œβ”€β”€ App.tsx                  # Main App component
β”‚   β”‚   β”œβ”€β”€ main.tsx                 # Application entry point
β”‚   β”‚   └── index.css                # Global styles
β”‚   β”œβ”€β”€ components.json              # shadcn/ui configuration
β”‚   β”œβ”€β”€ Dockerfile                   # Frontend Docker configuration
β”‚   β”œβ”€β”€ nginx.conf                   # Nginx config for frontend
β”‚   β”œβ”€β”€ package.json                 # Frontend dependencies
β”‚   β”œβ”€β”€ tsconfig.json                # TypeScript configuration
β”‚   β”œβ”€β”€ vite.config.ts               # Vite configuration
β”‚   └── README.md                    # Client documentation
β”‚
β”œβ”€β”€ server/                          # Backend Node.js Application
β”‚   β”œβ”€β”€ controllers/                 # Request handlers
β”‚   β”‚   β”œβ”€β”€ admin.controller.js      # Admin operations
β”‚   β”‚   β”œβ”€β”€ delivery.controller.js   # Delivery management
β”‚   β”‚   β”œβ”€β”€ map.controller.js        # Map/location services
β”‚   β”‚   β”œβ”€β”€ partner.controller.js    # Partner operations
β”‚   β”‚   └── user.controller.js       # User operations
β”‚   β”œβ”€β”€ db/
β”‚   β”‚   └── db.js                    # Database connection
β”‚   β”œβ”€β”€ middlewares/
β”‚   β”‚   └── auth.middleware.js       # JWT authentication
β”‚   β”œβ”€β”€ models/                      # Mongoose schemas
β”‚   β”‚   β”œβ”€β”€ admin.model.js
β”‚   β”‚   β”œβ”€β”€ BlacklistToken.model.js  # Token revocation
β”‚   β”‚   β”œβ”€β”€ delivery.model.js
β”‚   β”‚   β”œβ”€β”€ order.model.js
β”‚   β”‚   β”œβ”€β”€ partner.model.js
β”‚   β”‚   └── user.model.js
β”‚   β”œβ”€β”€ routes/                      # API route definitions
β”‚   β”‚   β”œβ”€β”€ admin.routes.js
β”‚   β”‚   β”œβ”€β”€ partner.routes.js
β”‚   β”‚   └── user.routes.js
β”‚   β”œβ”€β”€ validations/                 # Input validation schemas
β”‚   β”‚   β”œβ”€β”€ admin.validation.js
β”‚   β”‚   β”œβ”€β”€ order.validation.js
β”‚   β”‚   β”œβ”€β”€ partner.validation.js
β”‚   β”‚   └── user.validation.js
β”‚   β”œβ”€β”€ app.js                       # Express app configuration
β”‚   β”œβ”€β”€ server.js                    # Server entry point
β”‚   β”œβ”€β”€ socket.js                    # Socket.io configuration
β”‚   β”œβ”€β”€ seed-admin.js                # Admin seeding script
β”‚   β”œβ”€β”€ Dockerfile                   # Backend Docker configuration
β”‚   β”œβ”€β”€ docker-compose.yml           # Local development compose
β”‚   β”œβ”€β”€ package.json                 # Backend dependencies
β”‚   β”œβ”€β”€ Real-Time-Order-Delivery-System.postman_collection.json
β”‚   └── Real-Time-Order-Delivery-System-Local.postman_environment.json
β”‚
β”œβ”€β”€ docker-compose.yml               # Production Docker Compose
β”œβ”€β”€ nginx.conf                       # Root Nginx reverse proxy config
└── README.md                        # This file

πŸš€ Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • MongoDB (v7.0 or higher)
  • Docker & Docker Compose (for containerized deployment)

Docker Deployment

Quick Start with Docker Compose

# Build and start all services
docker-compose up -d

# View logs
docker-compose logs -f

# Stop services
docker-compose down

The application will be available at http://localhost

Local Development

1. Clone the repository

git clone https://github.com/dmelloaries/Delivery-System.git
cd Real-Time-Order-Delivery-System

2. Setup Backend

cd server
npm install

Create a .env file in the server directory:

PORT=8000
MONGODB_URI=mongodb://localhost:27017/delivery-system
JWT_SECRET=your-secret-key-here
CLIENT_URL=http://localhost:5173
NODE_ENV=development

Run the admin seeder:

node seed-admin.js

Start the server:

npm start

3. Setup Frontend

cd ../client
npm install
npm run dev

The application will be available at:

Default Admin Credentials

After running the seed script, use these credentials to login as admin:

πŸ“‘ API Documentation

Import the Postman collection and environment files from the server/ directory:

  • Real-Time-Order-Delivery-System.postman_collection.json
  • Real-Time-Order-Delivery-System-Local.postman_environment.json

πŸ”Œ Real-Time Events

The system uses Socket.io for real-time updates:

  • order:created - New order placed
  • order:updated - Order status changed
  • order:assigned - Order assigned to partner
  • delivery:updated - Delivery status updated
  • delivery:completed - Delivery completed

Made by dmelloaries

About

Real-Time Order & Delivery System

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published