# luisddb/manzana architecture

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

## Overview

##### Main Components
- Public Directory: Contains the entry point (public/index.php), assets (CSS, JS), and server configuration files (.htaccess). This represents the “web root” and handles incoming HTTP requests.
– Controllers (e.g., Home.php, EventoController.php, UsuarioController.php) which receive and process requests.
– Models (e.g., EventoModel.php, UsuarioModel.php) for interacting with data sources.
– Views (organized into subfolders such as eventos, usuarios, and global templates) which represent the presentation layer.
– Config, Helpers, Filters, and Libraries which define application settings, utility functions, middleware, and supplementary business logic.
- System Directory: Contains the core CodeIgniter engine. This directory is highly modular and organized into:
– Bootstrapping files (e.g., CodeIgniter.php, bootstrap.php) that initialize the framework.
– Core services, routing, caching, debugging, and session management components.
– A large range of sub-systems (Database handling, Email, Encryption, HTTP handling, etc.) that support the framework functionality.
- Environment and Configuration: The .env file, composer.json, and various configuration files within both app/Config and system/Config provide context on how the system is configured and bootstrapped.
- Testing and Writable Directories:
– The tests folder contains unit and functional test suites.
– The writable folder holds dynamic content such as cache, logs, and uploads which are essential for runtime operations.

##### Relationships and Interactions
- The request is routed (using routing configuration in app/Config/Routes.php and system/Router) to appropriate Controllers in the app/Controllers folder.
- Controllers interact with Models to retrieve or manipulate data and then pass that data to Views for response rendering.
- Underneath, the System folder provides core services such as database connectivity, caching, security, and session management that are consumed by the application.
- External dependencies, like third-party libraries (see app/ThirdParty and system/ThirdParty) and composer-installed packages, should be indicated.
- Testing components reside separately but mention integration that verifies the behavior of controllers, models, and other services.

##### Important Architectural Patterns and Design Principles
- MVC Pattern: Emphasize separation of concerns among models, views, and controllers as implemented in the “app” folder.
- Modular, Layered Design: The clear separation between the application-specific code (app) and the framework’s core (system) shows a layered architecture.
- Dependency Injection & Configuration Over Convention: The extensive configuration files (in app/Config and system/Config) allow for great flexibility.
- Security Best Practices: Note that index.php is in the public folder (not in the project root) which enhances security by hiding internal logic.

##### Relevant Technologies and Frameworks
- PHP 8.1+ is required with specific PHP extensions.
- Composer is used for dependency management (composer.json).

## Diagram (Mermaid)

```mermaid
flowchart TD 
    %% Client
    A["Client (Browser)"]:::client

    %% Public Folder Subgraph
    subgraph "Public Folder"
        B["index.php"]:::public
        C["CSS Assets"]:::public
        D["JS Assets"]:::public
        E[".htaccess"]:::public
        F["robots.txt"]:::public
    end

    %% Core Framework (System) Subgraph
    subgraph "Core Framework (System)"
        G["Bootstrapping Files (CodeIgniter.php, Boot.php)"]:::system
        H["Routing & Core Services"]:::system
    end

    %% Application Layer (app) Subgraph
    subgraph "Application Layer (app)"
        I["Controllers"]:::app
        J["Models"]:::app
        K["Views"]:::app
        L["Config/Helpers/Filters/Libraries"]:::app
    end

    %% Environment & Configuration Subgraph
    subgraph "Environment & Configuration"
        M[".env, composer.json, phpunit.xml.dist"]:::config
        N["Config Directories (app/Config & system/Config)"]:::config
    end

    %% Testing & Writable Subgraph
    subgraph "Testing & Writable"
        O["Tests"]:::test
        P["Writable Storage (Cache, Logs, Sessions, Uploads)"]:::storage
    end

    %% Flow Connections
    A -->|"HTTP_Request"| B
    B -->|"Init_Framework"| G
    G -->|"Handle_Routing"| H
    H -->|"Dispatch_Request"| I
    I -->|"Invoke_Models"| J
    I -->|"Render_Views"| K
    K -->|"Send_Response"| A

    %% Additional Connections for Configuration
    H -->|"Load_Config"| M
    M -->|"Setup_Config"| N

    %% Click Events for Public Folder
    click B "https://github.com/luisddb/manzana/blob/main/public/index.php"
    click C "https://github.com/luisddb/manzana/tree/main/public/css"
    click D "https://github.com/luisddb/manzana/tree/main/public/js"
    click E "https://github.com/luisddb/manzana/blob/main/public/.htaccess"
    click F "https://github.com/luisddb/manzana/blob/main/public/robots.txt"

    %% Click Events for Application Layer
    click I "https://github.com/luisddb/manzana/tree/main/app/Controllers"
    click J "https://github.com/luisddb/manzana/tree/main/app/Models"
    click K "https://github.com/luisddb/manzana/tree/main/app/Views"
    click L "https://github.com/luisddb/manzana/tree/main/app/Config"

    %% Click Events for Core Framework
    click G "https://github.com/luisddb/manzana/blob/main/system/CodeIgniter.php"
    click H "https://github.com/luisddb/manzana/tree/main/system/"

    %% Click Events for Environment & Configuration
    click M "https://github.com/luisddb/manzana/blob/main/.env"
    click N "https://github.com/luisddb/manzana/tree/main/app/Config"

    %% Click Events for Testing & Writable
    click O "https://github.com/luisddb/manzana/tree/main/tests/"
    click P "https://github.com/luisddb/manzana/tree/main/writable/"

    %% Styles
    classDef client fill:#f9f,stroke:#333,stroke-width:2px;
    classDef public fill:#bbf,stroke:#333,stroke-width:2px;
    classDef system fill:#fbf,stroke:#333,stroke-width:2px;
    classDef app fill:#bfb,stroke:#333,stroke-width:2px;
    classDef config fill:#ffb,stroke:#333,stroke-width:2px;
    classDef test fill:#fdb,stroke:#333,stroke-width:2px;
    classDef storage fill:#dfd,stroke:#333,stroke-width:2px;
```
