# aghontpi/infra-management-system architecture

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

- Interactive diagram: https://gitdiagram.com/aghontpi/infra-management-system
- Repository: https://github.com/aghontpi/infra-management-system

## Overview

##### Project type and purpose
- This is a monolithic, full-stack PHP web application (“PHP-Infra-Management-System”) for managing infrastructure assets.
- Purpose: let admins/register users add, remove, update, assign devices to users, plus account activation.

##### File structure
- Top-level PHP scripts (each acts as its own controller/action):
– index.php, register.php, activateusers.php, redirect.php (authentication & onboarding)
– dashboard.php, users.php, worker.php (admin/user dashboards)
– addnew.php, loanitems.php, updateitems.php (asset-management flows)
– header.php (shared UI include), Database.php (PDO DB connector)
- Static assets:
– css/ (normalize.css, skeleton.css, main.css)
– js/main.js
- Database dump: dump.sql for MySQL/MariaDB schema & seed data.

##### Extract architecture hints from README
- Built with raw PHP + PDO, JS, custom CSS (no framework).
- LAMP-style stack: Apache/Nginx + PHP + MySQL.
- Sloppy code organization—no MVC folder separation.

##### Main components
a. Client (Web Browser)
– Sends HTTP(s) requests, loads HTML/CSS/JS, triggers form submissions & AJAX.
b. Web Server + PHP Runtime
– HTTP listener (Apache or Nginx + PHP-FPM)
– Routes requests to specific .php files.
c. Application Modules (grouped by function)
- Auth Module: index.php (login), register.php, activateusers.php, redirect.php
- Dashboard Module: dashboard.php, users.php, worker.php
- Inventory Module: addnew.php, loanitems.php, updateitems.php
- Shared: Database.php (PDO connector), header.php (UI template)
d. Database
– MySQL/MariaDB instance with tables for users, devices, assignments (from dump.sql)
e. Static Asset Service
– Serves CSS and JS files directly from css/ and js/ folders.

##### Relationships & data flows
- Browser → Web Server: GET/POST requests to *.php endpoints
- *.php endpoints → Database.php → MySQL: CRUD via PDO
- PHP scripts → header.php → generate HTML → Browser
- Browser → JS (main.js): optional client-side interactivity (e.g., form validation)
- Browser ← CSS: styling via main.css etc.

##### Architectural patterns & principles
- Single monolith: no microservices or external APIs.
- Functional grouping by script file rather than strict MVC folders.
- Shared library (Database.php) for Data-Access Layer (DAL).
- Template include (header.php) for shared UI—primitive view composition.

##### Technologies & frameworks
- LAMP stack – PHP 7+ with PDO, MySQL/MariaDB
- Plain JavaScript for front-end behavior
- Custom CSS + Skeleton CSS (abandoned) + Normalize.css

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client
    subgraph "Client"
        Browser["Web Browser"]:::client
    end

    %% Static Assets
    subgraph "Static Assets"
        subgraph "css/" 
            Normalize["normalize.css"]:::static
            Skeleton["skeleton.css"]:::static
            MainCSS["main.css"]:::static
        end
        JS["main.js"]:::static
    end

    %% Server and Application
    subgraph "Web Server + PHP-FPM"
        Web["Web Server + PHP-FPM"]:::server
        subgraph "Application Modules"
            subgraph "Auth Module"
                Index["index.php"]:::php
                Register["register.php"]:::php
                Activate["activateusers.php"]:::php
                Redirect["redirect.php"]:::php
            end
            subgraph "Dashboard Module"
                Dashboard["dashboard.php"]:::php
                Users["users.php"]:::php
                Worker["worker.php"]:::php
            end
            subgraph "Inventory Module"
                AddNew["addnew.php"]:::php
                LoanItems["loanitems.php"]:::php
                UpdateItems["updateitems.php"]:::php
            end
            DatabaseFile["Database.php"]:::shared
            Header["header.php"]:::shared
        end
    end

    %% Database
    DB["MySQL/MariaDB"]:::db

    %% Flows
    Browser -->|"GET/POST *.php"| Web
    Web -->|"routes to"| Index
    Web -->|"routes to"| Dashboard
    Web -->|"routes to"| AddNew

    %% Module includes
    Index -.->|include| Header
    Register -.->|include| Header
    Activate -.->|include| Header
    Redirect -.->|include| Header
    Dashboard -.->|include| Header
    Users -.->|include| Header
    Worker -.->|include| Header
    AddNew -.->|include| Header
    LoanItems -.->|include| Header
    UpdateItems -.->|include| Header

    %% Data access
    Index -.->|PDO| DatabaseFile
    Register -.->|PDO| DatabaseFile
    Activate -.->|PDO| DatabaseFile
    Redirect -.->|PDO| DatabaseFile
    Dashboard -.->|PDO| DatabaseFile
    Users -.->|PDO| DatabaseFile
    Worker -.->|PDO| DatabaseFile
    AddNew -.->|PDO| DatabaseFile
    LoanItems -.->|PDO| DatabaseFile
    UpdateItems -.->|PDO| DatabaseFile

    DatabaseFile -->|"PDO::connect/query"| DB

    %% Static asset delivery
    Browser -->|"loads CSS"| Normalize
    Browser -->|"loads CSS"| Skeleton
    Browser -->|"loads CSS"| MainCSS
    Browser -->|"loads JS"| JS

    %% Click Events
    click Index "https://github.com/aghontpi/infra-management-system/blob/master/index.php"
    click Register "https://github.com/aghontpi/infra-management-system/blob/master/register.php"
    click Activate "https://github.com/aghontpi/infra-management-system/blob/master/activateusers.php"
    click Redirect "https://github.com/aghontpi/infra-management-system/blob/master/redirect.php"
    click Dashboard "https://github.com/aghontpi/infra-management-system/blob/master/dashboard.php"
    click Users "https://github.com/aghontpi/infra-management-system/blob/master/users.php"
    click Worker "https://github.com/aghontpi/infra-management-system/blob/master/worker.php"
    click AddNew "https://github.com/aghontpi/infra-management-system/blob/master/addnew.php"
    click LoanItems "https://github.com/aghontpi/infra-management-system/blob/master/loanitems.php"
    click UpdateItems "https://github.com/aghontpi/infra-management-system/blob/master/updateitems.php"
    click DatabaseFile "https://github.com/aghontpi/infra-management-system/blob/master/Database.php"
    click Header "https://github.com/aghontpi/infra-management-system/blob/master/header.php"
    click Normalize "https://github.com/aghontpi/infra-management-system/blob/master/css/normalize.css"
    click Skeleton "https://github.com/aghontpi/infra-management-system/blob/master/css/skeleton.css"
    click MainCSS "https://github.com/aghontpi/infra-management-system/blob/master/css/main.css"
    click JS "https://github.com/aghontpi/infra-management-system/blob/master/js/main.js"

    %% Styles
    classDef client fill:#FFD580,stroke:#333,stroke-width:1px
    classDef server fill:#80B3FF,stroke:#333,stroke-width:1px
    classDef php fill:#B3E1FF,stroke:#333,stroke-width:1px
    classDef shared fill:#D5E8D4,stroke:#333,stroke-width:1px,stroke-dasharray: 2 2
    classDef static fill:#F2F2F2,stroke:#333,stroke-width:1px
    classDef db fill:#FFB3B3,stroke:#333,stroke-width:1px,shape:cylinder
```
