# idreamsoft/icms architecture

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

- Interactive diagram: https://gitdiagram.com/idreamsoft/icms
- Repository: https://github.com/idreamsoft/icms

## Overview

##### Main Components
a. Web Frontend:
- The public and template directories (e.g., “public”, “template”, “template/blog”, and “template/iCMS”) serve as the view layer to present content to end users.
b. Backend Modules:
- The “app” directory contains many modules such as:
– Admin Control Panel (admincp)
– Article, Comment, Content, Category, Member, Node, File, etc.
- Each of these modules handles a specific business domain.
c. Core Framework and Libraries:
- The iPHP framework (in directories like “iPHP”, “core”, and “iPHP/core”) acts as the foundation and provides helper libraries, core routing, caching, database abstraction, templating, and security.
- “vendor”, “iPHP/library”, and third-party libraries (such as jQuery plugins, UEditor, ZeroClipboard, and more) are part of the ecosystem.
d. Data and Caching:
- The “config” directory holds configuration files such as database settings (in config/iCMS/database.php), secret keys, and other definitions.
- The system supports MySQL as the primary persistent datastore.
- Caching classes and files reside under “app/cache” and optional caching libraries (Memcached/Redis) are available.
e. External Integrations:
- There are integrations for API endpoints (under app/api), file storage (“app/files”), plugin system (under app/plugin), and even support for external services (WeChat, CDN, etc.).

##### Relationships and Interactions
– The Clients (web browsers, mobile apps, etc.) send HTTP requests (via public/index.php or public/api.php) to the web server.
– Requests hit the Public layer which, using routing (found in iPHP/core/Route.php and app/func/iCMS/route.php), directs them to the appropriate module (article, comment, user, etc.).
– The modules then interact with the core libraries (iPHP core, iCMS functions, and helper classes).
– All modules connect with the database (configured in “config/iCMS/database.php”) via a common database abstraction layer (in iPHP/core/DB.php and the database modules).
– Optionally, caching is used to improve performance.
– The Admin Control Panel (admincp) and User Control Panel (usercp) are distinct modules with their own views and assets.
– The plugin and extension mechanisms allow additional functionalities to integrate deeply with the system.
– The template system (in “template”) pulls data from backend modules using the core templating system in iPHP/core/template.

##### Architectural Patterns and Design Principles
– The system is organized in a modular, multi-layered architecture. Although not a strict MVC, it separates business logic (in “app” modules and core libraries) from presentation (the “template” and “public” directories).
– There is a clear decoupling where each module (e.g., article, comment, user) encapsulates its specific functions and views.
– Dependency on core libraries and centralized configuration ensures consistency across modules.
– The plugin system provides extensibility, letting third-party integrations hook into various system events.

##### Technologies and Frameworks
– PHP (version 5.6 or above) is the primary language.
– MySQL is used for persistent storage (with configurations under “config/iCMS/database.php”).
– JavaScript libraries (e.g., jQuery, art-template, UEditor) and CSS assets from “assets” and “template/blog/assets”.
– Third-party libraries for caching (Redis/Memcache) and external file storage are available.
– The system uses its own lightweight framework (iPHP) which supplies core functionalities such as routing, database abstraction, caching, templating, and security.

##### Specific Elements
- “Web Clients” (Browsers, Mobile)
- “Routing & Core Framework” (iPHP core libraries and routing engine)
- “Database” (MySQL, with a link to configuration)
- “Caching Layer” (optional, showing Redis/Memcache integration)
- “Template and View Engine” (template/iCMS, template/blog)
- Between Clients → Public entry → Routing → Modules → Database/Caching.
- Between modules and core libraries.

##### Additional Advice
– You might use layering (from presentation to application to infrastructure) to keep the conceptual flow clear.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        WC["Web Clients"]:::client
        PF["Public Entry"]:::frontend
        subgraph "Templates"
            TEMPL["Template Engine"]:::frontend
            TB["Blog Template"]:::frontend
            TC["iCMS Template"]:::frontend
        end
    end

    %% Application Layer
    subgraph "Application Layer"
        RC["Routing & Core Framework"]:::framework
        subgraph "Backend Modules"
            AMC["Admin Control Panel"]:::backend
            ART["Article Management"]:::backend
            COM["Comment Management"]:::backend
            USR["User Management"]:::backend
            MEM["Member Management"]:::backend
            CNT["Content Management"]:::backend
            CAT["Category Management"]:::backend
            NOD["Node Management"]:::backend
            FIL["File Management"]:::backend
            API["API Endpoints"]:::backend
            PLG["Plugin System"]:::backend
        end
    end

    %% Infrastructure Layer
    subgraph "Infrastructure"
        CFG["Configuration (DB Settings)"]:::infrastructure
        CAC["Caching Layer"]:::cache
        DB["MySQL Database"]:::db
        subgraph "Core Libraries"
            IPC["iPHP Core Framework"]:::framework
            IPL["iPHP Library"]:::framework
            VND["Vendor Packages"]:::framework
        end
    end

    %% Connections
    WC -->|"HTTP"| PF
    PF -->|"Routes"| RC
    RC -->|"Dispatches"| AMC
    RC -->|"Dispatches"| ART
    RC -->|"Dispatches"| COM
    RC -->|"Dispatches"| USR
    RC -->|"Dispatches"| MEM
    RC -->|"Dispatches"| CNT
    RC -->|"Dispatches"| CAT
    RC -->|"Dispatches"| NOD
    RC -->|"Dispatches"| FIL
    RC -->|"Dispatches"| API
    RC -->|"Dispatches"| PLG
    RC -->|"Renders"| TEMPL

    IPC -->|"Supports"| RC
    RC -->|"Uses"| IPL
    RC -->|"Uses"| VND

    ART -->|"DB_access"| DB
    AMC -->|"DB_access"| DB
    API -->|"DB_access"| DB
    PLG -->|"DB_access"| DB

    ART -->|"Cache"| CAC
    AMC -->|"Cache"| CAC

    CFG -->|"Configures"| DB

    %% Click Events
    click PF "https://github.com/idreamsoft/icms/tree/master/public"
    click TEMPL "https://github.com/idreamsoft/icms/tree/master/template"
    click TB "https://github.com/idreamsoft/icms/tree/master/template/blog"
    click TC "https://github.com/idreamsoft/icms/tree/master/template/iCMS"
    click AMC "https://github.com/idreamsoft/icms/tree/master/app/admincp"
    click ART "https://github.com/idreamsoft/icms/tree/master/app/article"
    click COM "https://github.com/idreamsoft/icms/tree/master/app/comment"
    click USR "https://github.com/idreamsoft/icms/tree/master/app/user"
    click MEM "https://github.com/idreamsoft/icms/tree/master/app/member"
    click CNT "https://github.com/idreamsoft/icms/tree/master/app/content"
    click CAT "https://github.com/idreamsoft/icms/tree/master/app/category"
    click NOD "https://github.com/idreamsoft/icms/tree/master/app/node"
    click FIL "https://github.com/idreamsoft/icms/tree/master/app/files"
    click API "https://github.com/idreamsoft/icms/tree/master/app/api"
    click PLG "https://github.com/idreamsoft/icms/tree/master/app/plugin"
    click IPC "https://github.com/idreamsoft/icms/tree/master/iPHP/core"
    click IPL "https://github.com/idreamsoft/icms/tree/master/iPHP/library"
    click VND "https://github.com/idreamsoft/icms/tree/master/vendor"
    click CFG "https://github.com/idreamsoft/icms/blob/master/config/iCMS/database.php"
    click CAC "https://github.com/idreamsoft/icms/tree/master/app/cache"

    %% Styles
    classDef client fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef frontend fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef backend fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef framework fill:#ABEBC6,stroke:#145A32,stroke-width:2px;
    classDef db fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef cache fill:#F7DC6F,stroke:#B7950B,stroke-width:2px;
    classDef infrastructure fill:#FAD7A0,stroke:#D35400,stroke-width:2px;
```
