# elibaps/cafe-ninety-five-sales-inventory architecture

> Architecture diagram of the GitHub repository elibaps/cafe-ninety-five-sales-inventory, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/elibaps/cafe-ninety-five-sales-inventory
- Repository: https://github.com/elibaps/cafe-ninety-five-sales-inventory

## Overview

Cafe Ninety Five is a PHP/JavaScript sales and inventory management demo. Its main workflow is a cashier building a POS order, submitting it through the API, and receiving a confirmed sale after server-side recipe and stock validation; the same service supports product/recipe setup, inventory operations, waste, reconciliation, histories, and operational summaries. The README documents UI features whose JavaScript implementation was not sampled, so links from the browser to the API and from the API to service/state are grounded in the documented architecture and sampled PHP. Persistence is initialized by bootstrap and uses SQLite via PDO.

Main entry points: [`app/service.php`](https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/app/service.php) (Action dispatcher), [`data`](https://github.com/elibaps/cafe-ninety-five-sales-inventory/tree/main/data) (Demo database), [`api.php`](https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/api.php) (JSON API), [`app/bootstrap.php`](https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/app/bootstrap.php) (Database bootstrap)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["POS and workspace"]
  node_workspace["Workspace shell<br/>[index.php]"]
  node_browser["POS and views<br/>[app.js]"]
end

subgraph group_application["API and domain service"]
  node_api["JSON API<br/>[api.php]"]
  node_service["Action dispatcher<br/>[service.php]"]
  node_history["Role-specific state<br/>[service.php]"]
end

subgraph group_operations["Stock operations and records"]
  node_sales["Checkout and sales<br/>[service.php]"]
  node_catalog["Products and recipes<br/>[service.php]"]
  node_inventory["Inventory and restock<br/>[service.php]"]
  node_waste["Waste recording<br/>[service.php]"]
  node_reconcile["Stock reconciliation<br/>[service.php]"]
end

subgraph group_persistence["Persistence"]
  node_bootstrap["Database bootstrap<br/>[bootstrap.php]"]
  node_schema["Relational schema<br/>[schema.sql]"]
  node_sqlite[("Demo database")]
end

node_cashier(("Cashier / owner"))

node_cashier -->|"uses"| node_workspace
node_workspace -->|"loads"| node_browser
node_browser -->|"submits actions"| node_api
node_api -->|"opens database"| node_bootstrap
node_api -->|"dispatches mutations"| node_service
node_api -->|"requests state"| node_history
node_service -->|"dispatches sale"| node_sales
node_service -->|"dispatches setup"| node_catalog
node_service -->|"dispatches stock"| node_inventory
node_service -->|"dispatches waste"| node_waste
node_service -->|"dispatches count"| node_reconcile
node_bootstrap -->|"initializes"| node_schema
node_bootstrap -->|"connects"| node_sqlite
node_sales -->|"records sale and movements"| node_sqlite
node_catalog -->|"stores products and recipes"| node_sqlite
node_inventory -->|"updates stock ledger"| node_sqlite
node_waste -->|"records waste"| node_sqlite
node_reconcile -->|"records adjustment"| node_sqlite
node_history -->|"reads role-filtered records"| node_sqlite

click node_workspace "https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/index.php"
click node_browser "https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/assets/app.js"
click node_api "https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/api.php"
click node_service "https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/app/service.php"
click node_sales "https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/app/service.php"
click node_catalog "https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/app/service.php"
click node_inventory "https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/app/service.php"
click node_waste "https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/app/service.php"
click node_reconcile "https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/app/service.php"
click node_history "https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/app/service.php"
click node_bootstrap "https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/app/bootstrap.php"
click node_schema "https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/app/schema.sql"
click node_sqlite "https://github.com/elibaps/cafe-ninety-five-sales-inventory/tree/main/data"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_workspace,node_browser toneBlue
class node_api,node_service,node_history toneAmber
class node_sales,node_catalog,node_inventory,node_waste,node_reconcile toneMint
class node_bootstrap,node_schema,node_sqlite toneRose
class node_cashier toneIndigo
```

## Components

### POS and workspace

- [Workspace shell](https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/index.php): `index.php`
- [POS and views](https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/assets/app.js): `assets/app.js`

### API and domain service

- [JSON API](https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/api.php): `api.php`
- [Action dispatcher](https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/app/service.php): `app/service.php`
- [Role-specific state](https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/app/service.php): `app/service.php`

### Stock operations and records

- [Checkout and sales](https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/app/service.php): `app/service.php`
- [Products and recipes](https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/app/service.php): `app/service.php`
- [Inventory and restock](https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/app/service.php): `app/service.php`
- [Waste recording](https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/app/service.php): `app/service.php`
- [Stock reconciliation](https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/app/service.php): `app/service.php`

### Persistence

- [Database bootstrap](https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/app/bootstrap.php): `app/bootstrap.php`
- [Relational schema](https://github.com/elibaps/cafe-ninety-five-sales-inventory/blob/main/app/schema.sql): `app/schema.sql`
- [Demo database](https://github.com/elibaps/cafe-ninety-five-sales-inventory/tree/main/data): `data`

### Other components

- **Cashier / owner**

## Connections

- Cashier / owner → Workspace shell: uses
- Workspace shell → POS and views: loads
- POS and views → JSON API: submits actions
- JSON API → Database bootstrap: opens database
- JSON API → Action dispatcher: dispatches mutations
- JSON API → Role-specific state: requests state
- Action dispatcher → Checkout and sales: dispatches sale
- Action dispatcher → Products and recipes: dispatches setup
- Action dispatcher → Inventory and restock: dispatches stock
- Action dispatcher → Waste recording: dispatches waste
- Action dispatcher → Stock reconciliation: dispatches count
- Database bootstrap → Relational schema: initializes
- Database bootstrap → Demo database: connects
- Checkout and sales → Demo database: records sale and movements
- Products and recipes → Demo database: stores products and recipes
- Inventory and restock → Demo database: updates stock ledger
- Waste recording → Demo database: records waste
- Stock reconciliation → Demo database: records adjustment
- Role-specific state → Demo database: reads role-filtered records
