# andrew-2609/final-college-project architecture

> Architecture diagram of the GitHub repository andrew-2609/final-college-project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/andrew-2609/final-college-project
- Repository: https://github.com/andrew-2609/final-college-project

## Overview

##### Project type and purpose
- This is a Rust-based backend service implementing a scheduling system (SGHSS).
- It exposes a RESTful HTTP API for managing patients, appointments, and admin users.
- Follows a Clean/Hexagonal architecture: clearly separated Presentation, Application, Domain, and Infrastructure layers.

##### File structure
- Top-level: Cargo.toml, migrations folder (Diesel/Postgres DDL scripts), README.md.
- src/main.rs + src/infrastructure/web.rs: HTTP server bootstrap (likely using Actix‐Web or similar).
- src/presentation: DTOs, request extractors, HTTP handlers, route definitions.
- src/application: Use case implementations (business logic), error types, JWT security service.
- src/domain: Core entities (Patient, Appointment, Admin), value objects, repository interfaces, domain errors.
- src/infrastructure: Postgres connection (Diesel), concrete repository implementations.

##### README for additional insights
- Only the project title is provided, but the file structure makes clear this is an educational full-stack backend project using Clean Architecture and Postgres.

##### Detailed breakdown of components
- Client (UI, Postman, etc.)
- Presentation
- Routes (admin_routes.rs, appointment_routes.rs, patient_routes.rs)
- Handlers (admin_handler.rs, …)
- DTOs & Extractors (patient_dto.rs, jwt_extractor.rs)
- Application
- Use Cases (book_appointment.rs, login.rs, etc.)
- JWT Security Service (jwt.rs)
- Application Errors
- Domain
- Entities (Patient, Appointment, Admin)
- Value Objects (ID)
- Repository Traits (admin_repository.rs, …)
- Domain Errors
- Infrastructure
- DB Connection (connection.rs)
- Diesel Migrations
- Postgres Repos (postgres_patient_repository.rs, etc.)
- Web Server Bootstrap (web.rs, main.rs)
- External Database (PostgreSQL)

## Diagram (Mermaid)

```mermaid
graph TB
    Client["Client"]:::external

    subgraph "Presentation Layer"
        Routes["Routes\n(admin, appointment, patient)"]:::presentation
        Handlers["Handlers\n(admin, appointment, patient)"]:::presentation
        DTOs["DTOs & Extractors"]:::presentation
    end

    subgraph "Application Layer"
        UseCases["Use Cases"]:::application
        AppErrors["Application Errors"]:::application
        JWTService["JWT Security Service"]:::application
    end

    subgraph "Domain Layer"
        Entities["Entities"]:::domain
        ValueObjects["Value Objects"]:::domain
        RepoInterfaces["Repository Interfaces"]:::domain
        DomainErrors["Domain Errors"]:::domain
    end

    subgraph "Infrastructure Layer"
        WebServer["HTTP Server Bootstrap"]:::infrastructure
        DBConn["DB Connection"]:::infrastructure
        Migrations["Migrations & Schema"]:::infrastructure
        Repos["Postgres Repository Implementations"]:::infrastructure
    end

    ExternalDB["PostgreSQL Database"]:::external

    %% Data Flow
    Client -->|HTTP Request| Routes
    Routes -->|calls| Handlers
    Handlers -->|invokes| UseCases
    UseCases -->|uses entities| Entities
    UseCases -->|calls repo interface| RepoInterfaces
    RepoInterfaces -- implements by --> Repos
    UseCases -->|uses| JWTService
    Repos -->|connects via Diesel| DBConn
    Migrations -->|defines schema| DBConn
    DBConn -->|executes SQL| ExternalDB
    WebServer -->|hosts| Routes

    %% Click Events
    click Routes "https://github.com/andrew-2609/final-college-project/blob/main/src/presentation/routes/mod.rs"
    click Handlers "https://github.com/andrew-2609/final-college-project/blob/main/src/presentation/handlers/mod.rs"
    click DTOs "https://github.com/andrew-2609/final-college-project/blob/main/src/presentation/dtos/mod.rs"
    click UseCases "https://github.com/andrew-2609/final-college-project/blob/main/src/application/use_cases/mod.rs"
    click AppErrors "https://github.com/andrew-2609/final-college-project/blob/main/src/application/errors/mod.rs"
    click JWTService "https://github.com/andrew-2609/final-college-project/blob/main/src/application/security/jwt/mod.rs"
    click Entities "https://github.com/andrew-2609/final-college-project/blob/main/src/domain/entities/mod.rs"
    click ValueObjects "https://github.com/andrew-2609/final-college-project/blob/main/src/domain/value_objects/mod.rs"
    click RepoInterfaces "https://github.com/andrew-2609/final-college-project/blob/main/src/domain/repositories/mod.rs"
    click DomainErrors "https://github.com/andrew-2609/final-college-project/blob/main/src/domain/errors/mod.rs"
    click WebServer "https://github.com/andrew-2609/final-college-project/blob/main/src/infrastructure/web.rs"
    click DBConn "https://github.com/andrew-2609/final-college-project/blob/main/src/infrastructure/db/connection.rs"
    click Migrations "https://github.com/andrew-2609/final-college-project/tree/main/migrations/"
    click Repos "https://github.com/andrew-2609/final-college-project/blob/main/src/infrastructure/repositories/mod.rs"

    %% Styles
    classDef presentation fill:#dae8fc,stroke:#6c8ebf,color:#274e75
    classDef application fill:#d5e8d4,stroke:#82b366,color:#274e13
    classDef domain fill:#ffe6cc,stroke:#d79b00,color:#663c00
    classDef infrastructure fill:#f2f2f2,stroke:#999999,color:#333333
    classDef external fill:#ffffff,stroke:#000000,color:#000000,stroke-width:2px
```
