How ahmad-alhafne/public-transport-launch-center-management-system-senior-2 works
Purpose and entry points
Departure Center System is a .NET 8 microservice platform for managing departure trips, users, vehicles, routes, bookings, auditing, payments, complaints, notifications, queues, and live tracking. The React/Vite client starts at frontend/src/main.jsx and routes from frontend/src/App.jsx. Backend HTTP composition begins in each service’s Program.cs; the administrative aggregation boundary is backend/ApiGateway/ApiGateway/Program.cs.
Service architecture and persistence
Most domain services follow layered API → Application → Domain → Infrastructure boundaries, with controllers delegating to application services and EF Core repositories persisting service-owned data. Representative paths:
• Trip lifecycle: backend/TripService/TripService.Api/Controllers/TripController.cs, backend/TripService/TripService.Application/Services/TripManagementService.cs, backend/TripService/TripService.Infrastructure/Data/TripDbContext.cs
• Identity and JWT issuance: backend/AuthService/AuthService.Api/Controllers/AuthController.cs, backend/AuthService/AuthService.Infrastructure/Authentication/JwtProvider.cs, backend/AuthService/AuthService.Infrastructure/Data/AuthDbContext.cs
• Booking state: backend/BookingService/BookingService.Application/Services/BookingManagementService.cs, backend/BookingService/BookingService.Infrastructure/Data/BookingDbContext.cs
SQL Server is the stated persistence runtime, accessed through EF Core DbContexts and per-service migrations.
Core operational domains
TripService is the operational hub: it manages trips, driver profiles/change requests, emergencies, and calls Auth, Booking, Route, and Vehicle services through infrastructure clients (backend/TripService/TripService.Infrastructure/Clients/). RouteService and VehicleService own route and vehicle records; BookingService owns reservation and seat-management behavior. Payment is isolated behind command/query handlers and a Stripe gateway:
backend/PaymentService/PaymentService.Api/Controllers/PaymentsController.cs,
backend/PaymentService/PaymentService.Infrastructure/Services/StripePaymentGateway.cs.
AuditService validates QR-related booking/trip information and records audit outcomes:
backend/AuditService/AuditService.Api/Controllers/AuditController.cs,
backend/AuditService/AuditService.Application/Services/AuditService.cs.
Synchronous request flow
Browser requests use the frontend API layer at frontend/src/services/api.js, typically reach the API Gateway or individual APIs, then controllers invoke application services. Cross-service dependencies are explicit HTTP-client interfaces rather than shared databases—for example BookingService calls Trip and Payment clients, while TripService calls Auth, Booking, Route, and Vehicle clients. The gateway’s admin-trip aggregation endpoint is backend/ApiGateway/ApiGateway/Controllers/AdminTripDetailsController.cs.
Authentication state and route authorization are client-side concerns in frontend/src/context/AuthContext.jsx and frontend/src/components/ProtectedRoute.jsx; authorization tokens are issued by AuthService.
Asynchronous notifications and events
RabbitMQ is the event boundary for payment, trip, complaint, tracking, audit, and notification workflows. Payment publishes successful/refunded events; NotificationService consumes integration events, stores notifications/preferences, and sends through configured channels:
backend/NotificationService/NotificationService.Api/Handlers/NotificationIntegrationEventHandler.cs,
backend/NotificationService/NotificationService.Api/Messaging/RabbitMqEventConsumerHostedService.cs,
backend/NotificationService/NotificationService.Application/Services/NotificationManagementService.cs.
Notification delivery supports Expo push, FCM, and in-app delivery via backend/NotificationService/NotificationService.Api/Channels/. Background workers handle reminders and push receipts.
Real-time tracking and client updates
LiveTrackingService accepts driver/client tracking operations, persists live/history records, synchronizes trip status, publishes RabbitMQ events, and exposes SignalR:
backend/LiveTrackingService/LiveTrackingService.Api/Controllers/DriverTrackingController.cs,
backend/LiveTrackingService/LiveTrackingService.Api/Hubs/LiveTrackingHub.cs,
backend/LiveTrackingService/LiveTrackingService.Api/HostedServices/TripStatusSyncService.cs.
The frontend consumes SignalR through frontend/src/services/signalr.js and uses driver tracking hooks at frontend/src/hooks/useDriverTracking.js. Notification real-time updates similarly use backend/NotificationService/NotificationService.Api/Hubs/NotificationHub.cs.
Deployment/runtime boundary
docker-compose.yml orchestrates the local full stack; service images are defined by per-service Dockerfiles and backend/Dockerfile.base. The frontend is containerized by frontend/Dockerfile and served through frontend/nginx.conf. Material external services are SQL Server, RabbitMQ, Stripe, Expo Push, and FCM. Service configuration and endpoint/connection settings reside in service appsettings.json files and frontend/src/config.js.
Main entry points: api.js HTTP API layer · TripManagementService.cs Trip management · BookingManagementService.cs Booking management · PaymentsController.cs Payments API
Components 21
Web Client
- React application
frontend/src/main.jsx - HTTP API layer
frontend/src/services/api.js - SignalR tracking client
frontend/src/services/signalr.js
API Edge
- Admin API gateway · Aggregates administrative trip details.
backend/ApiGateway/ApiGateway/Controllers/AdminTripDetailsController.cs - Auth & JWT service
backend/AuthService/AuthService.Api/Controllers/AuthController.cs - Auth data context
backend/AuthService/AuthService.Infrastructure/Data/AuthDbContext.cs
Operational Services
- Trip API
backend/TripService/TripService.Api/Controllers/TripController.cs - Trip management · Manages trips, drivers, changes, and emergencies.
backend/TripService/TripService.Application/Services/TripManagementService.cs - Trip data context
backend/TripService/TripService.Infrastructure/Data/TripDbContext.cs - Booking management · Owns reservations and seat state.
backend/BookingService/BookingService.Application/Services/BookingManagementService.cs - Booking data context
backend/BookingService/BookingService.Infrastructure/Data/BookingDbContext.cs - Route & vehicle services · Own route and vehicle records.
- Payments API
backend/PaymentService/PaymentService.Api/Controllers/PaymentsController.cs - Stripe gateway
backend/PaymentService/PaymentService.Infrastructure/Services/StripePaymentGateway.cs - Audit service · Validates QR booking and trip information.
backend/AuditService/AuditService.Application/Services/AuditService.cs
Events & Realtime
- Live tracking API · Persists tracking and synchronizes trip status.
backend/LiveTrackingService/LiveTrackingService.Api/Controllers/DriverTrackingController.cs - Live tracking hub
backend/LiveTrackingService/LiveTrackingService.Api/Hubs/LiveTrackingHub.cs - RabbitMQ · Integration-event boundary between services.
- Notification processor · Consumes events and stores notification preferences.
backend/NotificationService/NotificationService.Api/Handlers/NotificationIntegrationEventHandler.cs - Notification delivery hub · Delivers in-app, push, and realtime updates.
backend/NotificationService/NotificationService.Api/Hubs/NotificationHub.cs
External Runtime
- SQL Server · Hosts isolated service-owned schemas.
Connections 29
- React application → HTTP API layer: HTTP requests
- React application → SignalR tracking client: live updates
- HTTP API layer → Admin API gateway: admin requests
- HTTP API layer → Auth & JWT service: authenticate
- HTTP API layer → Trip API: trip operations
- HTTP API layer → Booking management: bookings
- HTTP API layer → Payments API: payments
- Admin API gateway → Trip API: trip aggregation
- Trip API → Trip management: delegates
- Trip management → Trip data context: persists
- Trip management → Auth & JWT service: identity client
- Trip management → Booking management: booking client
- Trip management → Route & vehicle services: route/vehicle clients
- Booking management → Booking data context: persists
- Booking management → Trip API: trip client
- Booking management → Payments API: payment client
- Payments API → Stripe gateway: charges and refunds
- Payments API → RabbitMQ: payment events
- Audit service → RabbitMQ: audit events
- Live tracking API → Trip management: sync trip status
- Live tracking API → Live tracking hub: broadcast locations
- Live tracking API → RabbitMQ: tracking events
- SignalR tracking client → Live tracking hub: SignalR
- RabbitMQ → Notification processor: integration events
- Notification processor → Notification delivery hub: send notifications
- SignalR tracking client → Notification delivery hub: notification updates
- Auth data context → SQL Server: EF Core
- Trip data context → SQL Server: EF Core
- Booking data context → SQL Server: EF Core