# pappastech/ospos architecture

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

- Interactive diagram: https://gitdiagram.com/pappastech/ospos
- Repository: https://github.com/pappastech/ospos

## Overview

##### Project type and purpose
- This is “ospos” (Open Source Point of Sale), a monolithic, full-stack web application.
- Built on the PHP CodeIgniter 2/3 MVC framework.
- Provides point-of-sale functions (sales, receivings, reports, inventory, customers, employees, etc.).

##### File structure
- Top-level:
- index.php – front controller
- application/ – your MVC app code
- system/ – CodeIgniter core
- css/, js/, images/ – static assets
- database/database.sql – DB schema dump
- application/:
- config/ – CI configuration (routes, database, autoload)
- controllers/ – HTTP request handlers (barcode, sales, reports…)
- models/ – data layer (Sale, Customer, Inventory, Reports subfolder…)
- views/ – UI templates (HTML + PHP for each module)
- libraries/ – custom CI libraries (MY_Session, charting libs, business-logic libs)
- helpers/ – procedural utilities (currency, tables)
- cache/, logs/ – on-disk storage for CI cache and runtime logs
- system/:
- core/, database/, libraries/, helpers/ – CodeIgniter framework internals
- static assets serve client-side UI (CSS, JS, images).

##### README
- Only a brief project title (“ospos”) and description (“Open Source Point of Sale”).

##### Detail
- Subcomponents: Router, Controllers, Business-logic libraries, Report modules, Chart engine, Session store, File cache.
- External integrations (email service for receipts, printing endpoint, CSV import).
- Visually separate code modules by folder: application/controllers, models, views, libraries, helpers.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Side
    subgraph "Client Side" 
        direction TB
        Browser["Web Browser / POS Terminal UI"]:::frontend
        CSS["CSS"]:::frontend
        JS["JavaScript"]:::frontend
        Images["Images"]:::frontend
    end

    %% Web Tier
    subgraph "Web Tier"
        direction TB
        LB["Load Balancer"]:::backend
        WebServer["Apache/Nginx + PHP-FPM"]:::backend
    end

    %% Application Tier
    subgraph "Application Tier"
        direction TB
        FC["Front Controller (index.php)"]:::backend
        Router["Router (system/core/Router.php)"]:::backend
        Controllers["Controllers (application/controllers/)"]:::backend
        Models["Models (application/models/)"]:::backend
        ReportModels["Report Models (application/models/reports/)"]:::backend
        Views["Views (application/views/)"]:::frontend
        subgraph "Libraries & Helpers"
            direction TB
            Libs["Custom Libraries (application/libraries/)"]:::library
            OFC["Open-Flash-Chart (application/libraries/ofc-library/)"]:::library
            SessionLib["Session Library (MY_Session.php)"]:::library
            Helpers["Helpers (application/helpers/)"]:::library
        end
    end

    %% Data Tier
    subgraph "Data Tier"
        direction TB
        DB["Database Server (MySQL/PostgreSQL)"]:::datastore
        Cache["Cache Store (application/cache/)"]:::datastore
        Logs["Logs (application/logs/)"]:::datastore
        FileStore["File Storage (uploads, receipts, CSVs)"]:::datastore
    end

    %% Database schema
    Schema["DB Schema Dump (database/database.sql)"]:::datastore

    %% Connections
    Browser -->|HTTP Request| LB
    LB --> WebServer
    WebServer --> FC
    FC --> Router
    Router --> Controllers
    Controllers --> Models
    Controllers --> ReportModels
    Controllers --> Views
    Controllers --> Libs
    Controllers --> OFC
    Controllers --> SessionLib
    Controllers --> Helpers
    Models --> DB
    ReportModels --> DB
    Models --> Cache
    Controllers --> FileStore
    Views -->|render HTML/CSS/JS| Browser
    CSS -->|static asset| Browser
    JS -->|static asset| Browser
    Images -->|static asset| Browser
    Cache -->|cache read/write| Models
    SessionLib -->|session read/write| SessionLib
    Logs -->|log write| Controllers
    Schema -.-> DB

    %% Click Events
    click FC "https://github.com/pappastech/ospos/blob/master/index.php"
    click Controllers "https://github.com/pappastech/ospos/tree/master/application/controllers/"
    click Models "https://github.com/pappastech/ospos/tree/master/application/models/"
    click ReportModels "https://github.com/pappastech/ospos/tree/master/application/models/reports/"
    click Views "https://github.com/pappastech/ospos/tree/master/application/views/"
    click Libs "https://github.com/pappastech/ospos/tree/master/application/libraries/"
    click OFC "https://github.com/pappastech/ospos/tree/master/application/libraries/ofc-library/"
    click SessionLib "https://github.com/pappastech/ospos/blob/master/application/libraries/MY_Session.php"
    click Helpers "https://github.com/pappastech/ospos/tree/master/application/helpers/"
    click Cache "https://github.com/pappastech/ospos/tree/master/application/cache/"
    click Logs "https://github.com/pappastech/ospos/tree/master/application/logs/"
    click Schema "https://github.com/pappastech/ospos/blob/master/database/database.sql"
    click CSS "https://github.com/pappastech/ospos/tree/master/css/"
    click JS "https://github.com/pappastech/ospos/tree/master/js/"
    click Images "https://github.com/pappastech/ospos/tree/master/images/"
    click Router "https://github.com/pappastech/ospos/blob/master/system/core/Router.php"

    %% Styles
    classDef frontend fill:#FFE0B2,stroke:#EF6C00,stroke-width:1px
    classDef backend fill:#BBDEFB,stroke:#1E88E5,stroke-width:1px
    classDef datastore fill:#C8E6C9,stroke:#43A047,stroke-width:1px
    classDef library fill:#FFF9C4,stroke:#F9A825,stroke-width:1px,stroke-dasharray: 5 5
```
