# fpt-uni-team/focs-be---cafeteria-ordering-system architecture

> Architecture diagram of the GitHub repository fpt-uni-team/focs-be---cafeteria-ordering-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-17). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/fpt-uni-team/focs-be---cafeteria-ordering-system
- Repository: https://github.com/fpt-uni-team/focs-be---cafeteria-ordering-system

## Overview

##### Project type and purpose
- This is a .NET-based, API-driven food-ordering and coupon management system with a “clean/onion” architecture.
- It exposes REST endpoints (FOCS project), implements business logic in a separate Application layer, persists data via multiple context-specific infrastructure projects (Identity, Order), provides real-time updates via SignalR (FOCS.Realtime.Hub), and background/messaging-based notifications (FOCS.NotificationService).

##### File structure
- Top-level solution (“FOCS.sln”) with multiple projects:
- FOCS – ASP.NET Web API (Controllers, Middleware, Program.cs)
- FOCS.Application – DTOs, service interfaces & implementations, background services
- FOCS.Common – shared constants, enums, models, interfaces, helpers
- FOCS.Infrastructure.Identity – Identity DB context, repositories, migrations, user models
- FOCS.Order.Infrastucture – Order DB context, entity models, migrations
- FOCS.Realtime.Hub – SignalR hubs for cart & order events
- FOCS.NotificationService – a worker process consuming messages and sending push notifications
- Deployment artifacts: Dockerfile, docker-compose.yml, GitHub Actions workflow

##### Elements
– Clear component labels (e.g., “FOCS Web API”, “Order DbContext”, “SignalR CartHub”)
- Layers (e.g., blue for API, green for Application, orange for Infrastructure)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    Client["Client (Web/Mobile/POS)"]:::external

    %% Presentation Layer
    subgraph "Presentation Layer"
        WebAPI["FOCS Web API"]:::api
        Controllers["Controllers"]:::api
        Middleware["ExceptionHandlingMiddleware"]:::api
        Program["Program Entry (Program.cs)"]:::api
        HTTPExamples["HTTP Examples (FOCS.http)"]:::api
    end

    %% Application Layer
    subgraph "Application Layer"
        Application["FOCS.Application"]:::app
        DTOs["DTOs"]:::app
        Services["Services"]:::app
        Background["Background Services"]:::app
        Mappings["Mapping Profiles"]:::app
    end

    %% Domain/Contracts Layer
    subgraph "Domain/Contracts Layer"
        Common["FOCS.Common"]:::common
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        subgraph "Identity Service"
            Identity["FOCS.Infrastructure.Identity"]:::infra
            IdentityDB["Identity DbContext"]:::infra
        end
        subgraph "Order Service"
            OrderInfra["FOCS.Order.Infrastucture"]:::infra
            OrderDB["Order DbContext"]:::infra
        end
        subgraph "Real-time Hub"
            Realtime["FOCS.Realtime.Hub"]:::infra
            CartHub["CartHub"]:::infra
            OrderHub["OrderHub"]:::infra
            NotifyHub["NotifyHub"]:::infra
        end
    end

    %% Notification Worker
    Notification["FOCS.NotificationService"]:::infra

    %% Messaging & External Services
    subgraph "Messaging & External Services"
        MessageBroker["Message Broker (Kafka/RabbitMQ)"]:::external
        Redis["Redis Cache"]:::external
        Cloudinary["Cloudinary Service"]:::external
        EmailSMS["Email/SMS Gateway"]:::external
        Payment["Payment Provider (PayOS/Momo)"]:::external
        Firebase["Firebase/FCM"]:::external
    end

    %% Deployment & CI/CD
    subgraph "Deployment & CI/CD"
        Dockerignore[".dockerignore"]:::external
        DockerfileAPI["API Dockerfile"]:::external
        DockerCompose["docker-compose.yml"]:::external
        Workflow["GitHub Actions Workflow"]:::external
    end

    %% Connections
    Client -->|REST calls| WebAPI
    WebAPI -->|uses| Controllers
    WebAPI -->|uses| Middleware
    WebAPI -->|entrypoint| Program
    WebAPI -->|example| HTTPExamples
    WebAPI -->|calls| Application
    Application -->|depends on| Common
    Application -->|read/write| IdentityDB
    Application -->|read/write| OrderDB
    Application -->|publish events| Realtime
    Application -->|enqueue messages| MessageBroker
    Application -->|calls| Cloudinary
    Application -->|calls| EmailSMS
    Application -->|calls| Payment
    Application -->|caches| Redis

    Realtime -->|real-time updates| Client
    MessageBroker -.->|consumed by| Notification
    Notification -->|push notifications| Firebase
    Notification -->|calls| EmailSMS

    %% CI/CD Connections
    Dockerignore -->|used by| DockerfileAPI
    DockerfileAPI -->|orchestrated by| DockerCompose
    DockerCompose -->|deployed via| Workflow

    %% Click Events
    click WebAPI "https://github.com/fpt-uni-team/focs-be---cafeteria-ordering-system/tree/main/SEP490-FOCS/FOCS"
    click Controllers "https://github.com/fpt-uni-team/focs-be---cafeteria-ordering-system/tree/main/SEP490-FOCS/FOCS/Controllers"
    click Middleware "https://github.com/fpt-uni-team/focs-be---cafeteria-ordering-system/blob/main/SEP490-FOCS/FOCS/Middlewares/ExceptionHandlingMiddleware.cs"
    click Program "https://github.com/fpt-uni-team/focs-be---cafeteria-ordering-system/blob/main/SEP490-FOCS/FOCS/Program.cs"
    click HTTPExamples "https://github.com/fpt-uni-team/focs-be---cafeteria-ordering-system/blob/main/SEP490-FOCS/FOCS/FOCS.http"
    click Application "https://github.com/fpt-uni-team/focs-be---cafeteria-ordering-system/blob/main/SEP490-FOCS/FOCS.Application"
    click DTOs "https://github.com/fpt-uni-team/focs-be---cafeteria-ordering-system/tree/main/SEP490-FOCS/FOCS.Application/DTOs"
    click Services "https://github.com/fpt-uni-team/focs-be---cafeteria-ordering-system/tree/main/SEP490-FOCS/FOCS.Application/Services"
    click Background "https://github.com/fpt-uni-team/focs-be---cafeteria-ordering-system/tree/main/SEP490-FOCS/FOCS.Application/Services/BackgroundServices"
    click Mappings "https://github.com/fpt-uni-team/focs-be---cafeteria-ordering-system/blob/main/SEP490-FOCS/FOCS.Application/Mappings/MappingProfiles.cs"
    click Common "https://github.com/fpt-uni-team/focs-be---cafeteria-ordering-system/blob/main/SEP490-FOCS/FOCS.Common"
    click Identity "https://github.com/fpt-uni-team/focs-be---cafeteria-ordering-system/blob/main/SEP490-FOCS/FOCS.Infrastructure.Identity"
    click IdentityDB "https://github.com/fpt-uni-team/focs-be---cafeteria-ordering-system/blob/main/SEP490-FOCS/FOCS.Infrastructure.Identity/Persistance/ApplicationDBContext.cs"
    click OrderInfra "https://github.com/fpt-uni-team/focs-be---cafeteria-ordering-system/blob/main/SEP490-FOCS/FOCS.Order.Infrastucture"
    click OrderDB "https://github.com/fpt-uni-team/focs-be---cafeteria-ordering-system/tree/main/SEP490-FOCS/FOCS.Order.Infrastucture/Context"
    click Realtime "https://github.com/fpt-uni-team/focs-be---cafeteria-ordering-system/blob/main/SEP490-FOCS/FOCS.Realtime.Hub"
    click Notification "https://github.com/fpt-uni-team/focs-be---cafeteria-ordering-system/blob/main/SEP490-FOCS/FOCS.NotificationService"
    click Dockerignore "https://github.com/fpt-uni-team/focs-be---cafeteria-ordering-system/blob/main/SEP490-FOCS/.dockerignore"
    click DockerfileAPI "https://github.com/fpt-uni-team/focs-be---cafeteria-ordering-system/blob/main/SEP490-FOCS/Dockerfile.txt"
    click DockerCompose "https://github.com/fpt-uni-team/focs-be---cafeteria-ordering-system/blob/main/SEP490-FOCS/docker-compose.yml"
    click Workflow "https://github.com/fpt-uni-team/focs-be---cafeteria-ordering-system/blob/main/SEP490-FOCS/.github/workflows/deploy.yml"

    %% Styles
    classDef api fill:#cce5ff,stroke:#004085,color:#004085;
    classDef app fill:#d4edda,stroke:#155724,color:#155724;
    classDef common fill:#fff3cd,stroke:#856404,color:#856404;
    classDef infra fill:#f8d7da,stroke:#721c24,color:#721c24;
    classDef external fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
```
