# ceyhunsahin/piqoff architecture

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

- Interactive diagram: https://gitdiagram.com/ceyhunsahin/piqoff
- Repository: https://github.com/ceyhunsahin/piqoff

## Overview

##### Project Layers and Main Components
a. Presentation/Client Layer:
- Additionally, look at folders such as “plugins/admin” – these may extend or couple with the presentation layer.
b. Server/Backend Layer:
- Files at the project root like “server.js”, “terminal.js”, and various API modules (“piqhub.js”, “piqService.js”, “piqXApi.js”, etc.) suggest a Node.js-based backend managing business logic, APIs, and service orchestration.
c. Business/Core Logic & Plugins:
- The “www/src/core” directory (with “cls” and “react” folders) indicates a layer where core business rules and UI components are maintained.
- The “plugins” directory contains modules (for example “devprint.js”, “nf525.js”, “pricerApi.js”) which extend the primary functionality. These plugins integrate with the core system and may encapsulate third-party libraries such as DevExpress (as seen in many XML configuration files).
d. Data/Database:
- Although there isn’t a visible “database” directory, you have documentation files in “doc/setup/mysql.md” and directories under “doc/setup/mysql”. This points to a MySQL (or similar SQL-based) database that the backend interacts with.
e. Deployment & Installation:
- The “setup” folder (with various scripts like Install-service.bat, startup.sh, etc.) indicates how services are deployed and managed.

##### Relationships and Interactions
b. API Gateway/Service Layer – The backend (server.js and associated API scripts) acts as the central hub that handles client requests, business logic operations, and orchestrates interactions between plugins and the database.
c. Core Modules and Plugins – Represent this as a layered block under the backend. The “core” directory (business logic, shared utilities, and components) and the “plugins” (extensions like printing, licensing, and specialized APIs) should be shown as integrated components used by the server layer.

##### Architectural Patterns & Technologies
a. The system follows a multi-layer (or layered/MVC-like) architecture:
– Separation between presentation (client UIs), business logic (core/cls and API modules), and data storage.
– Modularity via plugins which extend or customize core functionalities.
b. The frontend code uses frameworks such as DevExpress (as indicated by extensive references in the plugins folders) and seems designed to support different platforms (web, mobile, desktop).
c. The backend is likely a Node.js-based service with modules dedicated to handling various APIs.

##### Final Checklist
- All main components should be clearly labeled.
- Supporting elements such as deployment/setup scripts and any notes on external integrations (MySQL, DevExpress libraries).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation/Client Layer
    subgraph "Presentation/Client Layer"
        direction TB
        AdminUI["Admin UI"]:::presentation
        BossUI["Boss UI"]:::presentation
        MobileUI["Mobile UI"]:::presentation
        OfflineUI["Offline UI"]:::presentation
        POSUI["POS UI"]:::presentation
        RESTUI["REST UI"]:::presentation
        TabUI["Tab UI"]:::presentation
    end

    %% Server/Backend Layer
    subgraph "Server/Backend Layer"
        direction TB
        ServerJS["server.js"]:::backend
        TerminalJS["terminal.js"]:::backend
        PIQHub["piqhub.js"]:::backend
        PIQService["piqService.js"]:::backend
        PIQXApi["piqXApi.js"]:::backend
        PIQPoidApi["piqpoidApi.js"]:::backend
        API_Gateway["Backend API Gateway"]:::backend
    end

    %% Business/Core Logic & Plugins
    subgraph "Business/Core Logic & Plugins"
        direction TB
        CoreLogic["Core Business Logic"]:::core
        DevprintPlugin["DevPrint Plugin"]:::plugins
        NF525Plugin["NF525 Plugin"]:::plugins
        PricerApiPlugin["Pricer API Plugin"]:::plugins
        ClientPlugins["Client Plugins"]:::plugins
        AdminPlugins["Admin Plugins"]:::plugins
    end

    %% Data/Database
    Database["MySQL Database"]:::database

    %% Deployment & Installation
    Deployment["Setup & Deployment Scripts"]:::deployment

    %% Connections from Presentation Layer to Backend API Gateway
    AdminUI -->|"sendsRequest"| API_Gateway
    BossUI -->|"sendsRequest"| API_Gateway
    MobileUI -->|"sendsRequest"| API_Gateway
    OfflineUI -->|"sendsRequest"| API_Gateway
    POSUI -->|"sendsRequest"| API_Gateway
    RESTUI -->|"sendsRequest"| API_Gateway
    TabUI -->|"sendsRequest"| API_Gateway

    %% Connections within Server/Backend Layer to API Gateway
    ServerJS -->|"forwardsRequest"| API_Gateway
    TerminalJS -->|"forwardsRequest"| API_Gateway
    PIQHub -->|"forwardsRequest"| API_Gateway
    PIQService -->|"forwardsRequest"| API_Gateway
    PIQXApi -->|"forwardsRequest"| API_Gateway
    PIQPoidApi -->|"forwardsRequest"| API_Gateway

    %% Connections from Backend API Gateway to Business Logic & Plugins
    API_Gateway -->|"executes"| CoreLogic
    API_Gateway -->|"executes"| DevprintPlugin
    API_Gateway -->|"executes"| NF525Plugin
    API_Gateway -->|"executes"| PricerApiPlugin
    API_Gateway -->|"executes"| ClientPlugins
    API_Gateway -->|"executes"| AdminPlugins

    %% Connections between Backend and Database
    API_Gateway -->|"read/write"| Database
    Database -->|"responds"| API_Gateway

    %% Connection from Deployment to Backend
    Deployment -->|"manages"| API_Gateway

    %% Click Events for Presentation/Client Layer
    click AdminUI "https://github.com/ceyhunsahin/piqoff/tree/main/www/src/admin"
    click BossUI "https://github.com/ceyhunsahin/piqoff/tree/main/www/src/boss"
    click MobileUI "https://github.com/ceyhunsahin/piqoff/tree/main/www/src/mob"
    click OfflineUI "https://github.com/ceyhunsahin/piqoff/tree/main/www/src/off"
    click POSUI "https://github.com/ceyhunsahin/piqoff/tree/main/www/src/pos"
    click RESTUI "https://github.com/ceyhunsahin/piqoff/tree/main/www/src/rest"
    click TabUI "https://github.com/ceyhunsahin/piqoff/tree/main/www/src/tab"

    %% Click Events for Server/Backend Layer
    click ServerJS "https://github.com/ceyhunsahin/piqoff/blob/main/server.js"
    click TerminalJS "https://github.com/ceyhunsahin/piqoff/blob/main/terminal.js"
    click PIQHub "https://github.com/ceyhunsahin/piqoff/blob/main/piqhub.js"
    click PIQService "https://github.com/ceyhunsahin/piqoff/blob/main/plugins/piqService.js"
    click PIQXApi "https://github.com/ceyhunsahin/piqoff/blob/main/plugins/piqXApi.js"
    click PIQPoidApi "https://github.com/ceyhunsahin/piqoff/blob/main/plugins/piqpoidApi.js"

    %% Click Event for Business/Core Logic
    click CoreLogic "https://github.com/ceyhunsahin/piqoff/tree/main/www/src/core"

    %% Click Events for Plugins/Extensions
    click DevprintPlugin "https://github.com/ceyhunsahin/piqoff/blob/main/plugins/devprint.js"
    click NF525Plugin "https://github.com/ceyhunsahin/piqoff/blob/main/plugins/nf525.js"
    click PricerApiPlugin "https://github.com/ceyhunsahin/piqoff/blob/main/plugins/pricerApi.js"
    click ClientPlugins "https://github.com/ceyhunsahin/piqoff/tree/main/www/src/plugins"
    click AdminPlugins "https://github.com/ceyhunsahin/piqoff/tree/main/www/src/plugins/admin"

    %% Click Events for Data/Database
    click Database "https://github.com/ceyhunsahin/piqoff/blob/main/doc/setup/mysql.md"

    %% Click Event for Deployment & Installation
    click Deployment "https://github.com/ceyhunsahin/piqoff/tree/main/setup"

    %% Styles
    classDef presentation fill:#ADD8E6,stroke:#333,stroke-width:2px;
    classDef backend fill:#F4A460,stroke:#333,stroke-width:2px;
    classDef core fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef plugins fill:#FFC0CB,stroke:#333,stroke-width:2px;
    classDef database fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef deployment fill:#D3D3D3,stroke:#333,stroke-width:2px;
```
