LogiAPI is a production-ready, multi-tenant courier tracking API built using Node.js, Express, and MongoDB. It provides a complete logistics backend solution with authentication, API key management, real-time updates, analytics, and webhook-based notifications.
The system simulates real-world logistics platforms by enforcing structured shipment workflows, maintaining tracking history, and supporting scalable API usage.
- Shipment CRUD operations with auto-generated tracking IDs (TRK format)
- Strict shipment lifecycle: created → picked-up → in-transit → out-for-delivery → delivered
- Validation of status transitions (no skipping or reversing)
- Shipment tracking with current status and full history
- Estimated delivery date calculation
- Dual authentication system (JWT and API Key)
- Role-Based Access Control (Admin and User roles)
- Filtering, search, pagination, and sorting on shipments
- Webhook system for real-time status notifications
- Analytics API for shipment insights
- Config-driven status transition engine
- Redis caching for optimized tracking performance
- Real-time updates using Socket.io
- Background request logging stored in MongoDB
- Rate limiting for API protection
- Swagger API documentation at
/api-docs
- Node.js
- Express.js
- MongoDB with Mongoose
- Redis
- Socket.io
- JWT Authentication
- Swagger (OpenAPI)
src/
├── config/
├── models/
├── controllers/
├── routes/
├── middleware/
├── services/
├── utils/
├── sockets/
├── cache/
├── app.js
└── server.js
- Node.js installed
- MongoDB running locally or via cloud (MongoDB Atlas)
- Redis running locally or via cloud (Upstash)
- Clone the repository
git clone https://github.com/your-username/logiapi.git
cd logiapi
- Install dependencies
npm install
- Create a
.envfile
PORT=3000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_secure_secret
REDIS_URL=your_redis_connection_string
- Start the server
npm run dev
Server will run at:
http://localhost:3000
Note: The live deployed API is available at https://logiapi.onrender.com
-
POST /auth/register Register a new user and receive JWT and API key
-
POST /auth/login Login and receive JWT and API key
-
POST /shipments Create a shipment
-
GET /shipments Retrieve all shipments Supports query parameters:
- status
- search
- page
- limit
- sort
-
GET /shipments/:trackingId Retrieve shipment by tracking ID
-
PATCH /shipments/:trackingId/status Update shipment status and location
-
PUT /shipments/:trackingId Update shipment details
-
DELETE /shipments/:trackingId Delete shipment
-
GET /analytics Retrieve shipment statistics
-
GET /api-docs Access Swagger documentation
Protected routes require:
Authorization: Bearer <API_KEY>
or
x-api-key: <API_KEY>
Create Shipment
POST /shipments
Content-Type: application/json
{
"sender": {
"name": "John",
"address": "City A"
},
"receiver": {
"name": "Doe",
"address": "City B"
}
}
| Variable | Description |
|---|---|
| PORT | Server port |
| MONGO_URI | MongoDB connection string |
| JWT_SECRET | Secret key for JWT authentication |
| REDIS_URL | Redis connection string |
- All endpoints tested using Postman
- Postman collection included in the repository
🚀 Live API / Demo: https://logiapi.onrender.com Swagger Documentation is available at: https://logiapi.onrender.com/api-docs
Recommended deployment stack:
- Backend: Render or Railway
- Database: MongoDB Atlas
- Cache: Upstash Redis
- No real GPS tracking integration
- Notifications limited to webhook-based system
- No frontend interface included
- Email and SMS notifications
- Delivery agent module
- Advanced analytics dashboard
- Billing and API usage monitoring
Developed as a scalable backend system demonstrating real-world API design and logistics workflow management.