# mohit-ql/tgoms architecture

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

- Interactive diagram: https://gitdiagram.com/mohit-ql/tgoms
- Repository: https://github.com/mohit-ql/tgoms

## Overview

##### Project type and purpose
- From the file tree and the minimal README (“# tgoms”), we see this is a legacy, full-stack PHP web application—likely an Order Management System (OMS) given file names like neworderform.php, orderGoods.php, oms.js, and Templates/OMS.dwt.php.
- Key indicators:
- A suite of .php pages at the root handling forms and workflows (findClient.php, orderUpdate.php, printAll.php, etc.)
- A database.php file (model/DB adapter).
- config.php for configuration (DB credentials, site settings).
- A Templates folder with .dwt.php Dreamweaver templates (view layer).
- JavaScript (CalendarPopup.js, oms.js) and multiple CSS files for layout and print styling (printStyles*.css, style.css).

##### File structure
- Top-level PHP files each implement a “screen” or controller action—e.g., neworderform.php, search.php, viewOrder.php.
- control.php may serve as a front-controller or shared request dispatcher.
- database.php encapsulates all database calls.
- Templates/OMS.dwt.php provides HTML skeletons; header.php/footer.txt act as includes.
- Static assets: JavaScript in root and calendar popup, CSS in root, an image (hli906l3.bmp), a CSV (statecityUSonly.csv).
- No distinct “frontend” directory; this is a monolithic PHP app. No visible microservices or Node/modern framework.

##### README
- README has only the project name. No explicit architecture section. All architectural insight must come from file names and conventions.

a. Main components:
- Client Browser (UI layer)
- Web Server (Apache/IIS with .htaccess configuration)
- PHP Application Layer
– Front Controller (control.php)
– Individual Controllers/Pages (neworderform.php, search.php, etc.)
– View Templates (Templates/OMS.dwt.php, header.php, footer.txt)
– Model/DB Layer (database.php)
- Data Storage
– Relational Database (MySQL, PostgreSQL, etc.)
– Flat files (statecityUSonly.csv)
– Static assets (CSS, JS, images)
- External Services (if any): e-mail service, calendar popup JS library

b. Relationships & Interactions:
1. Browser sends HTTP requests to Web Server.
2. Web Server routes requests (via .htaccess) to PHP front controller or directly to page scripts.
3. PHP controller invokes database.php for CRUD operations.
4. database.php communicates with Database.
5. Controllers load Templates and include header/footer, produce HTML.
6. Response sent back to Browser.
7. Browser fetches CSS/JS assets and renders interactive UI.

c. Architectural patterns/design principles:
- MVC-style separation (Controllers in .php pages, Models in database.php, Views in Templates/*.dwt.php).
- Front-Controller pattern (control.php may centralize routing).
- Template Inclusion (Dreamweaver templates + PHP includes).
- Layered architecture (Presentation → Application → Persistence).

d. Key technologies/frameworks/libraries:
- PHP 5.x or 7.x on Apache (with .htaccess rules).
- MySQL or similar RDBMS (invoked via database.php).
- JavaScript libraries: CalendarPopup.js, custom oms.js.
- CSS for screen & print (style.css, printStyles.css variants).

##### Essential elements
- Don’t overcomplicate: focus on the layered separation and main data flows.
- Every .php file type as “Controller” to illustrate how each HTTP action is handled.
- Template folder and the database abstraction layer.
- Static file serving so reviewers understand where CSS/JS/CSV reside.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["Browser"]:::frontend
    WebServer["Web Server (Apache)"]:::server

    Browser -->|"HTTP Request"| WebServer
    WebServer -->|"Routes via .htaccess"| FrontController
    WebServer -->|"Serves Static Assets"| StaticAssets

    subgraph PHPApplication [PHP Application Layer]
        FrontController["Front Controller\ncontrol.php"]:::app
        Config["Configuration\nconfig.php"]:::app
        subgraph ControllerPages [Controller Pages]
            N1["New Order Form\nneworderform.php"]:::app
            N2["Search\nsearch.php"]:::app
            N3["View Order\nviewOrder.php"]:::app
            N4["Update Order\norderUpdate.php"]:::app
            N5["Order Goods\norderGoods.php"]:::app
            N6["Order Transfer\norderTransfer.php"]:::app
            N7["Find Client\nfindClient.php"]:::app
            N8["Edit Client\neditClient.php"]:::app
            N9["Department Mgmt\ndepartment.php"]:::app
            N10["Deletion\ndeleted.php"]:::app
            N11["Print All\nprintAll.php"]:::app
            N12["Pagination\npagination.php"]:::app
            N13["Sorting\nsort.php"]:::app
            N14["Calendar Endpoint\ncalendar.php"]:::app
        end
        Model["Model\n database.php"]:::model
        subgraph Views [View Templates]
            T1["Templates/OMS.dwt.php"]:::view
            T2["header.php"]:::view
            T3["header.txt"]:::view
            T4["footer.txt"]:::view
        end
        subgraph EntryPoints [Entry Points]
            E1["index.php"]:::app
            E2["index2.php"]:::app
        end

        FrontController --> Controllers
        subgraph Controllers
            Controllers --> N1
            Controllers --> N2
            Controllers --> N3
            Controllers --> N4
            Controllers --> N5
            Controllers --> N6
            Controllers --> N7
            Controllers --> N8
            Controllers --> N9
            Controllers --> N10
            Controllers --> N11
            Controllers --> N12
            Controllers --> N13
            Controllers --> N14
        end
        Controllers --> Model
        Model --> DBServer
        Controllers --> Views
        Config --> FrontController
        EntryPoints --> FrontController
    end

    subgraph StaticAssets [Static Assets]
        JS1["CalendarPopup.js"]:::static
        JS2["oms.js"]:::static
        CSS1["style.css"]:::static
        CSS2["style2.css"]:::static
        CSS3["styles.css"]:::static
        P1["printStyles.css"]:::static
        P2["printStylesIE.css"]:::static
        P3["printStylesMozilla.css"]:::static
        P4["printStylesMozilla121.css"]:::static
        Data1["statecityUSonly.csv"]:::static
        Img1["hli906l3.bmp"]:::static
    end

    DBServer["Database\nMySQL/PostgreSQL"]:::db

    WebServer --> PHPApplication
    PHPApplication -->|"HTML Response"| Browser
    DBServer -->|"Data Storage"| PHPApplication

    click FrontController "https://github.com/mohit-ql/tgoms/blob/main/control.php"
    click Config "https://github.com/mohit-ql/tgoms/blob/main/config.php"
    click Model "https://github.com/mohit-ql/tgoms/blob/main/database.php"
    click T1 "https://github.com/mohit-ql/tgoms/blob/main/Templates/OMS.dwt.php"
    click T2 "https://github.com/mohit-ql/tgoms/blob/main/header.php"
    click T3 "https://github.com/mohit-ql/tgoms/blob/main/header.txt"
    click T4 "https://github.com/mohit-ql/tgoms/blob/main/footer.txt"
    click N1 "https://github.com/mohit-ql/tgoms/blob/main/neworderform.php"
    click N2 "https://github.com/mohit-ql/tgoms/blob/main/search.php"
    click N3 "https://github.com/mohit-ql/tgoms/blob/main/viewOrder.php"
    click N4 "https://github.com/mohit-ql/tgoms/blob/main/orderUpdate.php"
    click N5 "https://github.com/mohit-ql/tgoms/blob/main/orderGoods.php"
    click N6 "https://github.com/mohit-ql/tgoms/blob/main/orderTransfer.php"
    click N7 "https://github.com/mohit-ql/tgoms/blob/main/findClient.php"
    click N8 "https://github.com/mohit-ql/tgoms/blob/main/editClient.php"
    click N9 "https://github.com/mohit-ql/tgoms/blob/main/department.php"
    click N10 "https://github.com/mohit-ql/tgoms/blob/main/deleted.php"
    click N11 "https://github.com/mohit-ql/tgoms/blob/main/printAll.php"
    click N12 "https://github.com/mohit-ql/tgoms/blob/main/pagination.php"
    click N13 "https://github.com/mohit-ql/tgoms/blob/main/sort.php"
    click N14 "https://github.com/mohit-ql/tgoms/blob/main/calendar.php"
    click E1 "https://github.com/mohit-ql/tgoms/blob/main/index.php"
    click E2 "https://github.com/mohit-ql/tgoms/blob/main/index2.php"
    click JS1 "https://github.com/mohit-ql/tgoms/blob/main/CalendarPopup.js"
    click JS2 "https://github.com/mohit-ql/tgoms/blob/main/oms.js"
    click CSS1 "https://github.com/mohit-ql/tgoms/blob/main/style.css"
    click CSS2 "https://github.com/mohit-ql/tgoms/blob/main/style2.css"
    click CSS3 "https://github.com/mohit-ql/tgoms/blob/main/styles.css"
    click P1 "https://github.com/mohit-ql/tgoms/blob/main/printStyles.css"
    click P2 "https://github.com/mohit-ql/tgoms/blob/main/printStylesIE.css"
    click P3 "https://github.com/mohit-ql/tgoms/blob/main/printStylesMozilla.css"
    click P4 "https://github.com/mohit-ql/tgoms/blob/main/printStylesMozilla121.css"
    click Data1 "https://github.com/mohit-ql/tgoms/blob/main/statecityUSonly.csv"
    click Img1 "https://github.com/mohit-ql/tgoms/blob/main/hli906l3.bmp"

    classDef frontend fill:#ccf,stroke:#333;
    classDef server fill:#cfc,stroke:#333;
    classDef app fill:#fcc,stroke:#333;
    classDef model fill:#fdd,stroke:#333;
    classDef view fill:#fcf,stroke:#333;
    classDef db fill:#fc9,stroke:#333;
    classDef static fill:#cff,stroke:#333;
```
