# markokroselj/launch-tracker architecture

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

- Interactive diagram: https://gitdiagram.com/markokroselj/launch-tracker
- Repository: https://github.com/markokroselj/launch-tracker

## Overview

##### Main Components
- Frontend:
– Views: Found in the “view” folder and its “components” subdirectory. Includes pages like home, dashboard, 404/500 error handling, and various forms (e.g., addLaunch.php).
– Public Assets: Static files such as images, PDF report, CSS (compiled from Tailwind CSS via an input file and configured with tailwind.config.js), and the entry front-end file “index.php.”
- Back-end:
– Controllers: Stored in the “controller” directory (Controller.php, jwtAuth.php, callback.php) that handle routing, authentication, and application logic.
– Models: In the “model” folder; these files (e.g., Launch.php, User.php, Rocket.php, Orbit.php, etc.) interact with the database.
– Routing: “router.php” along with the .htaccess file which manages Apache routing hints.
- Configuration & Dependency Management:
– Environment Variables: Managed via a .env file loaded by PHP dotenv.
– Composer and Node.js: “composer.json” for PHP dependencies and “package.json” with Node scripts for building CSS.
- Database:

##### Relationships & Interactions
– User Requests: Start at “index.php” and “router.php” (with routing rules defined in .htaccess). Incoming requests are passed on to the appropriate controller.
– Controllers use Models to fetch or update data in the MySQL database.
– Views render the data and include components like headers, footers, and tables.
– Async interactions and form submissions are enhanced by HTMX on the client side.
– Authentication: JWT and GitHub OAuth, as seen by dependencies in composer.json, facilitate secure user login and callbacks.
– Build Process: Node.js scripts (build:css, build:min-css) handle the styling part using Tailwind CSS.

##### Architectural Patterns and Design Principles
- MVC Structure: Separate concerns into Models, Views, and Controllers.
- Routing and Middleware: Use of .htaccess along with dedicated routing (router.php) to direct user requests.
- Modular Components: Reusable view components (header, footer, menu) increase maintainability.
- Use of Environment Variables: Centralized configuration management using PHP dotenv.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Entry & Routing Layer
    subgraph "Entry & Routing Layer"
        E["index.php"]:::entry
        R1["router.php"]:::routing
        R2[".htaccess"]:::routing
    end

    %% Controller Layer
    subgraph "Controller Layer"
        C1["Controller.php"]:::controller
        C2["jwtAuth.php"]:::controller
        C3["callback.php"]:::controller
    end

    %% Model Layer
    subgraph "Model Layer"
        M1["DBInit.php"]:::model
        M2["Launch.php"]:::model
        M3["Lc.php"]:::model
        M4["Lsp.php"]:::model
        M5["Orbit.php"]:::model
        M6["Rocket.php"]:::model
        M7["User.php"]:::model
    end

    %% Database
    DB["MySQL Schema (PowerDesigner)"]:::db

    %% View Layer
    subgraph "View Layer"
        V1["Views (view/)"]:::view
        V2["Components (view/components)"]:::view
    end

    %% Public Assets
    subgraph "Public Assets"
        P["Public (public/)"]:::public
    end

    %% Configuration & Build
    subgraph "Configuration & Build"
        Conf["composer.json & composer.lock"]:::config
        Node["package.json"]:::config
        Tail["tailwind.config.js"]:::config
        Env[".env"]:::config
    end

    %% Connections - Entry & Routing to Controllers
    E --> R1
    E --> R2
    R1 --> C1
    R1 --> C2
    R1 --> C3
    R2 --> C1
    R2 --> C2
    R2 --> C3

    %% Controllers to Models
    C1 --> M1
    C1 --> M2
    C1 --> M3
    C1 --> M4
    C1 --> M5
    C1 --> M6
    C1 --> M7
    C2 --> M1
    C2 --> M2
    C2 --> M3
    C2 --> M4
    C2 --> M5
    C2 --> M6
    C2 --> M7
    C3 --> M1
    C3 --> M2
    C3 --> M3
    C3 --> M4
    C3 --> M5
    C3 --> M6
    C3 --> M7

    %% Models to Database
    M1 --> DB
    M2 --> DB
    M3 --> DB
    M4 --> DB
    M5 --> DB
    M6 --> DB
    M7 --> DB

    %% Controllers to Views (typical response flow)
    C1 --> V1
    C2 --> V1
    C3 --> V1

    %% View Layer Internal Flow
    V1 --> V2

    %% View Layer to Public Assets (static content delivery)
    V2 --> P

    %% Asynchronous interaction using HTMX (bidirectional communication)
    V1 -- "HTMX" --> C1

    %% Configuration influences Controllers & Models
    Env --> Conf
    Conf --> C1
    Conf --> C2
    Conf --> C3

    %% Build Process influences Public Assets via CSS generation
    Node --> Tail
    Tail --> P

    %% Click Events
    click E "https://github.com/markokroselj/launch-tracker/blob/main/index.php"
    click R1 "https://github.com/markokroselj/launch-tracker/blob/main/router.php"
    click R2 "https://github.com/markokroselj/launch-tracker/blob/main/.htaccess"
    click C1 "https://github.com/markokroselj/launch-tracker/blob/main/controller/Controller.php"
    click C2 "https://github.com/markokroselj/launch-tracker/blob/main/controller/jwtAuth.php"
    click C3 "https://github.com/markokroselj/launch-tracker/blob/main/controller/callback.php"
    click M1 "https://github.com/markokroselj/launch-tracker/blob/main/model/DBInit.php"
    click M2 "https://github.com/markokroselj/launch-tracker/blob/main/model/Launch.php"
    click M3 "https://github.com/markokroselj/launch-tracker/blob/main/model/Lc.php"
    click M4 "https://github.com/markokroselj/launch-tracker/blob/main/model/Lsp.php"
    click M5 "https://github.com/markokroselj/launch-tracker/blob/main/model/Orbit.php"
    click M6 "https://github.com/markokroselj/launch-tracker/blob/main/model/Rocket.php"
    click M7 "https://github.com/markokroselj/launch-tracker/blob/main/model/User.php"
    click V1 "https://github.com/markokroselj/launch-tracker/tree/main/view/"
    click V2 "https://github.com/markokroselj/launch-tracker/tree/main/view/components"
    click P "https://github.com/markokroselj/launch-tracker/tree/main/public/"
    click Conf "https://github.com/markokroselj/launch-tracker/blob/main/composer.json"
    click Tail "https://github.com/markokroselj/launch-tracker/blob/main/tailwind.config.js"
    click Node "https://github.com/markokroselj/launch-tracker/blob/main/package.json"

    %% Styles
    classDef entry fill:#B3E5FC,stroke:#0288D1,stroke-width:2px;
    classDef routing fill:#F8BBD0,stroke:#C2185B,stroke-width:2px;
    classDef controller fill:#C8E6C9,stroke:#388E3C,stroke-width:2px;
    classDef model fill:#FFF9C4,stroke:#FBC02D,stroke-width:2px;
    classDef db fill:#FFE082,stroke:#F57F17,stroke-width:2px,stroke-dasharray: 5 5;
    classDef view fill:#BBDEFB,stroke:#1976D2,stroke-width:2px;
    classDef public fill:#FFCC80,stroke:#F57C00,stroke-width:2px;
    classDef config fill:#E1BEE7,stroke:#8E24AA,stroke-width:2px;
```
