# neuharthr/fleetco architecture

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

- Interactive diagram: https://gitdiagram.com/neuharthr/fleetco
- Repository: https://github.com/neuharthr/fleetco

## Overview

##### Main Components
- User Interface (UI) Layer: This includes all PHP pages (login.php, dashboard files, and hundreds of view/edit/add templates), CSS files (pagestyles, styles directories), JavaScript files (in include, plugins such as jQuery, bootstrap, and others), and HTML templates (found in the “templates” folder).
- Business Logic Layer: Represented by the “classes” directory (which contains classes for pages, controls, search functionality, report pages, etc.), “include” folder (which holds shared functions, configuration files, event handlers, and security controls) and additional handlers (such as buttonhandler.php, autofillfields.php, etc.).
- Data Access Layer: This includes the “connections” folder (with ADOConnection.php, ConnectionManager.php and all the specialized connection drivers for MySQL, MSSQL, PDO etc.), “dal” (data access layer) files, and dbcommon.php.
- Database: The application depends on MySQL for persistence. The provided SQL dump (mysql-dump-with dummy-data.sql) serves to initialize the database schema and sample data.
- External Libraries and Integrations: There are integrations with PHPMailer (for email), PHPExcel (for spreadsheet related features), and DomPDF (to generate PDFs) among others.

##### Out Component Interactions
- The User Interface layer receives requests from the user (login, CRUD operations for fueling, maintenance, inventory, etc.).
- These UI components call the business logic layer (via controller pages and included classes) to process requests – for example, using search controls, listing and reporting modules.
- Business logic components interact with the data access layer to execute SQL queries, as orchestrated by the connection classes or the DAL.
- Data retrieved from the database is processed and then returned to the UI for display or further actions.
- Additional integrations (like PDF generation or Excel export) are triggered from the business logic layer which calls the appropriate external library functions.

##### Architectural Patterns and Design Principles
- MVC-like Pattern (without a strict framework): Although not built on a modern MVC framework, the separation of presentation (templates/pages), business logic (classes and includes) and data access (connections/DAL) is evident.
- Layered Architecture: Clear separation between front-end presentation, business processing and database interaction.
- Reusability & Extensibility: The abundance of control classes, modular templates, and loosely coupled components (for example, changeable connection settings via ConnectionManager.php) suggest that the design supports maintainability and extensibility.
- Use of External Libraries: Specialized libraries like PHPMailer, DomPDF, and PHPExcel are integrated to extend functionality without reinventing the wheel.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        UI1["Login Page (login.php)"]:::ui
        UI2["Dashboard (Dashboard_dashboard.php)"]:::ui
        UI3["Templates (HTML Templates)"]:::ui
        UI4["Page Styles (CSS Files)"]:::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        direction TB
        BL1["Business Controls (classes)"]:::bl
        BL2["Includes & Handlers (include)"]:::bl
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        direction TB
        DA1["Connection Drivers (connections)"]:::db
        DA2["DB Functions (connections/dbfunctions)"]:::db
        DA3["DB Common (include/dbcommon.php)"]:::db
    end

    %% Database
    subgraph "Database"
        direction TB
        DB1["MySQL Database (SQL Dump)"]:::dbase
    end

    %% External Libraries and Integrations
    subgraph "External Libraries"
        direction TB
        EL1["PHPMailer"]:::ext
        EL2["PHPExcel"]:::ext
        EL3["DomPDF"]:::ext
    end

    %% Connections from Presentation to Business Logic
    UI1 -->|"loginRequest"| BL2
    UI2 -->|"dashboardActions"| BL1
    UI3 -->|"renderTemplates"| BL2
    UI4 -->|"applyStyles"| BL2

    %% Connections from Business Logic to Data Access and External Libraries
    BL1 -->|"executeCRUD"| DA1
    BL2 -->|"configRouting"| DA3
    BL1 -->|"generateReport"| EL2
    BL1 -->|"generatePDF"| EL3
    BL1 -->|"sendEmail"| EL1

    %% Data Access interactions with Database
    DA1 -->|"performQueries"| DB1
    DA2 -->|"helperFunctions"| DB1
    DA3 -->|"commonDBCalls"| DA1

    %% Data flow returning results
    DB1 --"dataResults"--> BL1
    BL1 --"processedData"--> UI2

    %% Click Events
    click UI1 "https://github.com/neuharthr/fleetco/blob/master/fleetco/login.php"
    click UI2 "https://github.com/neuharthr/fleetco/blob/master/fleetco/Dashboard_dashboard.php"
    click UI3 "https://github.com/neuharthr/fleetco/tree/master/fleetco/templates"
    click UI4 "https://github.com/neuharthr/fleetco/tree/master/fleetco/pagestyles"
    click BL1 "https://github.com/neuharthr/fleetco/tree/master/fleetco/classes"
    click BL2 "https://github.com/neuharthr/fleetco/tree/master/fleetco/include"
    click DA1 "https://github.com/neuharthr/fleetco/tree/master/fleetco/connections"
    click DA2 "https://github.com/neuharthr/fleetco/tree/master/fleetco/connections/dbfunctions"
    click DA3 "https://github.com/neuharthr/fleetco/blob/master/fleetco/include/dbcommon.php"
    click DB1 "https://github.com/neuharthr/fleetco/blob/master/fleetco/mysql-dump-with dummy-data.sql"
    click EL1 "https://github.com/neuharthr/fleetco/tree/master/fleetco/libs/phpmailer"
    click EL2 "https://github.com/neuharthr/fleetco/tree/master/fleetco/plugins/PHPExcel"
    click EL3 "https://github.com/neuharthr/fleetco/tree/master/fleetco/plugins/dompdf"

    %% Styles
    classDef ui fill:#f9c,stroke:#333,stroke-width:2px;
    classDef bl fill:#ccf,stroke:#333,stroke-width:2px;
    classDef db fill:#cfc,stroke:#333,stroke-width:2px;
    classDef dbase fill:#ffc,stroke:#333,stroke-width:2px;
    classDef ext fill:#fcc,stroke:#333,stroke-width:2px;
```
