# sonujha0210/freighttracker architecture

> Architecture diagram of the GitHub repository sonujha0210/freighttracker, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-26). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sonujha0210/freighttracker
- Repository: https://github.com/sonujha0210/freighttracker

## Overview

FreightTrack is a REST API for shipment lifecycle and tracking, with customer registration/login and role-protected operations. Clients send requests to API controllers; authentication and shipment services apply business logic, repositories persist or query data, and shipment responses include tracking history, filters, or CSV export. The graph reflects sampled controller, service, repository, and DbContext code, plus documented JWT/RBAC and exception handling. Other documented behavior, including the precise endpoint policies, is represented at subsystem level where source excerpts were unavailable.

Main entry points: [`FreightTrack.Application/Services/Implementation/ShipmentService.cs`](https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.Application/Services/Implementation/ShipmentService.cs) (Shipment Service), [`FreightTrack.API/Controllers/ShipmentsController.cs`](https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.API/Controllers/ShipmentsController.cs) (Shipment Routes), [`FreightTrack.Application/Services/Implementation/AuthService .cs`](https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.Application/Services/Implementation/AuthService%20.cs) (Auth Service), [`FreightTrack.API/JWTConffig/JwtConfiguration.cs`](https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.API/JWTConffig/JwtConfiguration.cs) (JWT Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_ship_controller["Shipment Routes"]
  node_auth_controller["Auth Routes<br/>[AuthController.cs]"]
  node_exception["Exception Handler"]
end

subgraph group_application["Application Services"]
  node_shipment_service["Shipment Service<br/>[ShipmentService.cs]"]
  node_auth_service["Auth Service<br/>[AuthService .cs]"]
  node_customer_service["Customer Service<br/>[CustomerService.cs]"]
end

subgraph group_persistence["Persistence and Domain"]
  node_shipment_repo["Shipment Repository"]
  node_customer_repo["Customer Repository"]
  node_dbcontext["EF DbContext"]
  node_domain_models["Shipment and Customer Models<br/>[Shipment.cs]"]
  node_tracking_model["Tracking Event Model<br/>[TrackingEvent.cs]"]
end

subgraph group_security["Security"]
  node_jwt_auth["JWT Authentication"]
  node_jwt_config["JWT Settings<br/>[appsettings.json]"]
end

node_client(("API Client"))
node_mysql[("MySQL Database")]

node_client -->|"sends requests"| node_ship_controller
node_client -->|"registers or logs in"| node_auth_controller
node_ship_controller -->|"calls"| node_shipment_service
node_shipment_service -->|"queries or changes"| node_shipment_repo
node_shipment_repo -->|"reads and writes"| node_dbcontext
node_dbcontext -->|"persists data"| node_mysql
node_shipment_service -->|"maps shipment data"| node_domain_models
node_shipment_service -->|"maps event data"| node_tracking_model
node_ship_controller -->|"requests CSV data"| node_shipment_service
node_auth_controller -->|"calls"| node_auth_service
node_auth_service -->|"looks up or saves"| node_customer_repo
node_customer_repo -->|"reads and writes"| node_dbcontext
node_auth_service -->|"reads signing settings"| node_jwt_config
node_jwt_auth -->|"reads validation settings"| node_jwt_config
node_client -->|"presents bearer token"| node_jwt_auth
node_jwt_auth -->|"authorizes requests"| node_ship_controller
node_exception -->|"handles request errors"| node_ship_controller
node_exception -->|"handles request errors"| node_auth_controller

click node_ship_controller "https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.API/Controllers/ShipmentsController.cs"
click node_auth_controller "https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.API/Controllers/AuthController.cs"
click node_exception "https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.API/Middleware/ExceptionMiddleware.cs.cs"
click node_shipment_service "https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.Application/Services/Implementation/ShipmentService.cs"
click node_auth_service "https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.Application/Services/Implementation/AuthService%20.cs"
click node_customer_service "https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.Application/Services/Implementation/CustomerService.cs"
click node_shipment_repo "https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.Infrastructure/Repositories/ShipmentRepository.cs"
click node_customer_repo "https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.Infrastructure/Repositories/CustomerRepository.cs"
click node_dbcontext "https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.Infrastructure/Data/FreightTrackDbContext.cs"
click node_domain_models "https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.Domain/Models/Shipment.cs"
click node_tracking_model "https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.Domain/Models/TrackingEvent.cs"
click node_jwt_auth "https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.API/JWTConffig/JwtConfiguration.cs"
click node_jwt_config "https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.API/appsettings.json"

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_ship_controller,node_auth_controller,node_exception,node_client toneBlue
class node_shipment_service,node_auth_service,node_customer_service,node_mysql toneAmber
class node_shipment_repo,node_customer_repo,node_dbcontext,node_domain_models,node_tracking_model toneMint
class node_jwt_auth,node_jwt_config toneRose
```

## Components

### HTTP API

- [Shipment Routes](https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.API/Controllers/ShipmentsController.cs): `FreightTrack.API/Controllers/ShipmentsController.cs`
- [Auth Routes](https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.API/Controllers/AuthController.cs): `FreightTrack.API/Controllers/AuthController.cs`
- [Exception Handler](https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.API/Middleware/ExceptionMiddleware.cs.cs): `FreightTrack.API/Middleware/ExceptionMiddleware.cs.cs`

### Application Services

- [Shipment Service](https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.Application/Services/Implementation/ShipmentService.cs): `FreightTrack.Application/Services/Implementation/ShipmentService.cs`
- [Auth Service](https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.Application/Services/Implementation/AuthService%20.cs): `FreightTrack.Application/Services/Implementation/AuthService .cs`
- [Customer Service](https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.Application/Services/Implementation/CustomerService.cs): `FreightTrack.Application/Services/Implementation/CustomerService.cs`

### Persistence and Domain

- [Shipment Repository](https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.Infrastructure/Repositories/ShipmentRepository.cs): `FreightTrack.Infrastructure/Repositories/ShipmentRepository.cs`
- [Customer Repository](https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.Infrastructure/Repositories/CustomerRepository.cs): `FreightTrack.Infrastructure/Repositories/CustomerRepository.cs`
- [EF DbContext](https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.Infrastructure/Data/FreightTrackDbContext.cs): `FreightTrack.Infrastructure/Data/FreightTrackDbContext.cs`
- [Shipment and Customer Models](https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.Domain/Models/Shipment.cs): `FreightTrack.Domain/Models/Shipment.cs`
- [Tracking Event Model](https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.Domain/Models/TrackingEvent.cs): `FreightTrack.Domain/Models/TrackingEvent.cs`

### Security

- [JWT Authentication](https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.API/JWTConffig/JwtConfiguration.cs): `FreightTrack.API/JWTConffig/JwtConfiguration.cs`
- [JWT Settings](https://github.com/sonujha0210/freighttracker/blob/main/FreightTrack.API/appsettings.json): `FreightTrack.API/appsettings.json`

### Other components

- **API Client**
- **MySQL Database**

## Connections

- API Client → Shipment Routes: sends requests
- API Client → Auth Routes: registers or logs in
- Shipment Routes → Shipment Service: calls
- Shipment Service → Shipment Repository: queries or changes
- Shipment Repository → EF DbContext: reads and writes
- EF DbContext → MySQL Database: persists data
- Shipment Service → Shipment and Customer Models: maps shipment data
- Shipment Service → Tracking Event Model: maps event data
- Shipment Routes → Shipment Service: requests CSV data
- Auth Routes → Auth Service: calls
- Auth Service → Customer Repository: looks up or saves
- Customer Repository → EF DbContext: reads and writes
- Auth Service → JWT Settings: reads signing settings
- JWT Authentication → JWT Settings: reads validation settings
- API Client → JWT Authentication: presents bearer token
- JWT Authentication → Shipment Routes: authorizes requests
- Exception Handler → Shipment Routes: handles request errors
- Exception Handler → Auth Routes: handles request errors
