# wouterdedroog/updat3r architecture

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

- Interactive diagram: https://gitdiagram.com/wouterdedroog/updat3r
- Repository: https://github.com/wouterdedroog/updat3r

## Overview

##### Main Components

a. Client Layer:
- External clients consuming the API
- Web interface users (dashboard)

b. Application Layer:
- Authentication System
- Web Controllers
- API Controllers
- Two-Factor Authentication System
- Middleware Layer

c. Data Layer:
- Database (likely MySQL/PostgreSQL based on Laravel)
- Storage System (for update files)

##### Key Architectural Elements

- MVC Architecture (evident from Laravel structure)
- REST API Architecture (for update distribution)
- Multi-authentication system (Traditional + 2FA)

##### Detailed Component Breakdown

Frontend Components (Blue):
- Dashboard Interface
- Authentication Pages
- Profile Management
- Project Management
- Update Management

API Layer (Green):
- v2 API Endpoints
- Legacy API Support
- API Authorization Middleware
- Request Validation Layer

Core Services (Yellow):
- Update Management Service
- Project Management Service
- Two-Factor Authentication Service
- User Management Service

Data Storage (Purple):
- User Data Store
- Project Data Store
- Updates Store
- Two-Factor Methods Store
- File Storage System

##### Flow Representations

- Client API Requests → API Middleware → Controllers → Models → Database
- Web Interface → Controllers → Views
- Authentication Flows
- Update File Distribution Path

##### Security Layer Representation (Red)
- API Authorization Middleware
- Two-Factor Authentication
- CSRF Protection
- Authentication Middleware

##### Specific Implementation Details

Key components:
**API Endpoints:**
- GET /api/v2/updates/{project}/{amount}
- GET /api/v2/updates/download/{project}/{version}

**Authentication Methods:**
- Traditional Login
- Two-Factor Authentication (Multiple Methods)

**Database Tables:**
- users
- projects
- updates
- two_factor_methods

##### Data Layer

Left to Right:

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Clients
        WEB["Web Browser"]
        API["API Consumers"]
    end

    subgraph "Application Layer"
        direction TB
        subgraph "Frontend"
            DASH["Dashboard Interface"]:::frontend
            AUTH_PAGES["Authentication Pages"]:::frontend
            PROF["Profile Management"]:::frontend
            PROJ_UI["Project Management UI"]:::frontend
            UPD_UI["Update Management UI"]:::frontend
        end

        subgraph "API Endpoints"
            V2_API["V2 API Controller"]:::api
            LEG_API["Legacy API Controller"]:::api
            click V2_API "https://github.com/wouterdedroog/updat3r/blob/main/app/Http/Controllers/ApiController/ProjectController.php"
            click LEG_API "https://github.com/wouterdedroog/updat3r/blob/main/app/Http/Controllers/ApiController/LegacyProjectController.php"
        end

        subgraph "Security Layer"
            AUTH["Authentication System"]:::security
            TFA["Two-Factor Authentication"]:::security
            API_AUTH["API Authorization"]:::security
            CSRF["CSRF Protection"]:::security
            click AUTH "https://github.com/wouterdedroog/updat3r/tree/main/app/Http/Controllers/Auth/"
            click TFA "https://github.com/wouterdedroog/updat3r/blob/main/app/Http/Controllers/TwoFactorMethodController.php"
            click API_AUTH "https://github.com/wouterdedroog/updat3r/blob/main/app/Http/Middleware/CheckApiAuthorization.php"
        end

        subgraph "Core Controllers"
            PROJ_CTRL["Project Controller"]:::controller
            UPD_CTRL["Update Controller"]:::controller
            USER_CTRL["User Controller"]:::controller
            click PROJ_CTRL "https://github.com/wouterdedroog/updat3r/blob/main/app/Http/Controllers/ProjectController.php"
            click UPD_CTRL "https://github.com/wouterdedroog/updat3r/blob/main/app/Http/Controllers/UpdateController.php"
            click USER_CTRL "https://github.com/wouterdedroog/updat3r/blob/main/app/Http/Controllers/UserController.php"
        end

        subgraph "Request Validation"
            PROJ_VAL["Project Validation"]:::validation
            UPD_VAL["Update Validation"]:::validation
            TFA_VAL["2FA Validation"]:::validation
            click PROJ_VAL "https://github.com/wouterdedroog/updat3r/blob/main/app/Http/Requests/ProjectRequest.php"
            click UPD_VAL "https://github.com/wouterdedroog/updat3r/blob/main/app/Http/Requests/UpdateRequest.php"
            click TFA_VAL "https://github.com/wouterdedroog/updat3r/blob/main/app/Http/Requests/StoreTwoFactorMethodRequest.php"
        end
    end

    subgraph "Data Layer"
        direction TB
        subgraph "Models"
            PROJ_MOD["Project Model"]:::model
            UPD_MOD["Update Model"]:::model
            USER_MOD["User Model"]:::model
            TFA_MOD["TwoFactor Model"]:::model
            click PROJ_MOD "https://github.com/wouterdedroog/updat3r/blob/main/app/Models/Project.php"
            click UPD_MOD "https://github.com/wouterdedroog/updat3r/blob/main/app/Models/Update.php"
            click USER_MOD "https://github.com/wouterdedroog/updat3r/blob/main/app/Models/User.php"
            click TFA_MOD "https://github.com/wouterdedroog/updat3r/blob/main/app/Models/TwoFactorMethod.php"
        end

        subgraph "Storage"
            DB[(Database)]:::storage
            FILES[("File Storage")]:::storage
        end
    end

    %% Connections
    WEB --> AUTH_PAGES
    API --> API_AUTH
    
    AUTH_PAGES --> AUTH
    AUTH --> TFA
    
    API_AUTH --> V2_API & LEG_API
    
    V2_API & LEG_API --> PROJ_VAL & UPD_VAL
    
    DASH --> PROJ_UI & UPD_UI & PROF
    PROJ_UI --> PROJ_CTRL
    UPD_UI --> UPD_CTRL
    PROF --> USER_CTRL
    
    PROJ_CTRL & UPD_CTRL & USER_CTRL --> PROJ_MOD & UPD_MOD & USER_MOD & TFA_MOD
    
    PROJ_MOD & UPD_MOD & USER_MOD & TFA_MOD --> DB
    UPD_MOD --> FILES

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef api fill:#2ecc71,stroke:#27ae60,color:white
    classDef security fill:#e74c3c,stroke:#c0392b,color:white
    classDef controller fill:#f1c40f,stroke:#f39c12,color:white
    classDef validation fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef model fill:#9b59b6,stroke:#8e44ad,color:white
    classDef storage fill:#34495e,stroke:#2c3e50,color:white
```
