GreenCart Logistics is a comprehensive logistics management system designed to optimize delivery operations through advanced simulation capabilities and real-time KPI tracking. The platform enables logistics managers to:
- Simulate Delivery Scenarios: Run realistic delivery simulations with various parameters
- Optimize Operations: Analyze driver utilization, route efficiency, and profit margins
- Manage Resources: Handle drivers, routes, and orders through intuitive interfaces
- Track Performance: Monitor KPIs with interactive dashboards and charts
- Make Data-Driven Decisions: Use simulation results to improve operational efficiency
- Reduce operational costs through optimized route planning
- Improve customer satisfaction with better delivery time predictions
- Maximize driver utilization and minimize fatigue
- Increase profitability through intelligent resource allocation
- Framework: Next.js 15 with App Router
- UI Library: React 19
- Language: TypeScript
- Styling: Tailwind CSS
- Components: Radix UI + shadcn/ui
- Charts: Recharts
- Icons: Lucide React
- Runtime: Node.js
- Framework: Next.js API Routes
- Database: PostgreSQL
- ORM: Prisma
- Authentication: JWT + bcrypt
- Validation: Zod (implicit through Prisma)
- Package Manager: npm
- Testing: Jest + ts-jest
- Linting: ESLint + Prettier
- Build Tool: Next.js built-in bundler
- Database Hosting: Neon DB (recommended)
- Node.js 18+
- PostgreSQL database (or Neon DB account)
- npm or yarn package manager
git clone <repository-url>
cd greencart-logistics/clientnpm installCreate a .env file in the client directory (see Environment Variables section below)
# Generate Prisma client
npm run db:generate
# Push schema to database
npm run db:push
# Seed database with sample data
npm run db:seednpm run devThe application will be available at http://localhost:3000
- Email:
admin@greencart.com - Password:
password123
Create a .env file in the client directory with the following variables:
# Database Configuration
DATABASE_URL="your-postgresql-connection-string"
# JWT Configuration
JWT_SECRET="your-super-secret-jwt-key"
JWT_EXPIRES_IN="24h"
# CORS Configuration
CORS_ORIGIN="http://localhost:3000"
# Application Configuration
NODE_ENV="development"DATABASE_URL: PostgreSQL connection string (required)JWT_SECRET: Secret key for JWT token signing (required, use strong random string)JWT_EXPIRES_IN: JWT token expiration time (default: 24h)CORS_ORIGIN: Allowed origin for CORS requests (update for production)NODE_ENV: Application environment (development/production)
- Connect Repository: Link your GitHub repository to Vercel
- Environment Variables: Add all environment variables in Vercel dashboard
- Database: Ensure your PostgreSQL database is accessible from Vercel
- Deploy: Vercel will automatically build and deploy
# Build for production
npm run build
# Start production server
npm start- Build Command:
npm run build - Start Command:
npm start - Node Version: 18+
- Environment Variables: Configure in platform dashboard
- Database: Ensure database connectivity
- Update
CORS_ORIGINto production domain - Use strong
JWT_SECRET(32+ characters) - Configure database connection pooling
- Enable HTTPS
- Set up monitoring and logging
- Configure backup strategy for database
- Development:
http://localhost:3000/api - Production:
https://your-domain.com/api
All protected endpoints require JWT token in Authorization header:
Authorization: Bearer <jwt-token>
POST /api/auth/login
Content-Type: application/json
{
"email": "admin@greencart.com",
"password": "password123"
}
Response:
{
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"user": {
"id": "cm123456789",
"email": "admin@greencart.com",
"name": "Admin User"
}
}# Get all drivers
GET /api/drivers
Authorization: Bearer <token>
Response:
[
{
"id": "cm123456789",
"name": "John Doe",
"email": "john@example.com",
"phone": "+1234567890",
"licenseNumber": "DL123456",
"vehicleType": "Van",
"maxHoursPerDay": 8,
"hourlyRate": 25.0,
"isActive": true,
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z"
}
]# Create new driver
POST /api/drivers
Authorization: Bearer <token>
Content-Type: application/json
{
"name": "Jane Smith",
"email": "jane@example.com",
"phone": "+1234567891",
"licenseNumber": "DL123457",
"vehicleType": "Truck",
"maxHoursPerDay": 8,
"hourlyRate": 30.0,
"isActive": true
}# Update driver
PUT /api/drivers/{id}
Authorization: Bearer <token>
Content-Type: application/json
# Delete driver
DELETE /api/drivers/{id}
Authorization: Bearer <token># Get all routes
GET /api/routes
Authorization: Bearer <token>
Response:
[
{
"id": "cm123456789",
"name": "Downtown Route",
"startLocation": "Warehouse A",
"endLocation": "Downtown District",
"distance": 15.5,
"estimatedTime": 45,
"fuelCost": 0.15,
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z"
}
]# Create new route
POST /api/routes
Authorization: Bearer <token>
Content-Type: application/json
{
"name": "Suburban Route",
"startLocation": "Warehouse B",
"endLocation": "Suburban Area",
"distance": 25.0,
"estimatedTime": 60,
"fuelCost": 0.18
}# Get all orders
GET /api/orders
Authorization: Bearer <token>
Response:
[
{
"id": "cm123456789",
"orderNumber": "ORD-001",
"customerName": "ABC Company",
"customerAddress": "123 Business St",
"orderValue": 1500.00,
"priority": "high",
"status": "pending",
"driverId": null,
"routeId": null,
"createdAt": "2024-01-01T00:00:00.000Z",
"updatedAt": "2024-01-01T00:00:00.000Z"
}
]# Create new order
POST /api/orders
Authorization: Bearer <token>
Content-Type: application/json
{
"orderNumber": "ORD-002",
"customerName": "XYZ Corp",
"customerAddress": "456 Commerce Ave",
"orderValue": 2000.00,
"priority": "urgent",
"status": "pending",
"driverId": "cm123456789",
"routeId": "cm987654321"
}# Run delivery simulation
POST /api/simulation/run
Authorization: Bearer <token>
Content-Type: application/json
{
"numDrivers": 3,
"startTime": "08:00",
"maxHours": 8
}
Response:
{
"totalProfit": 15750.25,
"efficiencyScore": 87.5,
"onTimeDeliveries": 12,
"lateDeliveries": 2,
"totalFuelCost": 245.80,
"averageDeliveryTime": 65.5,
"driverUtilization": [
{
"driver": "John Doe",
"utilization": 85
}
],
"hourlyPerformance": [
{
"hour": "08:00",
"deliveries": 3,
"efficiency": 92
}
]
}# Get simulation history
GET /api/simulation/history
Authorization: Bearer <token>
Response:
[
{
"id": "cm123456789",
"timestamp": "2024-01-01T08:00:00.000Z",
"numDrivers": 3,
"startTime": "08:00",
"maxHoursPerDay": 8,
"totalProfit": 15750.25,
"efficiencyScore": 87.5,
"onTimeDeliveries": 12,
"lateDeliveries": 2,
"totalFuelCost": 245.80,
"averageDeliveryTime": 65.5,
"driverUtilization": 85,
"hourlyPerformance": 12
}
]# Authentication Error
401 Unauthorized
{
"error": "Access token required"
}
# Validation Error
400 Bad Request
{
"error": "Missing required fields: name, email"
}
# Not Found Error
404 Not Found
{
"error": "Driver not found"
}
# Server Error
500 Internal Server Error
{
"error": "Internal server error"
}A complete Postman collection with all endpoints and example requests is available at:
/docs/GreenCart-Logistics-API.postman_collection.json
Import this collection into Postman for easy API testing and development.
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverageThis project is licensed under the MIT License - see the LICENSE file for details.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
For questions, issues, or support:
- Create an issue in the repository
- Contact the development team
- Check the documentation in
/docsfolder