# huynhminhduc/tiemluc2019 architecture

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

- Interactive diagram: https://gitdiagram.com/huynhminhduc/tiemluc2019
- Repository: https://github.com/huynhminhduc/tiemluc2019

## Overview

##### Project type and purpose
- This is a monolithic, full-stack PHP web application built on the Yii2 framework.
- It provides a public frontend (search/browse data), an authentication & accounts module, plus several feature-specific modules (e.g., “iptc” for IP transfer, “quanly” for management, “sync” for data synchronization, “taisantritueadmin” for IP asset administration).
- It implements MVC and modular Yii2 patterns, with business logic in “services” classes, persistence in ActiveRecord models, presentation in view scripts, and controllers routing requests.

##### File-structure analysis
- Top-level application directories:
- config/ – application configs (web, console, DB, URL rules)
- assets/, modules/, widgets/ – reusable assets (CSS/JS), Yii modules, custom widgets
- commands/ – console commands (Yii console controllers)
- controllers/, models/, views/ – global MVC artifacts
- commons/, services/ – shared utilities and business-logic services
- codeception.yml + tests/ – acceptance/unit/functional tests
- web/ – public web root (index.php, assets deployment, uploads)
- docker-compose.yml, Vagrantfile, vagrant/ – local dev environment
- Each module folder uses the standard Yii2 layout (base controllers, controllers/, models/, views/, assets/, layouts/).
- config/* defines DB connections, parameters, route rules.

##### Key technical stack identified from README & files
- PHP 7.x, Yii2 framework (MVC + modules)
- MySQL (or PostgreSQL) via ActiveRecord
- Nginx + PHP-FPM (via Vagrant/Docker)
- Frontend assets: Dashmix, Bootstrap, jQuery, Slick, ApexCharts
- Console & codeception tests for CI.

##### Main architectural components
a. Client & presentation layer
- Browser (public & admin UIs)
- Assets (CSS/JS delivered from web/assets and modules/*/assets)
b. Web tier
- Nginx (or Apache) as reverse proxy/web server
- PHP-FPM process hosting Yii2 application
- Entry scripts: web/index.php (HTTP), console entry for CLI
c. Application layer (Yii2 monolith)
- Core: index.php → bootstrap → Yii application
- Modules:
– frontend (public search/browse)
– accounts (authentication & user management)
– auth (RBAC, roles, permission)
– iptc, quanly, sync, taisantritueadmin (feature areas)
- Controllers → Services → Models (ActiveRecord)
- Widgets as reusable UI components
- Shared commons/services for cross-module logic
d. Persistence & storage
- RDBMS (MySQL/PostgreSQL) for structured data
- File storage under web/uploads for file attachments
e. External & auxiliary
- Email (mail/* layouts)
- Third-party JS libs (ApexCharts, etc.)
- Vagrant/Docker for local dev/QA
- Codeception for testing

##### Interactions & data flow
- Browser → Nginx → web/index.php
- Yii2 router (URL rules) → appropriate module’s Controller
- Controller calls Service layer for business logic
- Service interacts with ActiveRecord models → DB
- Models may read/write file attachments → web/uploads
- Controller renders view with widgets & assets → Browser
- CLI console commands (commands/) interact with same Services/Models

##### Architectural patterns & design principles
- MVC (Model-View-Controller) core
- Modularization (Yii2 modules isolate feature domains)
- Service layer for business logic, separating it from controllers
- ActiveRecord for ORM
- Shared “commons” and “services” for cross-cutting concerns
- Widget abstraction for reusable UI components

##### Summary of essential elements to capture
- Clear separation: Presentation, Web server, Application modules, Services/Models, Data stores
- Module grouping: frontend, accounts/auth, iptc, quanly, sync, taisantritueadmin

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        Browser["Browser (UI)"]:::presentation
        Assets["Assets (CSS/JS)"]:::presentation
    end

    %% Web Tier
    subgraph "Web Tier"
        Nginx["Nginx (Reverse Proxy)"]:::web
        PHPFPM["PHP-FPM"]:::web
    end

    %% Application Layer
    subgraph "Application Layer"
        Config["Configuration<br/>config/"]:::app
        IndexHTTP["Entry Script<br/>web/index.php"]:::app
        IndexTest["Test Entry<br/>web/index-test.php"]:::app
        ConsoleCLI["Console Entry<br/>tests/bin/yii"]:::app

        subgraph "Yii2 Core"
            Core["Yii2 Bootstrap"]:::app
        end

        subgraph "Modules"
            FE["Frontend Module"]:::module
            Accounts["Accounts Module"]:::module
            AuthMod["Auth/RBAC Module"]:::module
            IPTC["IPTC Module"]:::module
            Quanly["Quanly Module"]:::module
            Sync["Sync Module"]:::module
            TSTTAdmin["TSTTAdmin Module"]:::module
        end

        Controllers["Controllers<br/>controllers/"]:::app
        ServicesAll["Services<br/>services/ & commons/services/"]:::app
        Models["Models<br/>models/ & commons/models/"]:::app
        Views["Views<br/>views/"]:::app
        Widgets["Widgets<br/>widgets/"]:::app
    end

    %% Data & Storage
    subgraph "Data & Storage"
        DB["RDBMS (MySQL/PostgreSQL)"]:::data
        Files["File Storage<br/>web/uploads/"]:::data
    end

    %% External & DevOps
    subgraph "External & DevOps"
        Email["Email Server"]:::external
        DevEnv["Dev Environment<br/>Vagrant/Docker"]:::external
        Tests["Codeception Tests"]:::external
    end

    %% Data Flows
    Browser -->|HTTP Request| Nginx
    Nginx -->|Forward Request| PHPFPM
    PHPFPM -->|Invoke| IndexHTTP
    PHPFPM -->|Invoke| IndexTest
    PHPFPM -->|Invoke| ConsoleCLI
    IndexHTTP -->|Bootstrap| Core
    IndexTest -->|Bootstrap| Core
    ConsoleCLI -->|Bootstrap| Core
    Core -->|Route| Controllers
    Controllers -->|Call| ServicesAll
    ServicesAll -->|Query/Update| Models
    Models -->|Read/Write| DB
    Models -->|Read/Write| Files
    Controllers -->|Render| Views
    Views -->|Use| Assets
    Views -->|Embed| Widgets
    Widgets -->|Load| Assets
    Core -->|Send Email| Email
    DevEnv ---|Setup| Core
    Tests -->|Test| Core

    %% Click Events
    click Config "https://github.com/huynhminhduc/tiemluc2019/tree/master/config/"
    click IndexHTTP "https://github.com/huynhminhduc/tiemluc2019/blob/master/web/index.php"
    click IndexTest "https://github.com/huynhminhduc/tiemluc2019/blob/master/web/index-test.php"
    click ConsoleCLI "https://github.com/huynhminhduc/tiemluc2019/tree/master/tests/bin/yii"
    click Assets "https://github.com/huynhminhduc/tiemluc2019/tree/master/assets/"
    click Controllers "https://github.com/huynhminhduc/tiemluc2019/tree/master/controllers/"
    click Models "https://github.com/huynhminhduc/tiemluc2019/tree/master/models/"
    click Views "https://github.com/huynhminhduc/tiemluc2019/tree/master/views/"
    click ServicesAll "https://github.com/huynhminhduc/tiemluc2019/tree/master/services/"
    click Widgets "https://github.com/huynhminhduc/tiemluc2019/tree/master/widgets/"
    click FE "https://github.com/huynhminhduc/tiemluc2019/tree/master/modules/frontend/"
    click Accounts "https://github.com/huynhminhduc/tiemluc2019/tree/master/modules/accounts/"
    click IPTC "https://github.com/huynhminhduc/tiemluc2019/tree/master/modules/iptc/"
    click Quanly "https://github.com/huynhminhduc/tiemluc2019/tree/master/modules/quanly/"
    click Sync "https://github.com/huynhminhduc/tiemluc2019/tree/master/modules/sync/"
    click TSTTAdmin "https://github.com/huynhminhduc/tiemluc2019/tree/master/modules/taisantritueadmin/"
    click Files "https://github.com/huynhminhduc/tiemluc2019/tree/master/web/uploads/"
    click DevEnv "https://github.com/huynhminhduc/tiemluc2019/blob/master/docker-compose.yml"
    click Tests "https://github.com/huynhminhduc/tiemluc2019/blob/master/codeception.yml"

    %% Styles
    classDef presentation fill:#D0E6FF,stroke:#0366D6,color:#0366D6;
    classDef web fill:#DFFFE0,stroke:#28A745,color:#28A745;
    classDef app fill:#FFE4CC,stroke:#D46A00,color:#D46A00;
    classDef module fill:#FFE4CC,stroke:#D46A00,color:#D46A00;
    classDef data fill:#E0E0E0,stroke:#6C757D,color:#6C757D;
    classDef external fill:#F3E1FF,stroke:#6F42C1,color:#6F42C1;
```
