# weberp-team/weberp architecture

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

- Interactive diagram: https://gitdiagram.com/weberp-team/weberp
- Repository: https://github.com/weberp-team/weberp

## Overview

##### Project type and purpose
- This is webERP, an open-source, web-based ERP (enterprise resource planning) system built on the LAMP stack (Linux/Apache/Nginx + PHP + MySQL/MariaDB).
- It delivers multi-user accounting and business administration tools via server-side PHP scripts, covering general ledger, inventory, sales orders, MRP, purchasing, EDI, reporting, etc.

##### File structure
- Top-level PHP scripts (e.g., AccountGroups.php, SalesOrders.php, etc.) act as “controllers”/entry points.
- The includes/ directory holds shared libraries for database connection (ConnectDB.inc), business logic classes (Define*.php), utility functions (MiscFunctions.inc), session, authentication, PDF page headers, EDI config, etc.
- Third-party libraries under includes: PHPExcel, phplot (charting), TCPDF (PDF generation), xmlrpc, php-gettext (localization).
- api/ and xmlrpc/ expose programmatic endpoints (REST-like PHP scripts and XML-RPC server).
- reportwriter/ is a sub-module for ad-hoc report building (FormMaker, ReportMaker).
- companies/ holds per-company configuration, custom EDI files, form designs, part images, report templates.
- config.distrib.php and config.php handle global configuration; sql/ contains schema and migration scripts. css/ and javascripts/ hold UI assets; locale/ has translation files.

##### README for additional insights
- Confirms it’s a full-stack PHP ERP, with no separate SPA frontend. It relies on server-rendered HTML/CSS/JS (Bootstrap themes).
- Emphasizes requirements: web server, PHP 5.1+, MySQL/MariaDB, HTML5 browser.
- Documentation and upgrade scripts live under doc/ and sql/.

a. Main components:
- Clients (web browsers)
- Load balancer or reverse proxy (optional)
- Web server + PHP interpreter (Apache, NGINX, Hiawatha)
- Application modules (entry-point PHP scripts)
- Shared libraries & service layer (includes/, Classes/PHPExcel, xmlrpc/)
- Data storage: MySQL/MariaDB database
- File storage: companies/ directory, reportwriter templates, uploaded media
- External services: SMTP mail server, FTP/EDI endpoints, XML-RPC consumers/clients
b. Relationships and interactions:
- HTTP(S) requests from browser → web server → PHP front controller scripts
- Controllers invoke includes/ business-logic classes and utility functions
- Business logic issues SQL queries to the database (via ConnectDB_*.inc)
- PDF/chart libraries invoked for report generation, writing output to browser or file system
- Localization layer (php-gettext) loads .po/.mo per locale
- API scripts and XML-RPC server expose data operations → external clients
- EDI workflows read/write files under companies/<company>/EDI_* and may call FTP_RadioBeacon
- Email functions (htmlMimeMail, smtp.php) deliver notifications
c. Architectural patterns and principles:
- Monolithic, layered architecture: presentation (entry PHP scripts + CSS/JS), service/logic layer (includes/, reportwriter/), data access layer (ConnectDB_*.inc), persistence (MySQL + file store)
- Modular PHP scripts organized by business domain (Sales, GL, Inventory, Fixed Assets, etc.)
- Shared libraries abstract repetitive tasks (PDF headers, charting, Excel I/O)
- Configuration per‐company isolated to companies/ subfolders
- Localization via gettext, enabling multi‐language support
d. Key technologies/frameworks:
- PHP 5+
- MySQL/MariaDB
- PHPExcel for Excel import/export
- TCPDF and PHPlot for PDF and chart generation
- xmlrpc library for XML-RPC interfaces
- php-gettext for internationalization
- Bootstrap CSS themes for UI

##### Detail
- Major directory as a logical module in the service layer.
- Per-company storage partition.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Presentation Tier
    subgraph "Presentation Tier"
        Browser["Web Browser"]:::ui
        LoadBalancer["Load Balancer/Reverse Proxy"]:::ui
        WebServer["Web Server<br/>Apache/Nginx + PHP"]:::ui
        CSS["css/ UI Assets"]:::ui
        JS["javascripts/ UI Scripts"]:::ui
    end

    %% Application Tier
    subgraph "Application Tier"
        EntryScripts["PHP Entry-point Scripts"]:::logic
        SharedLibs["includes/ Shared Libraries"]:::logic
        PHPExcel["Classes/PHPExcel"]:::logic
        PHPlot["includes/phplot"]:::logic
        TCPDF["includes/tcpdf"]:::logic
        API["api/ REST-like API Endpoints"]:::logic
        XMLRPC["xmlrpc/ XML-RPC Server"]:::logic
        ReportWriter["reportwriter/ Ad-hoc Report Builder"]:::logic
        Config["config.distrib.php & config.php"]:::logic
        LocaleLib["includes/php-gettext Localization"]:::logic
        LocaleFiles["locale/ Translations"]:::logic
        EDIConfig["includes/EDIconfig.inc & FTP_RadioBeacon"]:::logic
        EmailLib["includes/htmlMimeMail & smtp"]:::logic
    end

    %% Data Tier
    subgraph "Data Tier"
        Database["MySQL/MariaDB Database"]:::persistence
        Migrations["sql/mysql/ Schema & Migrations"]:::persistence
        CompanyFiles["companies/<company>/ File Storage"]:::persistence
    end

    %% External Services
    subgraph "External Services"
        ExtSMTP["SMTP Mail Server"]:::external
        ExtFTP["FTP/EDI Endpoints"]:::external
        ExtXMLClients["External XML-RPC Clients"]:::external
    end

    %% Traffic Flow
    Browser -->|HTTP/HTTPS| LoadBalancer --> WebServer
    WebServer --> CSS
    WebServer --> JS
    WebServer --> EntryScripts

    %% Application Layer Interactions
    EntryScripts --> SharedLibs
    SharedLibs --> Database
    SharedLibs --> CompanyFiles
    EntryScripts --> PHPExcel
    EntryScripts --> PHPlot
    EntryScripts --> TCPDF
    EntryScripts --> LocaleLib
    LocaleLib --> LocaleFiles
    EntryScripts --> Config
    EntryScripts --> EDIConfig
    EDIConfig --> CompanyFiles
    EntryScripts --> EmailLib
    EmailLib --> ExtSMTP
    EntryScripts --> API
    API --> ExtXMLClients
    EntryScripts --> XMLRPC
    XMLRPC --> ExtXMLClients
    EntryScripts --> ReportWriter
    ReportWriter --> CompanyFiles

    %% Data Tier Internal
    Migrations --> Database

    %% Click Events
    click EntryScripts "https://github.com/weberp-team/weberp/blob/after_4.15.1_bug_fixes_only//*.php"
    click SharedLibs "https://github.com/weberp-team/weberp/tree/after_4.15.1_bug_fixes_only/includes/"
    click PHPExcel "https://github.com/weberp-team/weberp/tree/after_4.15.1_bug_fixes_only/Classes/PHPExcel/"
    click PHPlot "https://github.com/weberp-team/weberp/tree/after_4.15.1_bug_fixes_only/includes/phplot/"
    click TCPDF "https://github.com/weberp-team/weberp/tree/after_4.15.1_bug_fixes_only/includes/tcpdf/"
    click API "https://github.com/weberp-team/weberp/tree/after_4.15.1_bug_fixes_only/api/"
    click XMLRPC "https://github.com/weberp-team/weberp/tree/after_4.15.1_bug_fixes_only/xmlrpc/"
    click ReportWriter "https://github.com/weberp-team/weberp/tree/after_4.15.1_bug_fixes_only/reportwriter/"
    click CompanyFiles "https://github.com/weberp-team/weberp/tree/after_4.15.1_bug_fixes_only/companies/"
    click Config "https://github.com/weberp-team/weberp/blob/after_4.15.1_bug_fixes_only/config.php"
    click CSS "https://github.com/weberp-team/weberp/tree/after_4.15.1_bug_fixes_only/css/"
    click JS "https://github.com/weberp-team/weberp/tree/after_4.15.1_bug_fixes_only/javascripts/"
    click LocaleLib "https://github.com/weberp-team/weberp/tree/after_4.15.1_bug_fixes_only/includes/php-gettext/"
    click LocaleFiles "https://github.com/weberp-team/weberp/tree/after_4.15.1_bug_fixes_only/locale/"
    click EDIConfig "https://github.com/weberp-team/weberp/blob/after_4.15.1_bug_fixes_only/includes/EDIconfig.inc"
    click EmailLib "https://github.com/weberp-team/weberp/blob/after_4.15.1_bug_fixes_only/includes/htmlMimeMail.php"
    click Migrations "https://github.com/weberp-team/weberp/tree/after_4.15.1_bug_fixes_only/sql/mysql/"

    %% Styles
    classDef ui fill:#D6E9FE,stroke:#2B7CE9;
    classDef logic fill:#D0F0C0,stroke:#2E8B57;
    classDef persistence fill:#FFE0B2,stroke:#FF8C00;
    classDef external fill:#E0E0E0,stroke:#A9A9A9;
```
