# itflow-org/itflow architecture

> Architecture diagram of the GitHub repository itflow-org/itflow, 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/itflow-org/itflow
- Repository: https://github.com/itflow-org/itflow

## Overview

##### Project Components
a. User Interfaces:
- Admin Panel – the numerous “admin_*.php” files along with subdirectories (for example, files in the “post/admin” folder) present an interface for managing settings, clients, tickets, invoices, and system configuration.
- Client Portal – the “client” directory, including login pages, dashboards, and ticket management files, supports self-service actions for clients.
- Guest/General Interface – pages like “index.php”, “login.php”, “guest/” similarly hint at public or unauthenticated entry points.
b. API Layer:
- The “api” folder (with version subdirectory “api/v1”) clearly establishes REST endpoints for assets, clients, tickets, invoices, etc. This API is likely consumed by AJAX calls on the frontend and may also support integrations.
c. AJAX Endpoints:
- The “ajax” directory shows many endpoints (like ajax/ajax_ticket_edit.php, ajax/ajax_asset_details.php) that are used for asynchronous functionality in the web‐app.
d. Data & Persistence:
- There is “db.sql” indicating the database structure (most likely a MySQL database) that stores data for all modules.
e. Background Jobs & Scripts:
- The “scripts” folder and specific cron job files (e.g., “cron_mail_queue.php”, “cron_ticket_email_parser.php”) handle asynchronous tasks, data updates, and notifications.
f. Plugins and External Libraries:
- The “plugins” directory contains many third‐party libraries (e.g., PHPMailer, TCPDF, Select2, TinyMCE, FullCalendar, and stripe-php) which are essential for email handling, PDF generation, UI enhancements, and payment processing.
g. Configuration and Deployment:
- Files like “.github” workflows, “.htaccess”, and “LICENSE” as well as the changelog/documentation indicate CI/CD, security rules, and licensing management.

##### Mapping Component Relationships
- Web Clients (Admin, Client, Guest) – Users access distinct frontend interfaces via the web server.
- Web Server Layer (PHP) – The PHP scripts (both traditional page loads and AJAX endpoints) are executed by a web server (such as Apache or Nginx) and they handle routing and business logic.
- API Layer – Requests from the interfaces or external systems (e.g., for mobile apps or integrations) are routed through the API endpoints under “api/v1”, following REST principles.
- Database – All modules (whether via regular page requests, API calls, or cron jobs) interact with a central database whose schema is defined in “db.sql”.
- Background Jobs – Scheduled scripts (in the “scripts” directory) run periodically, handling tasks such as mail queue processing, certificate and domain updates, and ticket email parsing.
- Plugins Libraries – These support additional functions (like sending emails via PHPMailer, generating PDFs with TCPDF, or interacting with Stripe for payments) and are incorporated into various parts of the codebase.

##### Architectural Patterns
- Although not strictly following a modern MVC framework, note that ITFlow separates out different concerns by having specific directories/files for admin, client, API, AJAX, and background processing.
- There is an implicit layering where presentation (HTML/JS/CSS in “client”, “modals”, “includes”), business logic (PHP files/handlers for admin and user operations), and data persistence (SQL database) are clearly discernible.
- Use of versioned API endpoints and dedicated cron scripts are patterns that add modularity to the otherwise monolithic structure.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["Browser Request"]:::frontend
    WebServer["Web Server (PHP)"]:::backend

    subgraph "User Interfaces"
        AdminRoot["Admin Panel (Root)"]:::frontend
        AdminPost["Admin Panel (Post/Admin)"]:::frontend
        Client["Client Portal"]:::frontend
        Guest["Guest/Guest Interface"]:::frontend
    end

    API["API Layer (api/v1)"]:::backend
    AJAX["AJAX Endpoints"]:::backend
    Database["Database (MySQL)"]:::database
    Cron["Cron Jobs & Scripts"]:::jobs
    Plugins["External Plugins"]:::plugins
    Config["Config & Deployment"]:::config

    Browser -->|"HTTP_Request"| WebServer
    WebServer -->|"Serves_UI"| AdminRoot
    WebServer -->|"Serves_UI"| AdminPost
    WebServer -->|"Serves_UI"| Client
    WebServer -->|"Serves_UI"| Guest
    WebServer -->|"Handles_API"| API
    WebServer -->|"Handles_AJAX"| AJAX
    WebServer -->|"DB_Query"| Database
    API -->|"DB_Query"| Database
    AJAX -->|"DB_Query"| Database
    Cron -->|"Scheduled_DB_Task"| Database
    WebServer -->|"Integrates_Plugins"| Plugins
    Cron -->|"Integrates_Plugins"| Plugins
    Config -->|"Secures_CI"| WebServer

    click AdminRoot "https://github.com/itflow-org/itflow/blob/master/admin_api.php"
    click AdminPost "https://github.com/itflow-org/itflow/blob/master/post/admin/admin_api.php"
    click Client "https://github.com/itflow-org/itflow/blob/master/client/index.php"
    click Guest "https://github.com/itflow-org/itflow/blob/master/guest/index.php"
    click API "https://github.com/itflow-org/itflow/tree/master/api/v1"
    click AJAX "https://github.com/itflow-org/itflow/tree/master/ajax"
    click Database "https://github.com/itflow-org/itflow/blob/master/db.sql"
    click Cron "https://github.com/itflow-org/itflow/blob/master/scripts/cron_mail_queue.php"
    click Plugins "https://github.com/itflow-org/itflow/tree/master/plugins"
    click Config "https://github.com/itflow-org/itflow/blob/master/.github"

    classDef frontend fill:#add8e6,stroke:#000,stroke-width:1px;
    classDef backend fill:#90ee90,stroke:#000,stroke-width:1px;
    classDef database fill:#ffff99,stroke:#000,stroke-width:1px;
    classDef jobs fill:#ffcc99,stroke:#000,stroke-width:1px;
    classDef plugins fill:#cfcfcf,stroke:#000,stroke-width:1px;
    classDef config fill:#ffb6c1,stroke:#000,stroke-width:1px;
```
