This system enables distribution companies to optimize their operations through microservices for managing users, orders, inventory, geolocation, and reports.
- Core: Node.js, Express.js
- Databases: PostgreSQL (for relational data) with Prisma ORM, and MongoDB (for geolocation data) with Mongoose.
- Containerization: Docker & Docker Compose.
- API Gateway: Custom implementation using
http-proxy-middleware. - CI/CD: GitHub Actions.
- Authentication: JWT (JSON Web Tokens) for securing endpoints.
- Notifications: Nodemailer (for emails) and Twilio (for SMS).
- API Documentation: Swagger (OpenAPI).
- File Handling: Multer for file uploads, with support for CSV and Excel.
The backend is designed using a microservices architecture, where each service is responsible for a specific domain. An API Gateway acts as a single entry point for all client requests.
├── api-gateway/
├── auth-service/
├── inventory-service/
├── orders-service/
├── geo-service/
├── reports-service/
├── docker-compose.yml
└── .env (local)
Each microservice is a standalone app with its own Dockerfile, package.json, and business logic.
- GitHub: api-gateway
- Description: Single entry point for all incoming requests. Routes traffic to the appropriate microservice and serves a status page.
- Base Path:
/ - Features:
- Reverse proxy for all other microservices.
- Serves a static status page (
/).
- Technologies:
express,cors,http-proxy-middleware.
- GitHub: auth-service
- Description: Manages user authentication, roles, and permissions.
- Base Path:
/auth - Features:
- User registration (
/signup) - Email verification and two-factor authentication (2FA) (
/verify-email,/verify-two-factor). - User login (
/signin) - Password management (reset, change).
- CRUD operations for Users, Roles, and Permissions.
- User registration (
- Technologies:
express,@prisma/client,bcrypt,jsonwebtoken,nodemailer,twilio,swagger-jsdoc.
- GitHub: inventory-service
- Description: Manages all inventory aspects, including products, categories, suppliers, and warehouses.
- Base Path:
/inventory - Features:
- CRUD for Products, Categories, Suppliers, and Warehouses.
- Manages stock levels and product movements between warehouses.
- Bulk data import from CSV/Excel files for products and warehouses.
- Technologies:
express,@prisma/client,axios,csv-parser,xlsx,multer,nodemailer.
- GitHub: orders-service
- Description: Handles the full order lifecycle from creation to delivery assignment.
- Base Path:
/orders - Features:
- CRUD operations for orders.
- Delivery staff management.
- Assigns available delivery personnel to new orders.
- Address geocoding using the Google Maps API.
- Technologies:
express,@prisma/client,@googlemaps/google-maps-services-js,axios,nodemailer.
- GitHub: geo-service
- Description: Manages real-time geolocation tracking for deliveries.
- Base Path:
/geo - Features:
- Saves and updates delivery staff locations.
- Provides endpoints for location history and finding nearby couriers.
- Real-time tracking via WebSockets.
- Technologies:
express,mongoose,socket.io,axios.
- GitHub: reports-service
- Description: Generates and serves reports based on data from other microservices.
- Base Path:
/reports - Features:
- Generates delivery reports in PDF and XLSX formats.
- Aggregates data from the
orders,inventory, andauthservices.
- Technologies:
express,pdfkit,exceljs,axios,moment.
- Docker
- Docker Compose
-
Clone the repository:
git clone https://github.com/Cruz1122/logistics-backend.git cd logistics-backend -
Set up environment variables: Create a
.envfile in the project root by copying.env.exampleand completing the required values. -
Build and run the services:
docker-compose up --build
This command builds the Docker images for each microservice and starts them. Services will be accessible through the API Gateway at
http://localhost:3000.