# ahmad-alhafne/public-transport-launch-center-management-system-senior-2 architecture

> Architecture diagram of the GitHub repository ahmad-alhafne/public-transport-launch-center-management-system-senior-2, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2
- Repository: https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2

## Overview

#### 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: [`frontend/src/services/api.js`](https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/frontend/src/services/api.js) (HTTP API layer), [`backend/TripService/TripService.Application/Services/TripManagementService.cs`](https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/TripService/TripService.Application/Services/TripManagementService.cs) (Trip management), [`backend/BookingService/BookingService.Application/Services/BookingManagementService.cs`](https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/BookingService/BookingService.Application/Services/BookingManagementService.cs) (Booking management), [`backend/PaymentService/PaymentService.Api/Controllers/PaymentsController.cs`](https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/PaymentService/PaymentService.Api/Controllers/PaymentsController.cs) (Payments API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web Client"]
  node_web_app["React application<br/>frontend<br/>[main.jsx]"]
  node_frontend_api["HTTP API layer<br/>frontend service<br/>[api.js]"]
  node_frontend_realtime["SignalR tracking client<br/>frontend realtime<br/>[signalr.js]"]
end

subgraph group_edge["API Edge"]
  node_gateway{{"Admin API gateway"}}
  node_auth["Auth &amp; JWT service<br/>identity API<br/>[AuthController.cs]"]
  node_auth_store[("Auth data context<br/>EF Core context<br/>[AuthDbContext.cs]")]
end

subgraph group_operations["Operational Services"]
  node_trip_api["Trip API<br/>[TripController.cs]"]
  node_trip_management["Trip management<br/>application service"]
  node_trip_store[("Trip data context<br/>EF Core context<br/>[TripDbContext.cs]")]
  node_booking["Booking management<br/>application service"]
  node_booking_store[("Booking data context<br/>EF Core context")]
  node_route_vehicle["Route &amp; vehicle services<br/>domain APIs"]
  node_payment["Payments API<br/>payment API"]
  node_stripe_gateway["Stripe gateway<br/>payment integration"]
  node_audit["Audit service<br/>audit API<br/>[AuditService.cs]"]
end

subgraph group_events["Events &amp; Realtime"]
  node_tracking_api["Live tracking API"]
  node_tracking_hub["Live tracking hub<br/>SignalR hub<br/>[LiveTrackingHub.cs]"]
  node_rabbitmq["RabbitMQ<br/>event bus"]
  node_notifications["Notification processor<br/>event consumer"]
  node_notification_delivery["Notification delivery hub<br/>channels &amp; SignalR<br/>[NotificationHub.cs]"]
end

subgraph group_platform["External Runtime"]
  node_sql_server[("SQL Server<br/>database runtime")]
end

node_web_app -->|"HTTP requests"| node_frontend_api
node_web_app -->|"live updates"| node_frontend_realtime
node_frontend_api -->|"admin requests"| node_gateway
node_frontend_api -->|"authenticate"| node_auth
node_frontend_api -->|"trip operations"| node_trip_api
node_frontend_api -->|"bookings"| node_booking
node_frontend_api -->|"payments"| node_payment
node_gateway -->|"trip aggregation"| node_trip_api
node_trip_api -->|"delegates"| node_trip_management
node_trip_management -->|"persists"| node_trip_store
node_trip_management -->|"identity client"| node_auth
node_trip_management -->|"booking client"| node_booking
node_trip_management -->|"route/vehicle clients"| node_route_vehicle
node_booking -->|"persists"| node_booking_store
node_booking -->|"trip client"| node_trip_api
node_booking -->|"payment client"| node_payment
node_payment -->|"charges and refunds"| node_stripe_gateway
node_payment -->|"payment events"| node_rabbitmq
node_audit -->|"audit events"| node_rabbitmq
node_tracking_api -->|"sync trip status"| node_trip_management
node_tracking_api -->|"broadcast locations"| node_tracking_hub
node_tracking_api -->|"tracking events"| node_rabbitmq
node_frontend_realtime -->|"SignalR"| node_tracking_hub
node_rabbitmq -->|"integration events"| node_notifications
node_notifications -->|"send notifications"| node_notification_delivery
node_frontend_realtime -->|"notification updates"| node_notification_delivery
node_auth_store -->|"EF Core"| node_sql_server
node_trip_store -->|"EF Core"| node_sql_server
node_booking_store -->|"EF Core"| node_sql_server

click node_web_app "https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/frontend/src/main.jsx"
click node_frontend_api "https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/frontend/src/services/api.js"
click node_frontend_realtime "https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/frontend/src/services/signalr.js"
click node_gateway "https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/ApiGateway/ApiGateway/Controllers/AdminTripDetailsController.cs"
click node_auth "https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/AuthService/AuthService.Api/Controllers/AuthController.cs"
click node_auth_store "https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/AuthService/AuthService.Infrastructure/Data/AuthDbContext.cs"
click node_trip_api "https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/TripService/TripService.Api/Controllers/TripController.cs"
click node_trip_management "https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/TripService/TripService.Application/Services/TripManagementService.cs"
click node_trip_store "https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/TripService/TripService.Infrastructure/Data/TripDbContext.cs"
click node_booking "https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/BookingService/BookingService.Application/Services/BookingManagementService.cs"
click node_booking_store "https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/BookingService/BookingService.Infrastructure/Data/BookingDbContext.cs"
click node_payment "https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/PaymentService/PaymentService.Api/Controllers/PaymentsController.cs"
click node_stripe_gateway "https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/PaymentService/PaymentService.Infrastructure/Services/StripePaymentGateway.cs"
click node_audit "https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/AuditService/AuditService.Application/Services/AuditService.cs"
click node_tracking_api "https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/LiveTrackingService/LiveTrackingService.Api/Controllers/DriverTrackingController.cs"
click node_tracking_hub "https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/LiveTrackingService/LiveTrackingService.Api/Hubs/LiveTrackingHub.cs"
click node_notifications "https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/NotificationService/NotificationService.Api/Handlers/NotificationIntegrationEventHandler.cs"
click node_notification_delivery "https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/NotificationService/NotificationService.Api/Hubs/NotificationHub.cs"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web_app,node_frontend_api,node_frontend_realtime toneBlue
class node_gateway,node_auth,node_auth_store toneAmber
class node_trip_api,node_trip_management,node_trip_store,node_booking,node_booking_store,node_route_vehicle,node_payment,node_stripe_gateway,node_audit toneMint
class node_tracking_api,node_tracking_hub,node_rabbitmq,node_notifications,node_notification_delivery toneRose
class node_sql_server toneIndigo
```

## Components

### Web Client

- [React application](https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/frontend/src/main.jsx): frontend · `frontend/src/main.jsx`
- [HTTP API layer](https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/frontend/src/services/api.js): frontend service · `frontend/src/services/api.js`
- [SignalR tracking client](https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/frontend/src/services/signalr.js): frontend realtime · `frontend/src/services/signalr.js`

### API Edge

- [Admin API gateway](https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/ApiGateway/ApiGateway/Controllers/AdminTripDetailsController.cs): gateway · Aggregates administrative trip details. · `backend/ApiGateway/ApiGateway/Controllers/AdminTripDetailsController.cs`
- [Auth & JWT service](https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/AuthService/AuthService.Api/Controllers/AuthController.cs): identity API · `backend/AuthService/AuthService.Api/Controllers/AuthController.cs`
- [Auth data context](https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/AuthService/AuthService.Infrastructure/Data/AuthDbContext.cs): EF Core context · `backend/AuthService/AuthService.Infrastructure/Data/AuthDbContext.cs`

### Operational Services

- [Trip API](https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/TripService/TripService.Api/Controllers/TripController.cs): trip API · `backend/TripService/TripService.Api/Controllers/TripController.cs`
- [Trip management](https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/TripService/TripService.Application/Services/TripManagementService.cs): application service · Manages trips, drivers, changes, and emergencies. · `backend/TripService/TripService.Application/Services/TripManagementService.cs`
- [Trip data context](https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/TripService/TripService.Infrastructure/Data/TripDbContext.cs): EF Core context · `backend/TripService/TripService.Infrastructure/Data/TripDbContext.cs`
- [Booking management](https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/BookingService/BookingService.Application/Services/BookingManagementService.cs): application service · Owns reservations and seat state. · `backend/BookingService/BookingService.Application/Services/BookingManagementService.cs`
- [Booking data context](https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/BookingService/BookingService.Infrastructure/Data/BookingDbContext.cs): EF Core context · `backend/BookingService/BookingService.Infrastructure/Data/BookingDbContext.cs`
- **Route & vehicle services**: domain APIs · Own route and vehicle records.
- [Payments API](https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/PaymentService/PaymentService.Api/Controllers/PaymentsController.cs): payment API · `backend/PaymentService/PaymentService.Api/Controllers/PaymentsController.cs`
- [Stripe gateway](https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/PaymentService/PaymentService.Infrastructure/Services/StripePaymentGateway.cs): payment integration · `backend/PaymentService/PaymentService.Infrastructure/Services/StripePaymentGateway.cs`
- [Audit service](https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/AuditService/AuditService.Application/Services/AuditService.cs): audit API · Validates QR booking and trip information. · `backend/AuditService/AuditService.Application/Services/AuditService.cs`

### Events & Realtime

- [Live tracking API](https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/LiveTrackingService/LiveTrackingService.Api/Controllers/DriverTrackingController.cs): tracking API · Persists tracking and synchronizes trip status. · `backend/LiveTrackingService/LiveTrackingService.Api/Controllers/DriverTrackingController.cs`
- [Live tracking hub](https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/LiveTrackingService/LiveTrackingService.Api/Hubs/LiveTrackingHub.cs): SignalR hub · `backend/LiveTrackingService/LiveTrackingService.Api/Hubs/LiveTrackingHub.cs`
- **RabbitMQ**: event bus · Integration-event boundary between services.
- [Notification processor](https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/NotificationService/NotificationService.Api/Handlers/NotificationIntegrationEventHandler.cs): event consumer · Consumes events and stores notification preferences. · `backend/NotificationService/NotificationService.Api/Handlers/NotificationIntegrationEventHandler.cs`
- [Notification delivery hub](https://github.com/ahmad-alhafne/public-transport-launch-center-management-system-senior-2/blob/main/backend/NotificationService/NotificationService.Api/Hubs/NotificationHub.cs): channels & SignalR · Delivers in-app, push, and realtime updates. · `backend/NotificationService/NotificationService.Api/Hubs/NotificationHub.cs`

### External Runtime

- **SQL Server**: database runtime · Hosts isolated service-owned schemas.

## Connections

- 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
