A comprehensive delivery management platform connecting partners, agents, and administrators
Features β’ Installation β’ Documentation β’ API Reference β’ Deployment
- Overview
- Features
- Tech Stack
- Project Structure
- Prerequisites
- Quick Start
- Installation
- Configuration
- Running the Application
- API Documentation
- Deployment
- Development
- Contributing
- License
Centralized Delivery Network is a full-stack delivery management platform that enables seamless coordination between delivery partners, agents, and administrators. The platform provides real-time tracking, order management, analytics, and comprehensive administrative tools.
- π Real-time Order Management - Live order tracking and status updates
- π Location Tracking - Real-time agent location monitoring
- π REST API Integration - Partner API for seamless integrations
- π Analytics Dashboard - Comprehensive metrics and insights
- π Multi-role Authentication - Secure role-based access control
- π± Mobile-Optimized - Responsive design for all devices
- β REST API for order creation and management
- β Webhook support for real-time order updates
- β Comprehensive dashboard with analytics
- β API key management and rotation
- β Order tracking and status monitoring
- β Performance metrics and reporting
- β Real-time order notifications
- β Accept/reject order offers
- β Live location tracking
- β Order status updates (Pickup, Delivery, etc.)
- β Profile and document management
- β KYC verification system
- β Earnings and performance tracking
- β Mobile-optimized interface with collapsible sidebar
- β Live map view of all agents and orders
- β Agent approval and management
- β Partner account management
- β Order oversight and reassignment
- β KYC document verification
- β System-wide analytics dashboard
- β Support ticket management
- β Real-time system monitoring
| Technology | Purpose |
|---|---|
| Node.js 18+ | Runtime environment |
| Express.js | Web framework |
| TypeScript | Type-safe development |
| PostgreSQL | Primary database |
| Prisma | ORM and database toolkit |
| Redis | Caching and real-time data |
| Socket.io | WebSocket for real-time updates |
| JWT | Authentication |
| Multer | File upload handling |
| Firebase Admin | Push notifications |
| Technology | Purpose |
|---|---|
| Next.js 16 | React framework with App Router |
| TypeScript | Type-safe development |
| Tailwind CSS 4 | Utility-first CSS framework |
| Axios | HTTP client |
| Socket.io Client | WebSocket client |
| Mapbox GL | Interactive maps |
| Recharts | Data visualization |
| NextAuth.js | Authentication |
| Zod | Schema validation |
NextJS/
βββ backend/ # Express.js API Server
β βββ src/
β β βββ controllers/ # Request handlers
β β βββ routes/ # API route definitions
β β βββ services/ # Business logic layer
β β βββ middleware/ # Auth, validation, error handling
β β βββ lib/ # External library configs
β β β βββ prisma.ts # Prisma client
β β β βββ redis.ts # Redis client
β β β βββ websocket.ts # Socket.io server
β β β βββ webhook.ts # Webhook utilities
β β βββ utils/ # Utility functions
β βββ prisma/
β β βββ schema.prisma # Database schema
β β βββ migrations/ # Database migrations
β βββ uploads/ # File uploads directory
β
βββ next-app/ # Next.js Frontend Application
β βββ app/ # Next.js App Router
β β βββ (admin)/ # Admin route group
β β βββ (agent)/ # Agent route group
β β βββ (partner)/ # Partner route group
β β βββ (auth)/ # Authentication routes
β βββ components/ # React components
β β βββ layout/ # Layout components
β β βββ maps/ # Map components
β β βββ orders/ # Order components
β β βββ ui/ # Reusable UI components
β βββ lib/ # Utilities and helpers
β β βββ api/ # API client functions
β β βββ utils/ # Helper functions
β βββ public/ # Static assets
β
βββ docs/ # Project documentation
βββ API_DOCUMENTATION.md
βββ DEPLOYMENT.md
βββ PARTNER_INTEGRATION_GUIDE.md
βββ ...
Before you begin, ensure you have the following installed:
- Node.js 18+ (Download)
- npm or yarn package manager
- PostgreSQL 12+ (Download)
- Redis (Optional, for caching and real-time features)
- Git (Download)
- Mapbox Account - For map features (Sign up)
- Firebase Project - For push notifications (Optional)
# Clone the repository
git clone <repository-url>
cd NextJS
# Backend setup
cd backend
npm install
cp .env.example .env
# Edit .env with your configuration
npm run prisma:generate
npm run prisma:migrate
npm run dev
# Frontend setup (in a new terminal)
cd ../next-app
npm install
cp .env.local.example .env.local
# Edit .env.local with your configuration
npm run devVisit http://localhost:3000 to see the application.
git clone <repository-url>
cd NextJScd backend
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env
# Edit .env with your configuration
# Set up database
npm run prisma:generate
npm run prisma:migrate
# (Optional) Seed database
npm run prisma:seedcd ../next-app
# Install dependencies
npm install
# Set up environment variables
cp .env.local.example .env.local
# Edit .env.local with your configurationCreate backend/.env:
# Server Configuration
NODE_ENV=development
PORT=5000
# Database
DATABASE_URL="postgresql://user:password@localhost:5432/delivery_network"
# Authentication
JWT_SECRET="your-super-secret-jwt-key-minimum-32-characters-long"
# CORS
CORS_ORIGIN="http://localhost:3000"
# Redis (Optional)
REDIS_ENABLED=true
REDIS_URL="redis://localhost:6379"
# Firebase (Optional)
FIREBASE_PROJECT_ID="your-project-id"
FIREBASE_PRIVATE_KEY="your-private-key"
FIREBASE_CLIENT_EMAIL="your-client-email"Create next-app/.env.local:
# API Configuration
NEXT_PUBLIC_API_URL="http://localhost:5000/api"
# Authentication
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="your-nextauth-secret-minimum-32-characters"
# Maps
NEXT_PUBLIC_MAPBOX_ACCESS_TOKEN="pk.your-mapbox-token"# Generate JWT_SECRET
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
# Generate NEXTAUTH_SECRET
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"Terminal 1 - Start Backend:
cd backend
npm run devBackend runs on http://localhost:5000
Terminal 2 - Start Frontend:
cd next-app
npm run devFrontend runs on http://localhost:3000
Build and Start Backend:
cd backend
npm run build
npm startBuild and Start Frontend:
cd next-app
npm run build
npm start- Development:
http://localhost:5000/api - Production:
https://your-backend-url.onrender.com/api
Authorization: Bearer <jwt_token>X-API-Key: pk_<your_api_key>Register User:
curl -X POST http://localhost:5000/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"name": "John Doe",
"email": "john@example.com",
"password": "securePassword123",
"role": "AGENT"
}'Create Order (Partner API):
curl -X POST http://localhost:5000/api/partner-api/orders \
-H "X-API-Key: pk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"pickupLat": 28.7041,
"pickupLng": 77.1025,
"dropLat": 28.6139,
"dropLng": 77.2090,
"payoutAmount": 150.00,
"priority": "HIGH"
}'π See docs/API_DOCUMENTATION.md for complete API documentation.
See docs/QUICK_DEPLOY.md for fast-track deployment.
See docs/DEPLOYMENT.md for comprehensive deployment instructions.
- Backend: Render.com (recommended)
- Frontend: Netlify (recommended)
- Database: Render PostgreSQL or external PostgreSQL
- Redis: Render Redis or external Redis
npm run dev # Start development server with hot reload
npm run build # Build for production
npm start # Start production server
npm run prisma:generate # Generate Prisma Client
npm run prisma:migrate # Run database migrations
npm run prisma:studio # Open Prisma Studio (database GUI)
npm run prisma:seed # Seed database with sample datanpm run dev # Start development server
npm run build # Build for production
npm start # Start production server
npm run lint # Run ESLint- Backend: MVC pattern with controllers, services, and routes
- Frontend: Component-based architecture with Next.js App Router
- Database: Prisma ORM with migrations
- Real-time: Socket.io for WebSocket connections
- Copy
.env.exampleto.envin backend - Copy
.env.local.exampleto.env.localin next-app - Fill in all required environment variables
- Run database migrations
- Start development servers
- β JWT Authentication - Secure token-based authentication
- β API Key Authentication - For partner integrations
- β Password Hashing - bcryptjs with salt rounds
- β CORS Protection - Configurable allowed origins
- β Input Validation - Zod and Express Validator
- β File Upload Validation - Type and size restrictions
- β Environment Variables - Sensitive data in .env files
- β SQL Injection Protection - Prisma ORM parameterized queries
- β XSS Protection - React's built-in XSS protection
The application uses PostgreSQL with Prisma ORM.
- User - Authentication and user profiles
- Agent - Delivery agent profiles and status
- Partner - Partner accounts and API keys
- Order - Delivery orders and tracking
- Document - Agent KYC documents
- SupportTicket - Support ticket management
See backend/prisma/schema.prisma for the complete schema definition.
# Create a new migration
npm run prisma:migrate
# Apply migrations in production
npm run prisma:migrate:deploy- WebSocket Support - Real-time order updates via Socket.io
- Location Tracking - Real-time agent location updates
- Order Notifications - Push notifications for order status changes
- Live Map - Real-time map updates for admin dashboard
The frontend is fully responsive with:
- β Collapsible Sidebar - Mobile-optimized navigation
- β Touch-Friendly UI - Optimized for mobile interactions
- β Responsive Design - Works seamlessly on all screen sizes
- β Progressive Web App - Can be installed on mobile devices
All documentation is available in the docs/ directory:
| Document | Description |
|---|---|
| API_DOCUMENTATION.md | Complete API reference |
| DEPLOYMENT.md | Deployment guide |
| QUICK_DEPLOY.md | Quick deployment reference |
| PARTNER_INTEGRATION_GUIDE.md | Partner API integration |
| backend-deployment-checklist.md | Backend deployment checklist |
| frontend-deployment-checklist.md | Frontend deployment checklist |
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow TypeScript best practices
- Write meaningful commit messages
- Add tests for new features
- Update documentation as needed
- Follow the existing code style
This project is licensed under the ISC License.
Need help? Check out:
- π Documentation
- π API Documentation
- π Deployment Guide
- π Partner Integration Guide
- Enhanced analytics and reporting
- Mobile app (React Native)
- Advanced route optimization
- Multi-language support
- Payment integration
- SMS notifications
- Advanced admin features
- Automated testing suite
- CI/CD pipeline
- Next.js - React framework
- Express.js - Web framework
- Prisma - Database toolkit
- Mapbox - Maps platform
- Tailwind CSS - CSS framework
Built with β€οΈ using Next.js, Express.js, and TypeScript