# lethabomohapi/spazasnap architecture

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

- Interactive diagram: https://gitdiagram.com/lethabomohapi/spazasnap
- Repository: https://github.com/lethabomohapi/spazasnap

## Overview

SpazaSnap is a photo-first, multi-tenant inventory SaaS for spaza shops. Owners register or sign in, manage stock and shelf-photo counts, review formula-based restock suggestions, and save supplier order drafts; receiving drafts updates inventory. The graph also covers the browser’s offline snapshot/draft workflow and the session-derived tenant boundary. README documents additional UI and plan capabilities; unsampled implementation details are represented only where documented, with evidence limits reflected in omitted links.

Main entry points: [`Program.cs`](https://github.com/lethabomohapi/spazasnap/blob/master/Program.cs) (API and sessions), [`StockStore.cs`](https://github.com/lethabomohapi/spazasnap/blob/master/StockStore.cs) (Stock operations), [`wwwroot/app.js`](https://github.com/lethabomohapi/spazasnap/blob/master/wwwroot/app.js) (Shop interface), [`database/schema.sql`](https://github.com/lethabomohapi/spazasnap/blob/master/database/schema.sql) (MySQL data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Accounts and tenancy"]
  node_api["API and sessions<br/>[Program.cs]"]
  node_accounts["Account management<br/>[AccountStore.cs]"]
  node_tenant["Tenant context<br/>[Tenancy.cs]"]
end

subgraph group_inventory["Inventory and stock"]
  node_models["Domain rules<br/>[Models.cs]"]
  node_stock["Stock operations<br/>[StockStore.cs]"]
  node_photos["Shelf photos<br/>[Program.cs]"]
end

subgraph group_orders["Restock and orders"]
  node_restock["Restock estimates<br/>[Models.cs]"]
  node_orderdrafts["Order drafts<br/>[StockStore.cs]"]
end

subgraph group_client["Shop web app"]
  node_browser["Shop interface<br/>[app.js]"]
  node_offline["Offline shell<br/>[sw.js]"]
end

subgraph group_persistence["Persistence"]
  node_mysql[("MySQL data<br/>[schema.sql]")]
  node_photofiles[("Photo and key files<br/>[Program.cs]")]
  node_samples["Sample products<br/>[seed.sql]"]
end

node_owner(("Shop owner"))

node_owner -->|"uses"| node_browser
node_browser -->|"requests API"| node_api
node_browser -->|"registers worker"| node_offline
node_browser -->|"caches snapshots and drafts"| node_browser
node_api -->|"registers and signs in"| node_accounts
node_api -->|"uses shop context"| node_tenant
node_api -->|"routes inventory and orders"| node_stock
node_api -->|"handles photo upload"| node_photos
node_accounts -->|"reads and writes accounts"| node_mysql
node_accounts -->|"optionally inserts"| node_samples
node_stock -->|"scopes shop queries"| node_tenant
node_stock -->|"reads and writes stock"| node_mysql
node_stock -->|"calculates suggestions"| node_restock
node_restock -->|"uses forecast formula"| node_models
node_stock -->|"creates and receives"| node_orderdrafts
node_orderdrafts -->|"stores order lines"| node_mysql
node_api -->|"stores uploaded files"| node_photofiles
node_photos -->|"records photo metadata"| node_stock
node_api -->|"initializes schema"| node_mysql

click node_browser "https://github.com/lethabomohapi/spazasnap/blob/master/wwwroot/app.js"
click node_offline "https://github.com/lethabomohapi/spazasnap/blob/master/wwwroot/sw.js"
click node_api "https://github.com/lethabomohapi/spazasnap/blob/master/Program.cs"
click node_accounts "https://github.com/lethabomohapi/spazasnap/blob/master/AccountStore.cs"
click node_tenant "https://github.com/lethabomohapi/spazasnap/blob/master/Tenancy.cs"
click node_models "https://github.com/lethabomohapi/spazasnap/blob/master/Models.cs"
click node_stock "https://github.com/lethabomohapi/spazasnap/blob/master/StockStore.cs"
click node_photos "https://github.com/lethabomohapi/spazasnap/blob/master/Program.cs"
click node_restock "https://github.com/lethabomohapi/spazasnap/blob/master/Models.cs"
click node_orderdrafts "https://github.com/lethabomohapi/spazasnap/blob/master/StockStore.cs"
click node_mysql "https://github.com/lethabomohapi/spazasnap/blob/master/database/schema.sql"
click node_photofiles "https://github.com/lethabomohapi/spazasnap/blob/master/Program.cs"
click node_samples "https://github.com/lethabomohapi/spazasnap/blob/master/database/seed.sql"

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_api,node_accounts,node_tenant toneBlue
class node_models,node_stock,node_photos toneAmber
class node_restock,node_orderdrafts toneMint
class node_browser,node_offline toneRose
class node_mysql,node_photofiles,node_samples,node_owner toneIndigo
```

## Components

### Accounts and tenancy

- [API and sessions](https://github.com/lethabomohapi/spazasnap/blob/master/Program.cs): `Program.cs`
- [Account management](https://github.com/lethabomohapi/spazasnap/blob/master/AccountStore.cs): `AccountStore.cs`
- [Tenant context](https://github.com/lethabomohapi/spazasnap/blob/master/Tenancy.cs): `Tenancy.cs`

### Inventory and stock

- [Domain rules](https://github.com/lethabomohapi/spazasnap/blob/master/Models.cs): `Models.cs`
- [Stock operations](https://github.com/lethabomohapi/spazasnap/blob/master/StockStore.cs): `StockStore.cs`
- [Shelf photos](https://github.com/lethabomohapi/spazasnap/blob/master/Program.cs): `Program.cs`

### Restock and orders

- [Restock estimates](https://github.com/lethabomohapi/spazasnap/blob/master/Models.cs): `Models.cs`
- [Order drafts](https://github.com/lethabomohapi/spazasnap/blob/master/StockStore.cs): `StockStore.cs`

### Shop web app

- [Shop interface](https://github.com/lethabomohapi/spazasnap/blob/master/wwwroot/app.js): `wwwroot/app.js`
- [Offline shell](https://github.com/lethabomohapi/spazasnap/blob/master/wwwroot/sw.js): `wwwroot/sw.js`

### Persistence

- [MySQL data](https://github.com/lethabomohapi/spazasnap/blob/master/database/schema.sql): `database/schema.sql`
- [Photo and key files](https://github.com/lethabomohapi/spazasnap/blob/master/Program.cs): `Program.cs`
- [Sample products](https://github.com/lethabomohapi/spazasnap/blob/master/database/seed.sql): `database/seed.sql`

### Other components

- **Shop owner**

## Connections

- Shop owner → Shop interface: uses (evidence: `README.md`)
- Shop interface → API and sessions: requests API (evidence: `Program.cs`)
- Shop interface → Offline shell: registers worker (evidence: `wwwroot/app.js`)
- Shop interface → Shop interface: caches snapshots and drafts (evidence: `wwwroot/app.js`)
- API and sessions → Account management: registers and signs in (evidence: `Program.cs`)
- API and sessions → Tenant context: uses shop context (evidence: `Program.cs`)
- API and sessions → Stock operations: routes inventory and orders (evidence: `Program.cs`)
- API and sessions → Shelf photos: handles photo upload (evidence: `Program.cs`)
- Account management → MySQL data: reads and writes accounts (evidence: `AccountStore.cs`)
- Account management → Sample products: optionally inserts (evidence: `AccountStore.cs`)
- Stock operations → Tenant context: scopes shop queries (evidence: `StockStore.cs`)
- Stock operations → MySQL data: reads and writes stock (evidence: `StockStore.cs`)
- Stock operations → Restock estimates: calculates suggestions (evidence: `StockStore.cs`)
- Restock estimates → Domain rules: uses forecast formula (evidence: `Models.cs`)
- Stock operations → Order drafts: creates and receives (evidence: `StockStore.cs`)
- Order drafts → MySQL data: stores order lines (evidence: `StockStore.cs`)
- API and sessions → Photo and key files: stores uploaded files (evidence: `Program.cs`)
- Shelf photos → Stock operations: records photo metadata (evidence: `Program.cs`)
- API and sessions → MySQL data: initializes schema (evidence: `Program.cs`)
