# hodardcodeclub/construction-works-management-system- architecture

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

- Interactive diagram: https://gitdiagram.com/hodardcodeclub/construction-works-management-system-
- Repository: https://github.com/hodardcodeclub/construction-works-management-system-

## Overview

##### Project type and purpose
- This is a full-stack PHP/MySQL web application called CWMS (Construction Works Management System).
- It has three distinct role-based modules:
– admin   (user login, registration, basic auth pages)
– cwms    (general user interface built on AdminLTE)
– owner   (owner-specific interface, similar structure to cwms)
- Uses Apache2 + PHP (5.7+), MySQL, front-end powered by Bootstrap/AdminLTE, jQuery, and a host of JS/CSS plugins.

##### File structure
Top-level directories:
- admin/        → PHP scripts for authentication and user management, plus SQL import scripts
- cwms/         → primary UI module:
– build/    → source .less files & Grunt asset pipeline
– dist/     → compiled CSS/JS, images
– pages/    → .php/.html views (UI, charts, forms, tables)
– plugins/  → third-party libraries (CKEditor, DataTables, Chart.js, etc.)
– upload/   → file-upload handler + user_images storage
– dbconnect.php, pages/tables/dbconfig.php → database connection
– Gruntfile.js, package.json → build tool config
- owner/        → a near-duplicate of cwms/, but for the “owner” role
- .idea, README.md

a. Client (Browser)
– Fetches HTML/CSS/JS (from dist/, plugins/)
– Sends HTTP(S) requests (GET/POST) to PHP endpoints
b. Web Server (Apache2)
– Serves static assets (dist/, plugins/)
– Routes requests for .php files in admin/, cwms/, owner/
c. Application Modules (PHP)
– Admin module: admin/index.php, register.php, logout.php → handles login/registration
– CWMS module: cwms/index.php + pages/… → dynamic UI, CRUD operations
– Owner module: owner/index.php + pages/… → owner-specific views & CRUD
d. Database (MySQL)
– Single or multiple schemas imported via testdb.sql/hodard.sql
– Accessed through dbconnect.php / dbconfig.php in each module
e. File Storage
– Upload directories: cwms/upload/user_images, owner/upload/user_images
– PHP scripts handle move_uploaded_file and file I/O
f. Build Tool (Grunt)
– Watches build/less → produces dist/css & dist/js bundles

##### Data flows and interactions
- Browser → HTTP → Apache serves static assets or invokes PHP scripts
- PHP scripts ↔ MySQL (PDO/mysqli calls for CRUD)
- PHP file-upload endpoints ↔ local filesystem (user_images/)
- Grunt → compiles LESS → dist/, which browsers then load

##### Architectural patterns and principles
- Role-based modularization: separate admin, cwms, and owner modules
- Asset pipeline: source (build/) → compiled (dist/) → served to client
- Shared templating: header.php, aside.php, footer.php includes for layout consistency
- MVC-inspired: pages/… directories act as “views”, direct DB calls within controllers (PHP pages)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    Client["Browser"]:::client

    %% Web Server Layer
    WebServer["Apache2 + PHP"]:::server

    %% Build Tool
    Build["Grunt (LESS → CSS/JS)"]:::build

    %% Application Modules
    subgraph "Application Modules"
        AdminModule["Admin Module"]:::module
        CwmsModule["CWMS Module"]:::module
        OwnerModule["Owner Module"]:::module
    end

    %% File Storage
    FileStorage["File Storage\n(user_images)"]:::storage

    %% Database
    DB[(MySQL Database)]:::db

    %% Connections
    Client -->|"HTTP GET/POST"| WebServer
    WebServer -->|"serves static assets"| CwmsDist
    WebServer -->|"serves static assets"| CwmsPlugins
    WebServer -->|"serves static assets"| OwnerDist
    WebServer -->|"serves static assets"| OwnerPlugins
    WebServer -->|"routes PHP"| AdminModule
    WebServer -->|"routes PHP"| CwmsModule
    WebServer -->|"routes PHP"| OwnerModule

    Build -->|"compilesLESS→CSS/JS"| CwmsDist
    Build -->|"compilesLESS→CSS/JS"| OwnerDist

    AdminModule -->|"DB queries"| DB
    CwmsModule -->|"DB queries"| DB
    OwnerModule -->|"DB queries"| DB

    AdminModule -->|"file I/O"| FileStorage
    CwmsModule -->|"file I/O"| FileStorage
    OwnerModule -->|"file I/O"| FileStorage

    %% CWMS Assets & Plugins Nodes for static serving
    CwmsDist["cwms/dist/"]:::static
    CwmsPlugins["cwms/plugins/"]:::static
    OwnerDist["owner/dist/"]:::static
    OwnerPlugins["owner/plugins/"]:::static

    %% Click Events for Admin Module
    click AdminModule "https://github.com/hodardcodeclub/construction-works-management-system-/tree/master/admin/"
    click AdminIndex "https://github.com/hodardcodeclub/construction-works-management-system-/blob/master/admin/index.php"
    click AdminRegister "https://github.com/hodardcodeclub/construction-works-management-system-/blob/master/admin/register.php"
    click AdminLogout "https://github.com/hodardcodeclub/construction-works-management-system-/blob/master/admin/logout.php"
    click AdminDBConnect "https://github.com/hodardcodeclub/construction-works-management-system-/blob/master/admin/dbconnect.php"
    click AdminTestDB "https://github.com/hodardcodeclub/construction-works-management-system-/blob/master/admin/testdb.sql"

    %% Click Events for CWMS Module
    click CwmsModule "https://github.com/hodardcodeclub/construction-works-management-system-/tree/master/cwms/"
    click CwmsIndex "https://github.com/hodardcodeclub/construction-works-management-system-/blob/master/cwms/index.php"
    click CwmsHeader "https://github.com/hodardcodeclub/construction-works-management-system-/blob/master/cwms/header.php"
    click CwmsAside "https://github.com/hodardcodeclub/construction-works-management-system-/blob/master/cwms/aside.php"
    click CwmsFooter "https://github.com/hodardcodeclub/construction-works-management-system-/blob/master/cwms/footer.php"
    click CwmsDBConfig "https://github.com/hodardcodeclub/construction-works-management-system-/blob/master/cwms/pages/tables/dbconfig.php"
    click CwmsPages "https://github.com/hodardcodeclub/construction-works-management-system-/tree/master/cwms/pages/"
    click CwmsUpload "https://github.com/hodardcodeclub/construction-works-management-system-/tree/master/cwms/upload/"
    click CwmsUserImages "https://github.com/hodardcodeclub/construction-works-management-system-/tree/master/cwms/upload/user_images"
    click CwmsTestDB "https://github.com/hodardcodeclub/construction-works-management-system-/blob/master/cwms/upload/testdb.sql"
    click CwmsGrunt "https://github.com/hodardcodeclub/construction-works-management-system-/blob/master/cwms/Gruntfile.js"
    click CwmsPackage "https://github.com/hodardcodeclub/construction-works-management-system-/blob/master/cwms/package.json"
    click CwmsBuild "https://github.com/hodardcodeclub/construction-works-management-system-/tree/master/cwms/build/"
    click CwmsDist "https://github.com/hodardcodeclub/construction-works-management-system-/tree/master/cwms/dist/"
    click CwmsPlugins "https://github.com/hodardcodeclub/construction-works-management-system-/tree/master/cwms/plugins/"

    %% Click Events for Owner Module
    click OwnerModule "https://github.com/hodardcodeclub/construction-works-management-system-/tree/master/owner/"
    click OwnerIndex "https://github.com/hodardcodeclub/construction-works-management-system-/blob/master/owner/index.php"
    click OwnerHeader "https://github.com/hodardcodeclub/construction-works-management-system-/blob/master/owner/header.php"
    click OwnerFooter "https://github.com/hodardcodeclub/construction-works-management-system-/blob/master/owner/footer.php"
    click OwnerDBConfig "https://github.com/hodardcodeclub/construction-works-management-system-/blob/master/owner/pages/tables/dbconfig.php"
    click OwnerDBConnect "https://github.com/hodardcodeclub/construction-works-management-system-/blob/master/owner/pages/tables/dbconnect.php"
    click OwnerPages "https://github.com/hodardcodeclub/construction-works-management-system-/tree/master/owner/pages/"
    click OwnerUpload "https://github.com/hodardcodeclub/construction-works-management-system-/tree/master/owner/upload/"
    click OwnerUserImages "https://github.com/hodardcodeclub/construction-works-management-system-/tree/master/owner/upload/user_images"
    click OwnerTestDB "https://github.com/hodardcodeclub/construction-works-management-system-/blob/master/owner/upload/testdb.sql"
    click OwnerGrunt "https://github.com/hodardcodeclub/construction-works-management-system-/blob/master/owner/Gruntfile.js"
    click OwnerBuild "https://github.com/hodardcodeclub/construction-works-management-system-/tree/master/owner/build/"
    click OwnerDist "https://github.com/hodardcodeclub/construction-works-management-system-/tree/master/owner/dist/"
    click OwnerPlugins "https://github.com/hodardcodeclub/construction-works-management-system-/tree/master/owner/plugins/"

    %% Styles
    classDef client fill:#9f6,stroke:#473;
    classDef server fill:#6cf,stroke:#036;
    classDef module fill:#fb3,stroke:#b80;
    classDef db fill:#f66,stroke:#900,stroke-width:2px;
    classDef storage fill:#b95,stroke:#630;
    classDef build fill:#999,stroke:#333;
    classDef static fill:#eef,stroke:#77a;
```
