# shellrean-dev/exo-cbt-service architecture

> Architecture diagram of the GitHub repository shellrean-dev/exo-cbt-service, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shellrean-dev/exo-cbt-service
- Repository: https://github.com/shellrean-dev/exo-cbt-service

## Overview

##### Main System Components
- Frontend/UI Layer:
- Public assets (under “public”) include stylesheets, images, installer assets, and the index.php file.
- Backend/API Layer:
- “app/Http/Controllers” contains multiple controllers organized by API version (v1, v2, v3) plus additional gateway and system controllers. This indicates RESTful endpoints for exam operations (auth, exam sessions, user management, exam content, etc.).
- “routes” directory holds the API routing definitions (api.php, api_v2.php, api_v3.php) as well as gateway and web routes, showing clear separation of API access.
- Business Logic & Service Layer:
- “app/Services” and “app/Repositories” directories encapsulate the core business logic (services for exam handling, backup, file processing, exam question handling [multiple types]) and data interactions.
- Other folders like “app/Actions”, “app/Console” and “app/Imports/Exports” indicate additional command-line utilities and import/export functionalities.
- Data / Persistence Layer:
- “database/migrations”, “database/seeds” and “database/factories” represent the database schema, data initialization, and test data creation.
- The “config/database.php” file shows the database configuration.
- Caching and External/Offline Capabilities:
- The “app/Cache” folder and configuration for caching show that caching is part of the design.
- The offline capability is hinted by the README and use of backup functions (see app/ExoBackup.php and BackupController).

##### Architectural Patterns and Relationships
- MVC and Layered Architecture: Controllers handle requests/responses, Services and Repositories process business logic and data access, while Models (in “app” and “app/Models”) represent the domain entities.
- API Versioning: Multiple API versions (v1, v2, v3) indicate an evolving interface for various clients or exam conditions, and gateway controllers further abstract interactions with certain systems.
- Separation of Concerns: Directories for imports, exports, cache handling, and scheduling (e.g., “app/SesiSchedule.php”) illustrate the adherence to modular design principles.
- Command & Background Processing: Console commands (in “app/Console/Commands/Exo”) are used for administrative and backend tasks like installations, repository creation, or service setup.

- Client Interface: Represent both web and potentially mobile exam interfaces drawing from Vue components and Blade templates.
- Caching & File Storage: Represent caching (app/Cache) and file storage (storage/app, public/download) as auxiliary components that support performance and offline capabilities.
- Requests moving from the front end to the API controllers.
- Controllers invoking services which in turn interact with repositories (data layer).
- Output or data being sent to the client.
- External interactions or administrative flows (console commands, backup processes).

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Frontend/UI Layer"
        FT1["Blade Templates"]:::frontend
        FT2["Vue Components"]:::frontend
        FT3["Public Assets"]:::frontend
    end

    subgraph "Backend/API Layer"
        API1["API Controllers"]:::backend
        ARC1["API Routes: api.php"]:::backend
        ARC2["API Routes: api_v2.php"]:::backend
        ARC3["API Routes: api_v3.php"]:::backend
        ARC4["API Routes: gateway.php"]:::backend
    end

    subgraph "Business Logic & Service Layer"
        BL1["Services"]:::services
        BL2["Repositories"]:::services
        BL3["Console Commands"]:::services
    end

    subgraph "Data / Persistence Layer"
        DB1["Migrations"]:::data
        DB2["Seeds"]:::data
        DB3["Factories"]:::data
        DB4["Database Config"]:::data
    end

    subgraph "Caching & Offline Capabilities"
        CO1["Cache Handler"]:::offline
        CO2["Backup Process"]:::offline
    end

    %% Connections from Frontend to Backend
    FT1 -->|"request"| API1
    FT2 -->|"request"| API1
    FT3 -->|"request"| API1

    %% Routing definitions forward to Controllers
    ARC1 -->|"routes"| API1
    ARC2 -->|"routes"| API1
    ARC3 -->|"routes"| API1
    ARC4 -->|"routes"| API1

    %% Controllers delegate to Business Logic
    API1 -->|"delegates"| BL1

    %% Business Logic interactions
    BL1 -->|"uses"| BL2
    BL3 -->|"triggers"| BL1

    %% Business Logic and Data interactions
    BL1 -->|"reads/writes"| DB1
    BL1 -->|"reads/writes"| DB2
    BL1 -->|"reads/writes"| DB3
    BL1 -->|"reads/writes"| DB4

    %% Business Logic uses caching and backup
    BL1 -->|"caches"| CO1
    BL1 -->|"backup"| CO2

    %% Response flow back to Frontend
    API1 -->|"responds"| FT1

    %% Click Events
    click FT1 "https://github.com/shellrean-dev/exo-cbt-service/tree/ristretto-pf/resources/views"
    click FT2 "https://github.com/shellrean-dev/exo-cbt-service/tree/ristretto-pf/resources/js"
    click FT3 "https://github.com/shellrean-dev/exo-cbt-service/tree/ristretto-pf/public"
    click API1 "https://github.com/shellrean-dev/exo-cbt-service/tree/ristretto-pf/app/Http/Controllers"
    click ARC1 "https://github.com/shellrean-dev/exo-cbt-service/blob/ristretto-pf/routes/api.php"
    click ARC2 "https://github.com/shellrean-dev/exo-cbt-service/blob/ristretto-pf/routes/api_v2.php"
    click ARC3 "https://github.com/shellrean-dev/exo-cbt-service/blob/ristretto-pf/routes/api_v3.php"
    click ARC4 "https://github.com/shellrean-dev/exo-cbt-service/blob/ristretto-pf/routes/gateway.php"
    click BL1 "https://github.com/shellrean-dev/exo-cbt-service/tree/ristretto-pf/app/Services"
    click BL2 "https://github.com/shellrean-dev/exo-cbt-service/tree/ristretto-pf/app/Repositories"
    click BL3 "https://github.com/shellrean-dev/exo-cbt-service/tree/ristretto-pf/app/Console/Commands/Exo"
    click DB1 "https://github.com/shellrean-dev/exo-cbt-service/tree/ristretto-pf/database/migrations"
    click DB2 "https://github.com/shellrean-dev/exo-cbt-service/tree/ristretto-pf/database/seeds"
    click DB3 "https://github.com/shellrean-dev/exo-cbt-service/tree/ristretto-pf/database/factories"
    click DB4 "https://github.com/shellrean-dev/exo-cbt-service/blob/ristretto-pf/config/database.php"
    click CO1 "https://github.com/shellrean-dev/exo-cbt-service/tree/ristretto-pf/app/Cache"
    click CO2 "https://github.com/shellrean-dev/exo-cbt-service/blob/ristretto-pf/app/ExoBackup.php"

    %% Styles
    classDef frontend fill:#b3d9ff,stroke:#1f78b4,stroke-width:2px;
    classDef backend fill:#ffcc99,stroke:#d35400,stroke-width:2px;
    classDef services fill:#d5e8d4,stroke:#82b366,stroke-width:2px;
    classDef data fill:#f8cecc,stroke:#b85450,stroke-width:2px;
    classDef offline fill:#f5f5a2,stroke:#a3a375,stroke-width:2px;
```
