How oshri134/delivery-management-service works
Project Type and Purpose
• This is a backend monolithic RESTful service called “Delivery Management Service.”
• Built in TypeScript + Node.js/Express, it handles user authentication, package creation, driver availability, delivery assignment, reporting, metrics, and forecasting.
File Structure
• Top-level: configuration files (.env, Dockerfile, docker-compose.yml), docs, scripts, source code under src, and tests.
• src/app.ts boots the Express server.
• src/config holds environment, Swagger and validation setup.
• src/routes ▶ controllers ▶ services ▶ repositories ▶ models form a classic layered architecture.
• src/database contains TypeORM/Sequelize config, migrations, and seeders.
• src/middleware provides cross-cutting concerns (auth, error handling, metrics).
• src/utils includes error definitions, logging, and response formatting.
• Ecosystem config, CI workflow, and Docker compose illustrate deployment readiness.
Key Insights from README
• Uses SQL Server (via Docker locally or RDS/Azure SQL in cloud).
• Optional Redis caching for sessions/fast data.
• JWT authentication, Sequelize ORM, Joi validation, Prometheus metrics, Swagger/OpenAPI docs.
• Layered service boundaries for Controllers (HTTP), Services (business logic), Repositories (data access).
• Dockerized for local dev; ECS/Fargate and Azure Container Instances for production.
a. Main Components
– API Gateway/HTTP Server (Express + middleware)
– Authentication Module (JWT, AuthController/AuthService)
– Business Logic Layer (DeliveryService, DriverService, PricingService, NotificationService, ForecastService)
– Data Access Layer (Sequelize ORM, Repositories for User, Package, Delivery, Driver, Address)
– Relational Database (SQL Server)
– Optional Cache (Redis)
– Observability: Prometheus metrics endpoint, SwaggerUI for API docs, Winston logging
– External Services: Secrets Manager (AWS Secrets Manager/Azure Key Vault), Container Registry, CI/CD pipeline
b. Relationships & Data Flows
– Client → HTTP Server → Router → Controller → Service → Repository → Database
– Authenticated requests validated by auth middleware before reaching controllers
– ServiceFactory to instantiate services with appropriate dependencies
– Database migrations/seeders executed via scripts for CI/CD
– Prometheus scraper pulls metrics from /metrics endpoint
– SwaggerUI exposed at /api-docs for API exploration
c. Architectural Patterns & Principles
– Layered (Clean) Architecture: separation of concerns across controllers/services/repositories/models
– Repository Pattern for decoupling business logic from ORM
– Middleware Chain for cross-cutting concerns (validation, security, error handling, metrics)
– Transactional Unit-of-Work for race-condition-safe driver assignment
– Dependency Injection via ServiceFactory and config modules
d. Major Technologies
– Node.js, Express, TypeScript
– Sequelize ORM targeting SQL Server
– Joi for request validation
– Redis for optional caching/session storage
– Docker & docker-compose for containerization
– Swagger/OpenAPI for API documentation
– Prometheus for metrics, Winston for structured logging
– GitHub Actions for CI, Amazon ECS/Azure Container Instances for CD