# webifycms/app architecture

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

## Overview

##### Project Type and Purpose
- WebifyCMS is a CMS application framework designed to simplify building web applications, with built-in content management features.
- It is built using PHP and leverages the Yii framework for its infrastructure.
- The project emphasizes Clean Architecture and Domain Driven Design (DDD), and it divides contexts into extensions for modular and reusable functionality.

##### File Structure
- Top-level files and directories include configuration (config), source code (src), public web files (public), templates, Docker setups (docker), and extension modules (extensions).
- Within src, note the clear separation into layers:
- Application – application bootstrapping.
- Domain – core business logic (staying agnostic of technologies).
- Infrastructure – handling presentation (with separate subdirectories for API, Console, and Web controllers) and service layer bootstrapping.
- The config files are grouped by purpose (e.g., routes, framework parameters, DB, web, and console configurations) making it clear how the environment and request handling are organized.
- Docker configuration is present (with docker/nginx and docker/php) which suggests the deployment and development environment is containerized.

##### README Insights
- The README outlines the architectural style (Clean Architecture & DDD) and mentions the use of Yii for the underlying framework.
- There is an emphasis on modular extensions (admin, user, site, blog, market for extensions/themes) to facilitate customization.
- The roadmap shows different feature areas being developed, which underpins the need for clear separations between core layers and extension points.

a. Main Components:
- Client/Browser: Interacts with the public/index.php.
- Web Server (Docker/Nginx): Serves the HTTP requests.
- PHP Application (Docker/PHP container): Hosts the application logic.
- Frontend Presentation Layer: The "public" folder, "templates" (layouts, admin, home), and "themes".
- Application Layer: Bootstrapping code in src/Application.
- Domain Layer: Business logic in src/Domain.
- Infrastructure Layer: Manages Presentation and Services; subdivided into API controllers, Web controllers, and Console controllers (in src/Infrastructure/Presentation* directories).
- Configuration and Routing: Files in config folder (framework config, routes for API and Web).
- Extensions: Modular components in the "extensions" folder that extend base functionality.
- External Services/Database: While not shown directly as a directory, the config/framework/db.php file and environment variables in .env indicate database connectivity and possibly other services.

b. Relationships and Interactions:
- Requests initiated from browsers hit the Web Server (Nginx) and are forwarded to the PHP container.
- The public/index.php acts as the entry point, directing incoming web requests to the appropriate controller based on routes defined in config/routes.
- Controllers in the Infrastructure layer (both API and Web) invoke business logic contained in the Domain layer and use Application services.
- Dependency Injection and configuration files (in config/dependencies.php and framework configs) ensure that components interact according to the Clean Architecture principles.
- Extensions plug into the core functionality, allowing customization and addition of features without changing core logic.
- The Docker setup facilitates a separation of environment concerns – meaning that development, testing, and eventual production are all managed in containerized environments.

c. Architectural Patterns and Design Principles:
- Clean Architecture separating concerns into different layers (Presentation, Application, Domain, Infrastructure).
- Domain Driven Design (DDD) ensuring that business rules and logic remain at the center.
- Modular extensions for scalability and customization.
- Usage of dependency injection via configuration for loose coupling.
- Containerization via Docker to isolate infrastructure and deployment concerns.

d. Key Technologies and Frameworks:
- PHP as the programming language.
- Yii Framework for core infrastructure functionalities.
- Docker (compose.yml, Dockerfile) for containerized deployment.
- Potential Database integrations as referenced in config/framework/db.php.
- PHP static analysis and coding standards enforcement tools (referenced via phpstan.dist.neon and php-cs-fixer).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client
    subgraph "Client"
        CB("Client/Browser"):::client
    end

    %% Docker Environment
    subgraph "Docker Environment"
        WS("Web Server (Nginx)"):::docker
        PHP("PHP Application (PHP Container)"):::docker
    end

    %% Entry & Presentation Layer
    subgraph "Entry & Presentation"
        PI("Public (index.php)"):::entry
        PF("Public Files"):::presentation
        T("Templates (Layouts)"):::presentation
        TH("Themes"):::presentation
    end

    %% Infrastructure Layer
    subgraph "Infrastructure"
        API("API Controllers"):::infra
        WC("Web Controllers"):::infra
        CC("Console Controllers"):::infra
        SB("Service Bootstrapping"):::infra
    end

    %% Core Application Layer
    subgraph "Core Application"
        AL("Application Layer (Bootstrapping)"):::app
        DL("Domain Layer (Business Logic)"):::domain
    end

    %% Configuration and Routing
    subgraph "Configuration"
        GC("General Configurations"):::config
        FC("Framework & Dependency Configurations"):::config
        RT("Routes"):::config
        DB("Database Connection"):::config
    end

    %% Extensions
    subgraph "Extensions"
        EX("Extensions (Modular Components)"):::extensions
    end

    %% Connections
    CB --> WS
    WS --> PHP
    PHP --> PI

    PI --> PF
    PI --> T
    PI --> TH
    PI --> API
    PI --> WC
    PI --> CC

    API --> SB
    WC --> SB
    CC --> SB

    SB --> AL
    API --> AL
    WC --> AL
    CC --> AL

    AL --> DL

    FC --> PI
    RT --> PI

    GC --> AL
    FC --> AL
    RT --> AL
    DB --> AL

    EX -.-> DL

    %% Click Events
    click PI "https://github.com/webifycms/app/blob/main/public/index.php"
    click WS "https://github.com/webifycms/app/blob/main/docker/nginx/nginx.conf"
    click PHP "https://github.com/webifycms/app/tree/main/docker/php/Dockerfile"
    click PF "https://github.com/webifycms/app/tree/main/public/"
    click T "https://github.com/webifycms/app/tree/main/templates/"
    click TH "https://github.com/webifycms/app/tree/main/themes/"
    click AL "https://github.com/webifycms/app/tree/main/src/Application/"
    click DL "https://github.com/webifycms/app/tree/main/src/Domain/"
    click API "https://github.com/webifycms/app/tree/main/src/Infrastructure/Presentation/Api/"
    click WC "https://github.com/webifycms/app/tree/main/src/Infrastructure/Presentation/Web/Controller/"
    click CC "https://github.com/webifycms/app/tree/main/src/Infrastructure/Presentation/Console/Controller/"
    click SB "https://github.com/webifycms/app/tree/main/src/Infrastructure/Service/Bootstrap/"
    click GC "https://github.com/webifycms/app/tree/main/config/"
    click FC "https://github.com/webifycms/app/tree/main/config/framework/"
    click RT "https://github.com/webifycms/app/tree/main/config/routes/"
    click DB "https://github.com/webifycms/app/blob/main/config/framework/db.php"
    click EX "https://github.com/webifycms/app/tree/main/extensions/"

    %% Styles
    classDef client fill:#ffcc00,stroke:#333,stroke-width:2px;
    classDef docker fill:#8cd9ff,stroke:#333,stroke-width:2px;
    classDef entry fill:#ffb3b3,stroke:#333,stroke-width:2px;
    classDef presentation fill:#c2f0c2,stroke:#333,stroke-width:2px;
    classDef infra fill:#d9b3ff,stroke:#333,stroke-width:2px;
    classDef app fill:#f2d7d5,stroke:#333,stroke-width:2px;
    classDef domain fill:#f7c6c7,stroke:#333,stroke-width:2px;
    classDef config fill:#d5f5e3,stroke:#333,stroke-width:2px;
    classDef extensions fill:#f6e7b4,stroke:#333,stroke-width:2px;
```
