# mrayanghosh/grocery-billing-system architecture

> Architecture diagram of the GitHub repository mrayanghosh/grocery-billing-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mrayanghosh/grocery-billing-system
- Repository: https://github.com/mrayanghosh/grocery-billing-system

## Overview

The Grocery Billing System supports an admin workflow: log in, maintain product stock, build a multi-item bill, deduct purchased quantities, and print an invoice. Stock management and billing query the shared MySQL product catalog through the PHP connection; billing calculations also run in the browser, while invoice data passes through PHP session state to the print page. The README documents responsive styling and these major capabilities. Evidence is limited to the README and sampled source; edges reflect only relationships visible there.

Main entry points: [`billing.php`](https://github.com/mrayanghosh/grocery-billing-system/blob/main/billing.php) (Bill submission), [`stock.php`](https://github.com/mrayanghosh/grocery-billing-system/blob/main/stock.php) (Stock management), [`index.php`](https://github.com/mrayanghosh/grocery-billing-system/blob/main/index.php) (Login), [`print_bill.php`](https://github.com/mrayanghosh/grocery-billing-system/blob/main/print_bill.php) (Printable invoice)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Admin Access"]
  node_login["Login<br/>[index.php]"]
  node_session[("PHP session state")]
  node_logout["Logout<br/>[logout.php]"]
end

subgraph group_inventory["Product Inventory"]
  node_stock["Stock management<br/>[stock.php]"]
  node_catalog[("Product catalog")]
  node_dbconn["MySQL connection<br/>[db.php]"]
end

subgraph group_checkout["Billing Workflow"]
  node_billing["Bill submission<br/>[billing.php]"]
  node_billui["Dynamic bill rows<br/>[billing.js]"]
end

subgraph group_presentation["Invoice and UI"]
  node_invoice["Printable invoice<br/>[print_bill.php]"]
  node_styles["Responsive styling<br/>[style.css]"]
end

node_admin(("Shop admin"))
node_browser(("Admin browser"))

node_admin -->|"enters credentials"| node_login
node_login -->|"sets login state"| node_session
node_login -->|"redirects on success"| node_stock
node_stock -->|"checks login state"| node_session
node_stock -->|"includes connection"| node_dbconn
node_stock -->|"reads and writes products"| node_catalog
node_billing -->|"checks login state"| node_session
node_billing -->|"includes connection"| node_dbconn
node_billing -->|"reads products and updates stock"| node_catalog
node_billing -->|"loads calculations"| node_billui
node_billui -->|"updates displayed totals"| node_browser
node_billing -->|"stores bill data"| node_session
node_billing -->|"redirects after billing"| node_invoice
node_invoice -->|"reads and clears bill data"| node_session
node_admin -->|"manages inventory"| node_stock
node_admin -->|"creates customer bill"| node_billing
node_admin -->|"prints bill"| node_invoice
node_logout -->|"destroys session"| node_session
node_logout -->|"redirects after logout"| node_login
node_browser -.->|"loads page styles"| node_styles

click node_login "https://github.com/mrayanghosh/grocery-billing-system/blob/main/index.php"
click node_stock "https://github.com/mrayanghosh/grocery-billing-system/blob/main/stock.php"
click node_dbconn "https://github.com/mrayanghosh/grocery-billing-system/blob/main/db.php"
click node_billing "https://github.com/mrayanghosh/grocery-billing-system/blob/main/billing.php"
click node_billui "https://github.com/mrayanghosh/grocery-billing-system/blob/main/billing.js"
click node_invoice "https://github.com/mrayanghosh/grocery-billing-system/blob/main/print_bill.php"
click node_logout "https://github.com/mrayanghosh/grocery-billing-system/blob/main/logout.php"
click node_styles "https://github.com/mrayanghosh/grocery-billing-system/blob/main/style.css"

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_login,node_session,node_logout,node_browser toneBlue
class node_stock,node_catalog,node_dbconn toneAmber
class node_billing,node_billui toneMint
class node_invoice,node_styles toneRose
class node_admin toneIndigo
```

## Components

### Admin Access

- [Login](https://github.com/mrayanghosh/grocery-billing-system/blob/main/index.php): `index.php`
- **PHP session state**
- [Logout](https://github.com/mrayanghosh/grocery-billing-system/blob/main/logout.php): `logout.php`

### Product Inventory

- [Stock management](https://github.com/mrayanghosh/grocery-billing-system/blob/main/stock.php): `stock.php`
- **Product catalog**
- [MySQL connection](https://github.com/mrayanghosh/grocery-billing-system/blob/main/db.php): `db.php`

### Billing Workflow

- [Bill submission](https://github.com/mrayanghosh/grocery-billing-system/blob/main/billing.php): `billing.php`
- [Dynamic bill rows](https://github.com/mrayanghosh/grocery-billing-system/blob/main/billing.js): `billing.js`

### Invoice and UI

- [Printable invoice](https://github.com/mrayanghosh/grocery-billing-system/blob/main/print_bill.php): `print_bill.php`
- [Responsive styling](https://github.com/mrayanghosh/grocery-billing-system/blob/main/style.css): `style.css`

### Other components

- **Shop admin**
- **Admin browser**

## Connections

- Shop admin → Login: enters credentials (evidence: `index.php`)
- Login → PHP session state: sets login state (evidence: `index.php`)
- Login → Stock management: redirects on success (evidence: `index.php`)
- Stock management → PHP session state: checks login state (evidence: `stock.php`)
- Stock management → MySQL connection: includes connection (evidence: `stock.php`)
- Stock management → Product catalog: reads and writes products (evidence: `stock.php`)
- Bill submission → PHP session state: checks login state (evidence: `billing.php`)
- Bill submission → MySQL connection: includes connection (evidence: `billing.php`)
- Bill submission → Product catalog: reads products and updates stock (evidence: `billing.php`)
- Bill submission → Dynamic bill rows: loads calculations (evidence: `billing.php`)
- Dynamic bill rows → Admin browser: updates displayed totals (evidence: `billing.js`)
- Bill submission → PHP session state: stores bill data (evidence: `billing.php`)
- Bill submission → Printable invoice: redirects after billing (evidence: `billing.php`)
- Printable invoice → PHP session state: reads and clears bill data (evidence: `print_bill.php`)
- Shop admin → Stock management: manages inventory (evidence: `README.md`)
- Shop admin → Bill submission: creates customer bill (evidence: `README.md`)
- Shop admin → Printable invoice: prints bill (evidence: `print_bill.php`)
- Logout → PHP session state: destroys session (evidence: `logout.php`)
- Logout → Login: redirects after logout (evidence: `logout.php`)
- Admin browser → Responsive styling: loads page styles
