Skip to content

Naren1520/LogiAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LogiAPI – Scalable Courier Tracking API Platform

Project Overview

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.


Features

Core Features

  • 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

Advanced Features

  • 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

System Enhancements

  • 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

Tech Stack

  • Node.js
  • Express.js
  • MongoDB with Mongoose
  • Redis
  • Socket.io
  • JWT Authentication
  • Swagger (OpenAPI)

Project Structure

src/
├── config/
├── models/
├── controllers/
├── routes/
├── middleware/
├── services/
├── utils/
├── sockets/
├── cache/
├── app.js
└── server.js

Setup Instructions

Prerequisites

  • Node.js installed
  • MongoDB running locally or via cloud (MongoDB Atlas)
  • Redis running locally or via cloud (Upstash)

Installation

  1. Clone the repository
git clone https://github.com/your-username/logiapi.git
cd logiapi
  1. Install dependencies
npm install
  1. Create a .env file
PORT=3000
MONGO_URI=your_mongodb_connection_string
JWT_SECRET=your_secure_secret
REDIS_URL=your_redis_connection_string
  1. 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


API Endpoints

Authentication

  • POST /auth/register Register a new user and receive JWT and API key

  • POST /auth/login Login and receive JWT and API key


Shipments

  • 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


Additional Endpoints

  • GET /analytics Retrieve shipment statistics

  • GET /api-docs Access Swagger documentation


Request Headers

Protected routes require:

Authorization: Bearer <API_KEY>

or

x-api-key: <API_KEY>

Example Request

Create Shipment

POST /shipments
Content-Type: application/json

{
  "sender": {
    "name": "John",
    "address": "City A"
  },
  "receiver": {
    "name": "Doe",
    "address": "City B"
  }
}

Environment Variables

Variable Description
PORT Server port
MONGO_URI MongoDB connection string
JWT_SECRET Secret key for JWT authentication
REDIS_URL Redis connection string

Testing

  • All endpoints tested using Postman
  • Postman collection included in the repository

Deployment

🚀 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

Limitations

  • No real GPS tracking integration
  • Notifications limited to webhook-based system
  • No frontend interface included

Future Improvements

  • Email and SMS notifications
  • Delivery agent module
  • Advanced analytics dashboard
  • Billing and API usage monitoring

Author

Developed as a scalable backend system demonstrating real-world API design and logistics workflow management.

About

A scalable multi-tenant courier tracking API with authentication, API key management, real-time updates, caching, and webhook-based notifications.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors