This is the backend repository for the Meridian fleet management and route optimization platform. It is built as a set of microservices on .NET 10.0 and ASP.NET Core Web API, with an API gateway in front.
The backend is organized into an API gateway and several microservices, following Domain-Driven Design principles. Paths below are relative to this folder (Meridian-Backend):
-
ApiGateway (
/src/ApiGateway)- Ocelot API gateway, HTTP entry point for the frontend (Port
5050) - Handles routing, CORS, and symmetric JWT validation (
MeridianBearer)
- Ocelot API gateway, HTTP entry point for the frontend (Port
-
UserService (
/src/UserService/UserService.API)- User registration, login, refresh tokens, and role management (Port
6007) - Issues JWTs that are validated by the gateway
- User registration, login, refresh tokens, and role management (Port
-
DeliveryService (
/src/DeliveryService/DeliveryService.API)- Delivery lifecycle and status tracking (Port
6001, gRPC7001)
- Delivery lifecycle and status tracking (Port
-
VehicleService (
/src/VehicleService/VehicleService.API)- Vehicle CRUD, capacity, and availability (Port
6002, gRPC7002)
- Vehicle CRUD, capacity, and availability (Port
-
DriverService (
/src/DriverService/DriverService.API)- Driver CRUD, availability, and working hours (Port
6003, gRPC7003)
- Driver CRUD, availability, and working hours (Port
-
AssignmentService (
/src/AssignmentService/AssignmentService.API)- Vehicle/driver assignment logic and recommendations (Port
6004, gRPC7004)
- Vehicle/driver assignment logic and recommendations (Port
-
RouteService (
/src/RouteService/RouteService.API)
- Route optimization, Google Maps Routes API integration, fuel cost estimation, Redis-backed route cache (Port
6005, gRPC7005) - HTTP endpoints (via the ApiGateway):
POST /api/routes/optimize– optimize a route and return the best option plus alternativesGET /api/routes/calculate– calculate distance, ETA, and polyline between origin and destinationGET /api/routes/alternatives– list alternative route options from Google Routes APIGET /api/routes/compare– compare alternative routes with distance, ETA, and fuel cost metricsGET /api/routes/rank– return ranked routes including fuel consumption (L), fuel cost (LKR), and duration (hours)
-
TrackingService (
/src/TrackingService/TrackingService.API)- Real-time GPS tracking via SignalR hub, location history (Port
6006)
- Real-time GPS tracking via SignalR hub, location history (Port
-
Architecture & Docs (
/docs)MERIDIAN_ARCHITECTURE_v2.md(authoritative architecture), API gateway notes, Azure deployment guide, and contribution guidelines
- Microservice scaffolding: Each service has pre-created folders and starter classes for
Controllers,Services,Repositories,Models, andDTOs. - API Gateway & Auth: Ocelot-based gateway with symmetric JWT auth (
MeridianBearer) and CORS configured for the frontend (http://localhost:3000). - gRPC for internal calls:
.protocontracts and gRPC clients/servers set up for inter-service communication (e.g., Assignment → Delivery/Vehicle/Driver, Route → Vehicle). - Database migrations: Each service uses DbUp with SQL scripts under its
Migrationsfolder, executed automatically on startup. - SQL Server & Redis: Local development uses Dockerized SQL Server and Redis. In Azure, the workflows create or update the core resources (resource group, SQL logical server, ACR, and Container Apps environment), while the service databases are created manually and Redis is provided by Redis Cloud.
- API documentation: Swagger/OpenAPI is enabled in development and can be enabled in QA with
Swagger__Enabled=true. Services expose Swagger directly on their local ports and through the gateway on routes such ashttp://localhost:5050/delivery/swagger. - Real-time tracking: A SignalR hub in
TrackingServiceexposes/hubs/trackingvia the gateway for live location updates.
-
Start the infrastructure (SQL Server, Redis)
Ensure Docker is running. From the root of the overall project (Meridian, one level above this folder), run:docker compose up -d
This starts SQL Server (
localhost:1433) and Redis (localhost:6379). -
Run the backend services
From this folder (Meridian-Backend), use separate terminals for each process:# API Gateway cd src/ApiGateway dotnet run # :5050 # Auth / Users cd src/UserService/UserService.API dotnet run # :6007 # Core domain services cd src/DeliveryService/DeliveryService.API dotnet run # :6001 cd src/VehicleService/VehicleService.API dotnet run # :6002 cd src/DriverService/DriverService.API dotnet run # :6003 cd src/AssignmentService/AssignmentService.API dotnet run # :6004 cd src/RouteService/RouteService.API dotnet run # :6005 cd src/TrackingService/TrackingService.API dotnet run # :6006
On first run, each service connects to SQL Server, creates its database, and applies DbUp migration scripts.
-
(Optional) Run the frontend
The Next.js frontend lives in the sibling foldermeridian-frontend:cd ../meridian-frontend npm install npm run dev # http://localhost:3000
The frontend talks to the API Gateway at
http://localhost:5050and usesws://localhost:5050/hubs/trackingfor real-time updates.
- Local direct service Swagger:
http://localhost:6001/swaggerhttp://localhost:6002/swaggerhttp://localhost:6003/swaggerhttp://localhost:6004/swaggerhttp://localhost:6005/swaggerhttp://localhost:6006/swaggerhttp://localhost:6007/swagger
- Local gateway Swagger proxies:
http://localhost:5050/delivery/swaggerhttp://localhost:5050/vehicle/swaggerhttp://localhost:5050/driver/swaggerhttp://localhost:5050/assignment/swaggerhttp://localhost:5050/route/swaggerhttp://localhost:5050/tracking/swaggerhttp://localhost:5050/user/swagger
- In Azure Container Apps, all containers listen internally on
8080, but the public entry point remains the API Gateway FQDN. - QA, staging, and PROD deployments expect these SQL databases to already exist on their respective Azure SQL logical servers:
meridian_user,meridian_delivery,meridian_vehicle,meridian_driver,meridian_assignment,meridian_route,meridian_tracking. - QA and PROD deployments use Redis Cloud for RouteService cache configuration instead of Azure Cache for Redis.
High-level roadmap items (see docs/MERIDIAN_ARCHITECTURE_v2.md for full detail):
- Business logic implementation: Flesh out controllers, services, and repositories to match the architecture spec for each bounded context.
- Google Maps integration: Complete Directions/Distance Matrix usage in
RouteServicewith proper caching in Redis. - Real-time UX: Enhance the frontend’s live tracking and status updates using the existing SignalR hub.
- Testing & CI/CD: Add unit/integration test projects and GitHub Actions workflows to build, test, containerize, and deploy services to Azure.