# malikhassaan513-jpg/fyp architecture

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

- Interactive diagram: https://gitdiagram.com/malikhassaan513-jpg/fyp
- Repository: https://github.com/malikhassaan513-jpg/fyp

## Overview

This is a FastAPI backend for an AI-assisted complaint and provider-booking service. The main customer journey is account access, Urdu complaint analysis and submission, location capture, provider matching and booking, OTP-verified completion, then rating. Admin, notification, and maintenance capabilities extend that journey. The excerpts and source index establish several router-to-service and service-to-service links; unsampled routes are retained as subsystems, but their internal calls are not inferred.

Main entry points: [`Backend/app/services/booking_service.py`](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/services/booking_service.py) (Booking Lifecycle), [`Backend/app/api/v1/router.py`](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/api/v1/router.py) (API Router), [`Backend/app/main.py`](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/main.py) (Application Entry), [`Backend/app/services/matching_service.py`](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/services/matching_service.py) (Provider Matching)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["HTTP API"]
  node_api_router["API Router<br/>[router.py]"]
  node_auth_api["Authentication API<br/>[auth.py]"]
  node_complaints_api["Complaints API<br/>[complaints.py]"]
  node_booking_api["Bookings API<br/>[bookings.py]"]
  node_providers_api["Providers API<br/>[providers.py]"]
  node_other_api["Other APIs"]
end

subgraph group_identity["Identity and Core"]
  node_app_entry["Application Entry<br/>[main.py]"]
  node_auth_service["Authentication Service<br/>[auth_service.py]"]
  node_security["Token Security<br/>[security.py]"]
  node_core_runtime["Core Runtime"]
  node_database[("Relational Database<br/>[database.py]")]
  node_account_models["Account Models<br/>[user.py]"]
end

subgraph group_complaints["Complaint Handling"]
  node_complaint_api_service["Complaint Service"]
  node_ml_service["Complaint Classification<br/>[ml_service.py]"]
  node_preprocess["Model Preprocessing<br/>[preprocess.py]"]
  node_complaint_model["Complaint Records<br/>[complaint.py]"]
end

subgraph group_fulfillment["Provider Fulfillment"]
  node_booking_service["Booking Lifecycle<br/>[booking_service.py]"]
  node_matching_service["Provider Matching"]
  node_provider_service["Provider Service"]
  node_provider_model["Provider Records<br/>[provider.py]"]
  node_service_requests["Service Requests<br/>[service_request.py]"]
  node_otp_service["Completion OTP<br/>[otp_service.py]"]
  node_ratings["Ratings<br/>[rating_service.py]"]
end

subgraph group_operations["Operations"]
  node_admin["Administration<br/>[admin_service.py]"]
  node_notifications["Notifications"]
  node_maintenance["Maintenance"]
end

node_customer(("Customer"))

node_customer -->|"uses API"| node_api_router
node_api_router -->|"registers"| node_auth_api
node_api_router -->|"registers"| node_complaints_api
node_api_router -->|"registers"| node_booking_api
node_api_router -->|"registers"| node_providers_api
node_api_router -->|"registers"| node_other_api
node_app_entry -->|"mounts"| node_api_router
node_app_entry -->|"initializes"| node_database
node_app_entry -->|"loads model"| node_ml_service
node_database -->|"reads settings"| node_core_runtime
node_auth_api -->|"delegates"| node_auth_service
node_auth_service -->|"uses tokens"| node_security
node_auth_service -->|"reads and writes"| node_account_models
node_complaints_api -->|"delegates"| node_complaint_api_service
node_complaint_api_service -->|"classifies text"| node_ml_service
node_ml_service -->|"reuses pipeline"| node_preprocess
node_complaint_api_service -->|"creates complaints"| node_complaint_model
node_booking_api -->|"delegates"| node_booking_service
node_providers_api -->|"delegates"| node_provider_service
node_providers_api -->|"delegates"| node_booking_service
node_booking_service -->|"ranks providers"| node_matching_service
node_booking_service -->|"uses provider logic"| node_provider_service
node_booking_service -->|"sends notices"| node_notifications
node_booking_service -->|"uses OTP"| node_otp_service
node_booking_service -->|"validates transitions"| node_core_runtime
node_matching_service -->|"filters providers"| node_provider_model
node_matching_service -->|"reads requests"| node_service_requests
node_otp_service -->|"dispatches notices"| node_notifications
node_otp_service -.->|"enables completion rating"| node_ratings
node_admin -->|"uses booking logic"| node_booking_service
node_admin -->|"uses matching"| node_matching_service
node_app_entry -->|"starts maintenance"| node_maintenance

click node_api_router "https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/api/v1/router.py"
click node_auth_api "https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/api/v1/auth.py"
click node_complaints_api "https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/api/v1/complaints.py"
click node_booking_api "https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/api/v1/bookings.py"
click node_providers_api "https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/api/v1/providers.py"
click node_other_api "https://github.com/malikhassaan513-jpg/fyp/tree/main/Backend/app/api/v1"
click node_app_entry "https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/main.py"
click node_auth_service "https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/services/auth_service.py"
click node_security "https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/core/security.py"
click node_core_runtime "https://github.com/malikhassaan513-jpg/fyp/tree/main/Backend/app/core"
click node_database "https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/core/database.py"
click node_account_models "https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/models/user.py"
click node_complaint_api_service "https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/services/complaint_service.py"
click node_ml_service "https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/services/ml_service.py"
click node_preprocess "https://github.com/malikhassaan513-jpg/fyp/blob/main/Model%20Training/preprocess.py"
click node_complaint_model "https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/models/complaint.py"
click node_booking_service "https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/services/booking_service.py"
click node_matching_service "https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/services/matching_service.py"
click node_provider_service "https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/services/provider_service.py"
click node_provider_model "https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/models/provider.py"
click node_service_requests "https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/models/service_request.py"
click node_otp_service "https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/services/otp_service.py"
click node_ratings "https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/services/rating_service.py"
click node_admin "https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/services/admin_service.py"
click node_notifications "https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/services/notification_service.py"
click node_maintenance "https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/services/maintenance_service.py"

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_api_router,node_auth_api,node_complaints_api,node_booking_api,node_providers_api,node_other_api toneBlue
class node_app_entry,node_auth_service,node_security,node_core_runtime,node_database,node_account_models toneAmber
class node_complaint_api_service,node_ml_service,node_preprocess,node_complaint_model toneMint
class node_booking_service,node_matching_service,node_provider_service,node_provider_model,node_service_requests,node_otp_service,node_ratings toneRose
class node_admin,node_notifications,node_maintenance,node_customer toneIndigo
```

## Components

### HTTP API

- [API Router](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/api/v1/router.py): `Backend/app/api/v1/router.py`
- [Authentication API](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/api/v1/auth.py): `Backend/app/api/v1/auth.py`
- [Complaints API](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/api/v1/complaints.py): `Backend/app/api/v1/complaints.py`
- [Bookings API](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/api/v1/bookings.py): `Backend/app/api/v1/bookings.py`
- [Providers API](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/api/v1/providers.py): `Backend/app/api/v1/providers.py`
- [Other APIs](https://github.com/malikhassaan513-jpg/fyp/tree/main/Backend/app/api/v1): `Backend/app/api/v1`

### Identity and Core

- [Application Entry](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/main.py): `Backend/app/main.py`
- [Authentication Service](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/services/auth_service.py): `Backend/app/services/auth_service.py`
- [Token Security](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/core/security.py): `Backend/app/core/security.py`
- [Core Runtime](https://github.com/malikhassaan513-jpg/fyp/tree/main/Backend/app/core): `Backend/app/core`
- [Relational Database](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/core/database.py): `Backend/app/core/database.py`
- [Account Models](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/models/user.py): `Backend/app/models/user.py`

### Complaint Handling

- [Complaint Service](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/services/complaint_service.py): `Backend/app/services/complaint_service.py`
- [Complaint Classification](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/services/ml_service.py): `Backend/app/services/ml_service.py`
- [Model Preprocessing](https://github.com/malikhassaan513-jpg/fyp/blob/main/Model%20Training/preprocess.py): `Model Training/preprocess.py`
- [Complaint Records](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/models/complaint.py): `Backend/app/models/complaint.py`

### Provider Fulfillment

- [Booking Lifecycle](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/services/booking_service.py): `Backend/app/services/booking_service.py`
- [Provider Matching](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/services/matching_service.py): `Backend/app/services/matching_service.py`
- [Provider Service](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/services/provider_service.py): `Backend/app/services/provider_service.py`
- [Provider Records](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/models/provider.py): `Backend/app/models/provider.py`
- [Service Requests](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/models/service_request.py): `Backend/app/models/service_request.py`
- [Completion OTP](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/services/otp_service.py): `Backend/app/services/otp_service.py`
- [Ratings](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/services/rating_service.py): `Backend/app/services/rating_service.py`

### Operations

- [Administration](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/services/admin_service.py): `Backend/app/services/admin_service.py`
- [Notifications](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/services/notification_service.py): `Backend/app/services/notification_service.py`
- [Maintenance](https://github.com/malikhassaan513-jpg/fyp/blob/main/Backend/app/services/maintenance_service.py): `Backend/app/services/maintenance_service.py`

### Other components

- **Customer**

## Connections

- Customer → API Router: uses API
- API Router → Authentication API: registers (evidence: `Backend/app/api/v1/router.py`)
- API Router → Complaints API: registers (evidence: `Backend/app/api/v1/router.py`)
- API Router → Bookings API: registers (evidence: `Backend/app/api/v1/router.py`)
- API Router → Providers API: registers (evidence: `Backend/app/api/v1/router.py`)
- API Router → Other APIs: registers (evidence: `Backend/app/api/v1/router.py`)
- Application Entry → API Router: mounts (evidence: `Backend/app/main.py`)
- Application Entry → Relational Database: initializes (evidence: `Backend/app/main.py`)
- Application Entry → Complaint Classification: loads model (evidence: `Backend/app/main.py`)
- Relational Database → Core Runtime: reads settings (evidence: `Backend/app/core/database.py`)
- Authentication API → Authentication Service: delegates (evidence: `Backend/app/api/v1/auth.py`)
- Authentication Service → Token Security: uses tokens (evidence: `Backend/app/services/auth_service.py`)
- Authentication Service → Account Models: reads and writes (evidence: `Backend/app/services/auth_service.py`)
- Complaints API → Complaint Service: delegates
- Complaint Service → Complaint Classification: classifies text (evidence: `Backend/app/services/complaint_service.py`)
- Complaint Classification → Model Preprocessing: reuses pipeline
- Complaint Service → Complaint Records: creates complaints (evidence: `Backend/app/services/complaint_service.py`)
- Bookings API → Booking Lifecycle: delegates (evidence: `Backend/app/api/v1/bookings.py`)
- Providers API → Provider Service: delegates (evidence: `Backend/app/api/v1/providers.py`)
- Providers API → Booking Lifecycle: delegates (evidence: `Backend/app/api/v1/providers.py`)
- Booking Lifecycle → Provider Matching: ranks providers (evidence: `Backend/app/services/booking_service.py`)
- Booking Lifecycle → Provider Service: uses provider logic (evidence: `Backend/app/services/booking_service.py`)
- Booking Lifecycle → Notifications: sends notices (evidence: `Backend/app/services/booking_service.py`)
- Booking Lifecycle → Completion OTP: uses OTP (evidence: `Backend/app/services/booking_service.py`)
- Booking Lifecycle → Core Runtime: validates transitions (evidence: `Backend/app/services/booking_service.py`)
- Provider Matching → Provider Records: filters providers (evidence: `Backend/app/services/matching_service.py`)
- Provider Matching → Service Requests: reads requests (evidence: `Backend/app/services/matching_service.py`)
- Completion OTP → Notifications: dispatches notices (evidence: `Backend/app/services/otp_service.py`)
- Completion OTP → Ratings: enables completion rating
- Administration → Booking Lifecycle: uses booking logic (evidence: `Backend/app/services/admin_service.py`)
- Administration → Provider Matching: uses matching (evidence: `Backend/app/services/admin_service.py`)
- Application Entry → Maintenance: starts maintenance (evidence: `Backend/app/main.py`)
