# captonseproject-spring2025/be_dotnetlaundryservice architecture

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

- Interactive diagram: https://gitdiagram.com/captonseproject-spring2025/be_dotnetlaundryservice
- Repository: https://github.com/captonseproject-spring2025/be_dotnetlaundryservice

## Overview

##### Project Type and Purpose
- This is a backend-only, full-stack service API (no bundled web frontend) for a laundry-service platform. It exposes REST endpoints (via ASP.NET Core), real-time hubs (SignalR), background jobs (Hangfire), and interfaces with external services (Firebase, Mapbox, SMS, payment gateway, OpenAI, file storage). Clients (mobile apps, admin dashboards) consume these APIs.

##### File Structure & Architectural Pattern
- Top‐Level Projects in the .sln:
- LaundryService.Api – ASP.NET Core Web API (Controllers, Middleware, Hubs, Dockerfile).
- LaundryService.Service – business logic / application services, background workers.
- LaundryService.Infrastructure – EF Core DbContext, Repository & UnitOf-Work, utilities, Hangfire config.
- LaundryService.Domain – domain entities, enums, constants, service interfaces (port definitions).
- LaundryService.Dto – data‐transfer objects (requests, responses, pagination).
- Patterns: Clean/Onion Architecture, Dependency Injection, Repository + Unit-Of-Work, layered separation, real-time messaging via SignalR, background scheduling via Hangfire.

##### Key Architectural Components
a. API Layer
- Controllers (e.g., OrderController, AuthController) expose HTTP endpoints.
- Middleware: global exception handler, authentication, Hangfire UI auth.
- SignalR Hubs: ChatHub, ComplaintHub, TrackingHub.
- Static file serving for uploads.
b. Application/Service Layer
- Implements domain service interfaces (IOrderService, IUserService, etc.).
- Orchestrates business rules and calls repositories and external‐service integrations.
- BackgroundServices (OrderAutoCompleteWorker, OrderJobService) for scheduled tasks.
c. Infrastructure Layer
- LaundryServiceDbContext: EF Core model for Persistence.
- Repository<T> + UnitOfWork: generic data access.
- HangfireConfig: configures background job storage and dashboard.
- Util: file uploads, Unit tests stubs.
d. Domain Layer
- Core Entities and Enums define data model (Order, User, Payment, etc.).
- Service interfaces define ports for business logic implementations.
e. External Services
- Firebase (push notifications, storage).
- Mapbox (geocoding, routing).
- SpeedSms (SMS OTP).
- PayOS or other Payment links.
- OpenAI (text/chat endpoints).
f. Data Store
- SQL Server (laundryservicedb.sql).
- Hangfire uses the same or dedicated storage.
g. Deployment
- Dockerfile under Api, docker-compose.yml in root.
- GitHub Actions (deploy.yml) for CI/CD.

##### Architectural Patterns & Principles
- Onion/Clean architecture: dependencies point inward to Domain.
- Single Responsibility per layer: Controllers only handle HTTP, Services only business, Infrastructure only data.
- Repository + UnitOfWork abstracts data store.
- DTOs for request/response separation.
- Real-time messaging decoupled via Hubs.
- Background scheduling for asynchronous tasks.
- Configuration & secrets externalized in appsettings.json and Docker secrets.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Clients
    subgraph "Clients"
        MobileApp["Mobile Apps"]
        AdminDashboard["Admin Dashboard"]
    end

    %% API Layer
    subgraph "API Layer"
        Controllers["Controllers"]:::api
        Middleware["Middleware"]:::api
        Hubs["SignalR Hubs"]:::api
        StaticFiles["Static File Serving"]:::api
        Program["Program.cs"]:::api
        Dockerfile["Dockerfile"]:::api
    end

    %% Service Layer
    subgraph "Service Layer"
        Services["Business Services"]:::service
        BackgroundWorkers["Background Workers"]:::service
    end

    %% Domain Layer
    subgraph "Domain Layer"
        Entities["Entities"]:::domain
        EnumsConstants["Enums & Constants"]:::domain
        Interfaces["Interfaces"]:::domain
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        DbContext["LaundryServiceDbContext"]:::infra
        Repo["Repository & UnitOfWork"]:::infra
        HangfireCfg["HangfireConfig"]:::infra
        Util["Util"]:::infra
    end

    %% DTO Layer
    subgraph "DTO Layer"
        Requests["Request Models"]:::dto
        Responses["Response Models"]:::dto
        Pagination["PaginationResult"]:::dto
    end

    %% External Services
    subgraph "External Services"
        Firebase["Firebase"]:::external
        Mapbox["Mapbox"]:::external
        SMS["SpeedSms"]:::external
        Payment["Payment Gateway"]:::external
        OpenAIExt["OpenAI"]:::external
    end

    %% Data Store
    subgraph "Data Store"
        SQLServer["SQL Server"]:::db
    end

    %% Deployment
    subgraph "Deployment"
        DockerCompose["Docker Compose"]:::deployment
        GitHubActions["GitHub Actions"]:::deployment
    end

    %% Connections
    MobileApp -->|HTTP/WebSocket| Middleware
    AdminDashboard -->|HTTP/WebSocket| Middleware
    Middleware --> Controllers
    Controllers --> Services
    Hubs --> Services
    Services --> Repo
    Repo --> DbContext
    DbContext --> SQLServer
    BackgroundWorkers --> Services
    Services --> Firebase
    Services --> Mapbox
    Services --> SMS
    Services --> Payment
    Controllers --> OpenAIExt
    MobileApp <-->|WebSocket| Hubs
    AdminDashboard <-->|WebSocket| Hubs
    MobileApp --> StaticFiles
    DockerCompose -.->|deploys| Controllers
    GitHubActions -.->|triggers| DockerCompose

    %% Click Events
    click Controllers "https://github.com/captonseproject-spring2025/be_dotnetlaundryservice/tree/main/LaundryService/LaundryService.Api/Controllers"
    click Middleware "https://github.com/captonseproject-spring2025/be_dotnetlaundryservice/tree/main/LaundryService/LaundryService.Api/Extensions"
    click Hubs "https://github.com/captonseproject-spring2025/be_dotnetlaundryservice/tree/main/LaundryService/LaundryService.Api/Hub"
    click StaticFiles "https://github.com/captonseproject-spring2025/be_dotnetlaundryservice/tree/main/LaundryService/LaundryService.Api/wwwroot/uploads"
    click Program "https://github.com/captonseproject-spring2025/be_dotnetlaundryservice/blob/main/LaundryService/LaundryService.Api/Program.cs"
    click Dockerfile "https://github.com/captonseproject-spring2025/be_dotnetlaundryservice/tree/main/LaundryService/LaundryService.Api/Dockerfile"
    click Services "https://github.com/captonseproject-spring2025/be_dotnetlaundryservice/blob/main/LaundryService/LaundryService.Service"
    click BackgroundWorkers "https://github.com/captonseproject-spring2025/be_dotnetlaundryservice/blob/main/LaundryService/LaundryService.Service/BackgroundServices/OrderAutoCompleteWorker.cs"
    click BackgroundWorkers "https://github.com/captonseproject-spring2025/be_dotnetlaundryservice/blob/main/LaundryService/LaundryService.Service/BackgroundServices/OrderJobService.cs"
    click DbContext "https://github.com/captonseproject-spring2025/be_dotnetlaundryservice/blob/main/LaundryService/LaundryService.Infrastructure/LaundryServiceDbContext.cs"
    click Repo "https://github.com/captonseproject-spring2025/be_dotnetlaundryservice/blob/main/LaundryService/LaundryService.Infrastructure/Repository.cs"
    click Repo "https://github.com/captonseproject-spring2025/be_dotnetlaundryservice/blob/main/LaundryService/LaundryService.Infrastructure/UnitOfWork.cs"
    click Repo "https://github.com/captonseproject-spring2025/be_dotnetlaundryservice/blob/main/LaundryService/LaundryService.Infrastructure/DbFactory.cs"
    click Repo "https://github.com/captonseproject-spring2025/be_dotnetlaundryservice/blob/main/LaundryService/LaundryService.Infrastructure/QueryableExtensions.cs"
    click HangfireCfg "https://github.com/captonseproject-spring2025/be_dotnetlaundryservice/blob/main/LaundryService/LaundryService.Infrastructure/HangfireConfig.cs"
    click Util "https://github.com/captonseproject-spring2025/be_dotnetlaundryservice/blob/main/LaundryService/LaundryService.Infrastructure/Util.cs"
    click Entities "https://github.com/captonseproject-spring2025/be_dotnetlaundryservice/tree/main/LaundryService/LaundryService.Domain/Entities"
    click EnumsConstants "https://github.com/captonseproject-spring2025/be_dotnetlaundryservice/tree/main/LaundryService/LaundryService.Domain/Enums"
    click EnumsConstants "https://github.com/captonseproject-spring2025/be_dotnetlaundryservice/tree/main/LaundryService/LaundryService.Domain/Constants"
    click Interfaces "https://github.com/captonseproject-spring2025/be_dotnetlaundryservice/tree/main/LaundryService/LaundryService.Domain/Interfaces"
    click Requests "https://github.com/captonseproject-spring2025/be_dotnetlaundryservice/tree/main/LaundryService/LaundryService.Dto/Requests"
    click Responses "https://github.com/captonseproject-spring2025/be_dotnetlaundryservice/tree/main/LaundryService/LaundryService.Dto/Responses"
    click Pagination "https://github.com/captonseproject-spring2025/be_dotnetlaundryservice/blob/main/LaundryService/LaundryService.Dto/Pagination/PaginationResult.cs"
    click DockerCompose "https://github.com/captonseproject-spring2025/be_dotnetlaundryservice/blob/main/LaundryService/docker-compose.yml"
    click GitHubActions "https://github.com/captonseproject-spring2025/be_dotnetlaundryservice/blob/main/.github/workflows/deploy.yml"

    %% Styles
    classDef api fill:#B3CDE0,stroke:#333,stroke-width:1px
    classDef service fill:#CCEBC5,stroke:#333,stroke-width:1px
    classDef domain fill:#FBB4AE,stroke:#333,stroke-width:1px
    classDef infra fill:#DECBE4,stroke:#333,stroke-width:1px
    classDef dto fill:#FED9A6,stroke:#333,stroke-width:1px
    classDef external fill:#FFFFCC,stroke:#333,stroke-width:1px
    classDef db fill:#80B1D3,stroke:#333,stroke-width:1px
    classDef deployment fill:#D9D9D9,stroke:#333,stroke-width:1px
```
