A comprehensive courier management system built with Express.js, Prisma, and PostgreSQL.
- Role-Based Access Control: Admin, Driver, Customer, and Manager roles
- JWT Authentication: Secure authentication with 30-day token expiry
- Delivery Management: Complete delivery tracking from request to completion
- Invoice Generation: Automated weekly invoice generation
- Pricing Tiers: Flexible pricing based on weight and distance
- Driver Management: Assign deliveries and track driver performance
- Proof of Delivery: Signature and photo capture
- Analytics Dashboard: Comprehensive reporting and analytics
- Node.js (v16 or higher)
- PostgreSQL database
- npm or yarn
- Install dependencies:
npm install- Set up environment variables:
cp .env.example .env
# Edit .env with your configuration- Generate Prisma Client:
npm run prisma:generate- Run database migrations:
npm run prisma:migrate- Seed the database (optional):
npm run prisma:seednpm run devnpm startThe server will start on http://localhost:5000
m19logistics/
├── prisma/
│ ├── schema.prisma # Database schema
│ └── seed.js # Database seeding
├── src/
│ ├── config/
│ │ ├── index.js # Configuration settings
│ │ └── database.js # Prisma client setup
│ ├── controllers/
│ │ └── authController.js # Authentication controller
│ ├── middleware/
│ │ ├── authenticate.js # JWT authentication
│ │ ├── authorize.js # Role-based authorization
│ │ ├── errorHandler.js # Global error handler
│ │ └── validate.js # Request validation
│ ├── routes/
│ │ ├── index.js # Route aggregator
│ │ └── authRoutes.js # Auth routes
│ ├── services/
│ │ ├── authService.js # Authentication service
│ │ └── userService.js # User service
│ ├── utils/ # Utility functions
│ ├── app.js # Express app setup
│ └── server.js # Server entry point
├── public/
│ └── uploads/ # File uploads
├── .env # Environment variables
├── .gitignore # Git ignore rules
├── package.json # Dependencies
└── README.md # Documentation
- ADMIN: Full system access
- DRIVER: View assigned deliveries, upload proof of delivery
- CUSTOMER: Request deliveries, view history and invoices
- MANAGER: Analytics and reporting access
POST /api/auth/register- Register new userPOST /api/auth/login- Login userPOST /api/auth/logout- Logout userGET /api/auth/me- Get current user profilePOST /api/auth/change-password- Change password
GET /api/health- API health status
The system uses the following main models:
- User: User accounts with role-based access
- Delivery: Delivery requests and tracking
- Invoice: Weekly invoices per customer
- PricingTier: Pricing configuration
- AccessToken: JWT token management
- AuditLog: Change tracking
- DriverFeedback: Driver notes per delivery
- JWT-based authentication with 30-day expiry
- Bcrypt password hashing
- Role-based access control
- Token revocation support
- Helmet.js security headers
- Request validation
Configure SMTP settings in .env for:
- Delivery notifications
- Invoice emails
- Weekly reports
npm testSee .env.example for all available configuration options.
This is a private project for M19 Logistics Limited.
ISC
For support, email admin@m19logistics.com or call 07971415430.