# elie-e/zener architecture

> Architecture diagram of the GitHub repository elie-e/zener, 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/elie-e/zener
- Repository: https://github.com/elie-e/zener

## Overview

##### Main Components

A. Client Layer
- Web Browser
- AJAX Requests Handler
- Frontend Views (organized in views/ directory)

B. Web Server Layer (Apache)
- Entry Point (public/index.php)
- .htaccess Configuration

C. Application Layer
- Controllers (AuthController, QuoteController, etc.)
- Models (User, Quote, Comment, Like)
- Database Abstraction Layer (Database.php)

D. Data Layer
- MySQL Database
- Tables (Users, Quotes, Comments, Likes)

E. Docker Infrastructure
- PHP Container
- MySQL Container

**┌─ Client Layer ─────────────────────┐**
- Web Browser / AJAX Requests        │
- ┬───────────────────┘
- ↓
**┌─ Web Server Layer ─────────────────┐**
- Apache (.htaccess routing)         │
- Entry Point (public/index.php)     │
- ┬───────────────────┘
- ↓
**┌─ Application Layer ────────────────┐**
- ┌─ Controllers ─┐ ┌─ Models ─────┐ │
- Auth        │ │ - User       │ │
- Quote      │ │ - Quote      │ │
- Comment    │ │ - Comment    │ │
- Like       │ │ - Like       │ │
- ┘ └─────────────┘ │
- ┌─ Database Abstraction Layer ───┐ │
- Database.php (PDO, Singleton)  │ │
- ┘ │
- ┬───────────────────┘
- ↓
**┌─ Data Layer ──────────────────────┐**
- MySQL Database                     │
- Users Table                      │
- Quotes Table                     │
- Comments Table                   │
- Likes Table                      │
- ┘

##### Additional Elements

A. Security Layer (cross-cutting):
- Password Hashing
- SQL Injection Protection
- XSS Protection
- CSRF Protection

B. Docker Infrastructure:
- Container relationships
- Network configuration
- Volume mounts

##### Key Interactions to Highlight

- User Authentication Flow
- Quote Creation/Retrieval Flow
- Comment Threading System
- Like Toggle Mechanism
- Database Connection Pool

##### Important Notes

- Stateless nature of the application
- Security measures at each layer
- Docker container boundaries
- Notes for important design patterns (e.g., Singleton for Database)

##### Technical Specifications to Note

- PHP 8.2 runtime
- MySQL database
- Apache web server
- Docker containerization
- PDO database abstraction
- Tailwind CSS for frontend

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Layer
    subgraph CL["Client Layer"]
        Browser["Web Browser"]:::client
        AJAX["AJAX Handler"]:::client
        Views["Frontend Views"]:::client
    end
    click Views "https://github.com/Elie-E/zener/tree/master/views"
    click Views "https://github.com/Elie-E/zener/tree/master/views/auth"
    click Views "https://github.com/Elie-E/zener/tree/master/views/quotes"
    click Views "https://github.com/Elie-E/zener/blob/master/views/layouts/main.php"

    %% Web Server Layer
    subgraph WS["Web Server Layer"]
        Apache["Apache Server"]:::server
        Entry["Entry Point"]:::server
        HTAccess[".htaccess"]:::server
    end
    click Entry "https://github.com/Elie-E/zener/blob/master/public/index.php"
    click HTAccess "https://github.com/Elie-E/zener/blob/master/public/.htaccess"

    %% Application Layer
    subgraph AL["Application Layer"]
        subgraph Controllers
            AuthC["Auth Controller"]:::controller
            QuoteC["Quote Controller"]:::controller
            CommentC["Comment Controller"]:::controller
            LikeC["Like Controller"]:::controller
            ErrorC["Error Controller"]:::controller
        end
        click AuthC "https://github.com/Elie-E/zener/blob/master/src/Controllers/AuthController.php"
        click QuoteC "https://github.com/Elie-E/zener/blob/master/src/Controllers/QuoteController.php"
        click CommentC "https://github.com/Elie-E/zener/blob/master/src/Controllers/CommentController.php"
        click LikeC "https://github.com/Elie-E/zener/blob/master/src/Controllers/LikeController.php"
        click ErrorC "https://github.com/Elie-E/zener/blob/master/src/Controllers/ErrorController.php"

        subgraph Models
            UserM["User Model"]:::model
            QuoteM["Quote Model"]:::model
            CommentM["Comment Model"]:::model
            LikeM["Like Model"]:::model
        end
        click UserM "https://github.com/Elie-E/zener/blob/master/src/Models/User.php"
        click QuoteM "https://github.com/Elie-E/zener/blob/master/src/Models/Quote.php"
        click CommentM "https://github.com/Elie-E/zener/blob/master/src/Models/Comment.php"
        click LikeM "https://github.com/Elie-E/zener/blob/master/src/Models/Like.php"

        DAL["Database Abstraction Layer"]:::dal
    end
    click DAL "https://github.com/Elie-E/zener/blob/master/src/Database.php"

    %% Data Layer
    subgraph DL["Data Layer"]
        DB[("MySQL Database")]:::database
        Users[("Users Table")]:::table
        Quotes[("Quotes Table")]:::table
        Comments[("Comments Table")]:::table
        Likes[("Likes Table")]:::table
    end
    click DB "https://github.com/Elie-E/zener/blob/master/docker/mysql/init.sql"

    %% Docker Infrastructure
    subgraph DI["Docker Infrastructure"]
        PHP["PHP Container"]:::docker
        MySQL["MySQL Container"]:::docker
        Docker["Docker Compose"]:::docker
    end
    click PHP "https://github.com/Elie-E/zener/tree/master/docker/php/Dockerfile"
    click Docker "https://github.com/Elie-E/zener/blob/master/docker-compose.yml"

    %% Connections
    Browser --> AJAX
    Browser --> Views
    AJAX --> Entry
    Views --> Entry
    Entry --> HTAccess
    HTAccess --> Apache
    Apache --> AuthC & QuoteC & CommentC & LikeC & ErrorC
    AuthC & QuoteC & CommentC & LikeC --> UserM & QuoteM & CommentM & LikeM
    UserM & QuoteM & CommentM & LikeM --> DAL
    DAL --> DB
    DB --> Users & Quotes & Comments & Likes

    %% Styles
    classDef client fill:#3498db,stroke:#2980b9,color:white
    classDef server fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef controller fill:#2ecc71,stroke:#27ae60,color:white
    classDef model fill:#e74c3c,stroke:#c0392b,color:white
    classDef dal fill:#9b59b6,stroke:#8e44ad,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:black
    classDef table fill:#e67e22,stroke:#d35400,color:white
    classDef docker fill:#34495e,stroke:#2c3e50,color:white

    %% Legend
    subgraph Legend
        Client["Client Component"]:::client
        Server["Server Component"]:::server
        Cont["Controller"]:::controller
        Mod["Model"]:::model
        DataAbs["Data Abstraction"]:::dal
        DataStore["Database"]:::database
        Tab["Database Table"]:::table
        Dock["Docker Component"]:::docker
    end
```
