# skywors/tempora architecture

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

- Interactive diagram: https://gitdiagram.com/skywors/tempora
- Repository: https://github.com/skywors/tempora

## Overview

##### Project type and purpose
- This is a monolithic full-stack PHP web application (“Tempora”) following an MVC-style organization.
- It provides user account management (register, login, password reset), a dashboard UI, and a small JSON-based API endpoint for user data.

##### File structure
- public/ holds all static assets (images, CSS, JS) and the single entry point (index.php) for the web server.
- src/ contains the PHP application logic, subdivided into:
- Configs (routing configuration in routes.json)
- Controllers (web UI controllers under Accounts, Dashboard, Error, plus an API subtree)
- Models (Database connection, Entities, Repositories, Services)
- Utils & Factories (helper classes: routing, navbar, element building)
- Router.php (front-controller dispatch)
- views/ (template components and layouts)
- sql/database.sql defines the relational schema.
- composer.json/lock declares PHP dependencies; phpunit.xml and tests/ enable automated testing of the API and error flows.
- logs/ captures runtime logs.

##### README
- It shows minimal Apache2/Nginx VirtualHost configurations, confirming that all dynamic routing is funneled through public/index.php.
- No additional microservices or external data stores are mentioned besides a mail service for email notifications.

- Web server (green),
- PHP application layers (blue),
- Database (orange),
- External services (purple),
- Static assets (gray).
- Edge cases like error handling (ErrorController) and logging.

##### Detailed capture of essential components
- Don’t forget minor but important pieces: RouterFactory, NavbarFactory, Utils (Cookie, Lang, System), and the PHPUnit test harness.
- How public/scripts (engine.js, toolbar.js, theme.js) and public/styles feed into the client-side UI.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    Browser["Web Browser"]:::external
    Browser -->|"requests static assets"| StaticAssets
    Browser -->|"requests dynamic pages/API"| WebServer

    %% Static Assets
    StaticAssets["Static Assets\n(public/scripts, public/styles, public/images)"]:::static
    click StaticAssets "https://github.com/skywors/tempora/tree/main/public/scripts/"

    %% Web Server Entry
    WebServer["Web Server\n(Apache/Nginx)"]:::webserver
    WebServer -->|funnel to| IndexPHP

    %% Entry Point
    IndexPHP["public/index.php"]:::router
    click IndexPHP "https://github.com/skywors/tempora/blob/main/public/index.php"
    IndexPHP --> RouterFactory
    IndexPHP --> Router

    %% Router Factory & Front Controller
    RouterFactory["RouterFactory"]:::router
    click RouterFactory "https://github.com/skywors/tempora/blob/main/src/Factories/RouterFactory.php"
    Router["Router.php"]:::router
    click Router "https://github.com/skywors/tempora/blob/main/src/Router.php"
    RouterFactory --> Router
    Router --> Controllers

    %% Controllers Subgraph
    subgraph "Controllers" 
        direction TB
        AccountController["AccountController"]:::controller
        click AccountController "https://github.com/skywors/tempora/blob/main/src/Controllers/Accounts/AccountController.php"
        LoginController["LoginController"]:::controller
        click LoginController "https://github.com/skywors/tempora/blob/main/src/Controllers/Accounts/LoginController.php"
        RegisterController["RegisterController"]:::controller
        click RegisterController "https://github.com/skywors/tempora/blob/main/src/Controllers/Accounts/RegisterController.php"
        ResetController["ResetController"]:::controller
        click ResetController "https://github.com/skywors/tempora/blob/main/src/Controllers/Accounts/ResetController.php"
        DisconnectController["DisconnectController"]:::controller
        click DisconnectController "https://github.com/skywors/tempora/blob/main/src/Controllers/Accounts/DisconnectController.php"
        LoginResetController["LoginResetController"]:::controller
        click LoginResetController "https://github.com/skywors/tempora/blob/main/src/Controllers/Accounts/LoginResetController.php"
        DashboardController["DashboardController"]:::controller
        click DashboardController "https://github.com/skywors/tempora/blob/main/src/Controllers/Dashboard/DashboardController.php"
        ErrorController["ErrorController"]:::controller
        click ErrorController "https://github.com/skywors/tempora/blob/main/src/Controllers/ErrorController.php"
        IndexController["IndexController"]:::controller
        click IndexController "https://github.com/skywors/tempora/blob/main/src/Controllers/IndexController.php"

        %% API Controllers subgroup
        subgraph "API Controllers"
            direction TB
            GETController["GETController"]:::controller
            click GETController "https://github.com/skywors/tempora/blob/main/src/Controllers/API/GETController.php"
            GETUsersController["GETUsersController"]:::controller
            click GETUsersController "https://github.com/skywors/tempora/blob/main/src/Controllers/API/Users/GETUsersController.php"
        end
    end

    Controllers --> Services
    Controllers --> Views
    Controllers --> Logging

    %% Services Layer
    subgraph "Services"
        direction TB
        APIService["APIService"]:::service
        click APIService "https://github.com/skywors/tempora/blob/main/src/Models/Services/APIService.php"
        MailService["MailService"]:::service
        click MailService "https://github.com/skywors/tempora/blob/main/src/Models/Services/MailService.php"
        ErrorService["ErrorService"]:::service
        click ErrorService "https://github.com/skywors/tempora/blob/main/src/Models/Services/ErrorService.php"
    end
    Services --> Repositories
    MailService --> SMTP
    ErrorService --> Logging

    %% Repositories & Database
    subgraph "Repositories & Database"
        direction TB
        UserRepo["UserRepository"]:::repo
        click UserRepo "https://github.com/skywors/tempora/blob/main/src/Models/Repositories/UserRepository.php"
        ResetRepo["ResetPasswordRepository"]:::repo
        click ResetRepo "https://github.com/skywors/tempora/blob/main/src/Models/Repositories/ResetPasswordRepository.php"
        Database["Database\n(MySQL)"]:::db
        click Database "https://github.com/skywors/tempora/blob/main/sql/database.sql"
    end
    Repositories --> Database

    %% Utils & Factories
    subgraph "Utils & Factories"
        direction TB
        NavbarFactory["NavbarFactory"]:::util
        click NavbarFactory "https://github.com/skywors/tempora/blob/main/src/Factories/NavbarFactory.php"
        ApplicationData["ApplicationData"]:::util
        click ApplicationData "https://github.com/skywors/tempora/blob/main/src/Utils/ApplicationData.php"
        Cookie["Cookie"]:::util
        click Cookie "https://github.com/skywors/tempora/blob/main/src/Utils/Cookie.php"
        Lang["Lang"]:::util
        click Lang "https://github.com/skywors/tempora/blob/main/src/Utils/Lang.php"
        System["System"]:::util
        click System "https://github.com/skywors/tempora/blob/main/src/Utils/System.php"
        Roles["Roles"]:::util
        click Roles "https://github.com/skywors/tempora/blob/main/src/Utils/Roles.php"
        Git["Git"]:::util
        click Git "https://github.com/skywors/tempora/blob/main/src/Utils/Git.php"
        ElementBuilder["ElementBuilder"]:::util
        click ElementBuilder "https://github.com/skywors/tempora/blob/main/src/Utils/ElementBuilder/ElementBuilder.php"
        Form["Form"]:::util
        click Form "https://github.com/skywors/tempora/blob/main/src/Utils/ElementBuilder/Form.php"
        Select["Select"]:::util
        click Select "https://github.com/skywors/tempora/blob/main/src/Utils/ElementBuilder/Select.php"
    end
    Helpers --> Controllers

    %% Views
    Views["View Renderer\n(src/views/components & layouts)"]:::view
    click Views "https://github.com/skywors/tempora/tree/main/src/views/components/"
    click Views "https://github.com/skywors/tempora/tree/main/src/views/layouts/"
    Views --> Browser

    %% External SMTP Service
    SMTP["SMTP/Mail Server"]:::external

    %% Logging
    Logging["Logging Subsystem\n(logs/)"]:::log
    click Logging "https://github.com/skywors/tempora/tree/main/logs/"

    %% Automated Tests
    Tests["Automated Tests\n(PHPUnit)"]:::test
    click Tests "https://github.com/skywors/tempora/blob/main/tests/APIErrorTest.php"
    click Tests "https://github.com/skywors/tempora/blob/main/phpunit.xml"
    Tests -->|HTTP requests| GETController

    %% Relationships
    Controllers -->|uses| Services
    Services -->|accesses| Repositories
    Repositories -->|CRUD| Database
    Controllers -->|renders| Views
    MailService -->|sends email| SMTP

    %% Styles
    classDef webserver fill:#e0ffe0,stroke:#333
    classDef router fill:#cce5ff,stroke:#333
    classDef controller fill:#cce5ff,stroke:#333
    classDef service fill:#cce5ff,stroke:#333
    classDef repo fill:#cce5ff,stroke:#333
    classDef util fill:#cce5ff,stroke:#333
    classDef view fill:#cce5ff,stroke:#333
    classDef db fill:#ffe0cc,stroke:#333
    classDef external fill:#f0ccff,stroke:#333
    classDef static fill:#eeeeee,stroke:#333
    classDef log fill:#ddd,stroke:#333
    classDef test fill:#ffebcc,stroke:#333
```
