# h2lsoft/unee-project architecture

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

## Overview

##### Main Components
- Core/Kernel: At the heart of the framework is the “core” directory. This contains the bootstrap file (core/bootstrap.php), a series of libraries (in core/lib) that include configuration handling, routing, database abstraction, session management, and logging, as well as the kernel that initializes the framework.
- Configuration Layer: Notice the stand-alone “config/default” directory with several key config files (e.g., app.php, app_dev.php, frontend.php, backend.php, firewall.php, etc.). This part is critical in defining the behavior of the application in different environments.
- Modules: UNEE is built on a modular design. Under the “core/module” folder you have distinct modules for both the backend (core-backend) and frontend (core-frontend). These include modules related to authentication, file management, newsletter mailing, user management, dashboard, logging, and more.
- Components and Assets: The framework includes reusable UI components (datagrid, form) and asset management (CSS, JS) inside the core/assets folder, along with theme assets in “core/theme” and “theme” directories.
- Routing and MVC Elements: Routing files (e.g., core/route/backend.php, frontend.php, frontend_blog.php) indicate the routing layer that directs incoming HTTP requests to the correct controllers (found in core/lib/class/Router.php or in the individual module controllers).
- CLI/Command Tools: The “core/command” directory handles command-line utilities such as installation, migration, and live updates, which are invoked via PHP commands.
- Public and Theme Assets: The “public” directory exposes the static assets and uploaded files (images, uploads for articles, galleries, etc.) while the “theme” directories provide the view layer (Twig templates) for rendering pages.

##### Relationships and Interactions
- The entry point (index.php) initializes the Kernel, which loads the configuration files and registers modules.
- The Router (in the core lib) maps HTTP requests to controllers located in the modules. Each module (e.g., core-backend, core-frontend) encapsulates its own controllers, views, and assets.
- The command-line tools enable tasks like installation, migration, and live-updates by triggering corresponding functions in the core libraries and modules.
- The public directory and themes provide the specialty to serve static content and dynamic view generation (using the Twig engine).

##### Architectural Patterns and Design Principles
- Modularity: Clear separation into modules, each with its own assets, controllers, and view templates.
- MVC-like Separation: Although not strictly “MVC,” you see a separation between application logic (modules/controllers), presentation (Twig templates in theme directories), and configuration.
- Reusability: The inclusion of reusable components (datagrid, forms, etc.) and assets shared across modules.
- Service Layer / Libraries: Core “lib” classes offer services such as database (DB.php), mailer (Mailer.php), and event management (EventManager.php).

##### Key Technologies and Framework Elements
- PHP and Composer for dependency management.
- Twig as the templating engine.
- Apache (as suggested in the prerequisites) for web serving.
- Built-in modules for common enterprise tasks (authentication, file management, live updater, etc.).

##### Detail and Clarity
- That every key element from the file tree (like asset management, theming, and configuration files) is captured;
- Not only the high-level modules but also their interdependencies — for example, how the “Router” depends on the “Config” files and interacts with both frontend and backend controllers;

Happy diagramming!

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% HTTP Request Flow
    subgraph "HTTP Request Flow"
        CLIENT["Client Request"]:::client
        APACHE["Apache Web Server"]:::server
        INDEX["index.php"]:::entry
        CLIENT -->|"sends request"| APACHE
        APACHE -->|"forwards to"| INDEX
        INDEX -->|"initializes"| KERNEL["Kernel/Bootstrap"]:::kernel
    end

    %% Core System
    subgraph "Core System"
        KERNEL -->|"loads"| CONFIG["Configuration Files"]:::config
        CONFIG -->|"provides settings for"| LIB["Core Libraries (DB, Session, Logging)"]:::service
        KERNEL -->|"invokes"| ROUTER["Router"]:::router
        ROUTER -->|"routes to"| BM["Backend Modules"]:::module
        ROUTER -->|"routes to"| FM["Frontend Modules"]:::module
        BM -->|"utilizes"| LIB
        FM -->|"utilizes"| LIB
        KERNEL -->|"initializes"| KERNEL_LIB["Kernel Library"]:::kernel
    end

    %% CLI Operations
    subgraph "CLI Operations"
        CLI["CLI/Command Tools"]:::cli
        CLI -->|"uses services"| LIB
    end

    %% UI & Assets
    subgraph "UI & Assets"
        ASSETS["Components & Assets"]:::assets
        ASSETS -->|"contains"| ADMIN["Admin Themes"]:::theme
        ASSETS -->|"contains"| FRONTEND["Frontend Themes"]:::theme
    end

    %% Public Assets Delivery
    PUBLIC["Public Assets"]:::public
    APACHE -->|"serves static files"| PUBLIC

    %% Click Events
    click KERNEL "https://github.com/h2lsoft/unee-project/blob/main/core/bootstrap.php"
    click KERNEL_LIB "https://github.com/h2lsoft/unee-project/blob/main/core/lib/class/Kernel.php"
    click CONFIG "https://github.com/h2lsoft/unee-project/tree/main/config/default"
    click BM "https://github.com/h2lsoft/unee-project/tree/main/core/module/core-backend"
    click FM "https://github.com/h2lsoft/unee-project/tree/main/core/module/core-frontend"
    click ASSETS "https://github.com/h2lsoft/unee-project/tree/main/core/assets"
    click ADMIN "https://github.com/h2lsoft/unee-project/tree/main/core/theme"
    click FRONTEND "https://github.com/h2lsoft/unee-project/tree/main/theme"
    click ROUTER "https://github.com/h2lsoft/unee-project/blob/main/core/lib/class/Router.php"
    click CLI "https://github.com/h2lsoft/unee-project/tree/main/core/command"
    click PUBLIC "https://github.com/h2lsoft/unee-project/tree/main/public"

    %% Styles
    classDef client fill:#ffcc00,stroke:#000,stroke-width:2px,color:#000;
    classDef server fill:#66ccff,stroke:#000,stroke-width:2px,color:#000;
    classDef entry fill:#cccccc,stroke:#000,stroke-width:2px,color:#000;
    classDef kernel fill:#ff9966,stroke:#000,stroke-width:2px,color:#000;
    classDef config fill:#99ccff,stroke:#000,stroke-width:2px,color:#000;
    classDef router fill:#ccffcc,stroke:#000,stroke-width:2px,color:#000;
    classDef service fill:#ccffff,stroke:#000,stroke-width:2px,color:#000;
    classDef module fill:#ffdddd,stroke:#000,stroke-width:2px,color:#000;
    classDef assets fill:#ddffdd,stroke:#000,stroke-width:2px,color:#000;
    classDef theme fill:#ddddff,stroke:#000,stroke-width:2px,color:#000;
    classDef cli fill:#ffccee,stroke:#000,stroke-width:2px,color:#000;
    classDef public fill:#eeeeee,stroke:#000,stroke-width:2px,color:#000;
```
