# miladraza123/oht_acc_sys architecture

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

- Interactive diagram: https://gitdiagram.com/miladraza123/oht_acc_sys
- Repository: https://github.com/miladraza123/oht_acc_sys

## Overview

Client One is a static PWA for accounting, inventory, billing, and metal-cutting operations; Supabase provides authentication and the PostgreSQL backend, with no application server. Users work through the app shell and its business screens, while database functions, triggers, and row-level security implement business rules. A separate scheduled job exports Excel and restore-JSON backups by email. The README documents product capabilities not visible in the sampled source; those are represented at the documented directory or page level, and the graph omits uncertain internal wiring.

Main entry points: [`client1-index.html`](https://github.com/miladraza123/oht_acc_sys/blob/main/client1-index.html) (App shell), [`db/02_tables.sql`](https://github.com/miladraza123/oht_acc_sys/blob/main/db/02_tables.sql) (PostgreSQL data), [`backup.js`](https://github.com/miladraza123/oht_acc_sys/blob/main/backup.js) (Backup exporter), [`client1-masters.html`](https://github.com/miladraza123/oht_acc_sys/blob/main/client1-masters.html) (Masters and reports)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Browser application"]
  node_shell["App shell<br/>[client1-index.html]"]
  node_masters["Masters and reports"]
  node_billing["Billing and inventory"]
  node_ledger["Daily ledger"]
  node_cutting["Cutting app"]
  node_serviceworker["Offline shell<br/>[sw.js]"]
end

subgraph group_operations["Business operations"]
  node_accounting["Accounting services"]
  node_cuttingdomain["Cutting services"]
  node_costing["Costing engine"]
  node_security["Permissions and RLS"]
end

subgraph group_backend["Database backend"]
  node_postgres[("PostgreSQL data<br/>[02_tables.sql]")]
end

subgraph group_backup["Backup"]
  node_backupjob["Backup exporter<br/>[backup.js]"]
  node_backupfiles["Excel and restore JSON<br/>[backup.js]"]
end

node_user(("User"))
node_supabase["Supabase"]
node_auth["Supabase Auth"]
node_scheduler(("Scheduled runner"))
node_email["Email service"]

node_user -->|"opens"| node_shell
node_shell -->|"embeds"| node_masters
node_shell -->|"embeds"| node_billing
node_shell -->|"embeds"| node_ledger
node_user -->|"uses"| node_cutting
node_masters -->|"requests data"| node_supabase
node_billing -->|"requests data"| node_supabase
node_ledger -->|"requests data"| node_supabase
node_cutting -->|"requests data"| node_supabase
node_shell -.->|"registers"| node_serviceworker
node_supabase -->|"authenticates"| node_auth
node_supabase -->|"accesses"| node_postgres
node_postgres -->|"runs"| node_accounting
node_postgres -->|"runs"| node_cuttingdomain
node_accounting -->|"uses"| node_costing
node_postgres -->|"enforces"| node_security
node_scheduler -->|"starts"| node_backupjob
node_backupjob -->|"signs in and reads"| node_supabase
node_backupjob -->|"generates"| node_backupfiles
node_backupjob -->|"emails attachments"| node_email
node_email -->|"delivers"| node_user

click node_shell "https://github.com/miladraza123/oht_acc_sys/blob/main/client1-index.html"
click node_masters "https://github.com/miladraza123/oht_acc_sys/blob/main/client1-masters.html"
click node_billing "https://github.com/miladraza123/oht_acc_sys/blob/main/client1-billing.html"
click node_ledger "https://github.com/miladraza123/oht_acc_sys/blob/main/client1-daily-ledger.html"
click node_cutting "https://github.com/miladraza123/oht_acc_sys/blob/main/client1-cutting.html"
click node_serviceworker "https://github.com/miladraza123/oht_acc_sys/blob/main/sw.js"
click node_accounting "https://github.com/miladraza123/oht_acc_sys/tree/main/db"
click node_cuttingdomain "https://github.com/miladraza123/oht_acc_sys/tree/main/db"
click node_costing "https://github.com/miladraza123/oht_acc_sys/blob/main/db/06_costing_engine.sql"
click node_security "https://github.com/miladraza123/oht_acc_sys/blob/main/db/10_rls_policies.sql"
click node_postgres "https://github.com/miladraza123/oht_acc_sys/blob/main/db/02_tables.sql"
click node_backupjob "https://github.com/miladraza123/oht_acc_sys/blob/main/backup.js"
click node_backupfiles "https://github.com/miladraza123/oht_acc_sys/blob/main/backup.js"

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_shell,node_masters,node_billing,node_ledger,node_cutting,node_serviceworker,node_user toneBlue
class node_accounting,node_cuttingdomain,node_costing,node_security toneAmber
class node_postgres toneMint
class node_backupjob,node_backupfiles toneRose
class node_supabase,node_auth,node_scheduler,node_email toneIndigo
```

## Components

### Browser application

- [App shell](https://github.com/miladraza123/oht_acc_sys/blob/main/client1-index.html): `client1-index.html`
- [Masters and reports](https://github.com/miladraza123/oht_acc_sys/blob/main/client1-masters.html): `client1-masters.html`
- [Billing and inventory](https://github.com/miladraza123/oht_acc_sys/blob/main/client1-billing.html): `client1-billing.html`
- [Daily ledger](https://github.com/miladraza123/oht_acc_sys/blob/main/client1-daily-ledger.html): `client1-daily-ledger.html`
- [Cutting app](https://github.com/miladraza123/oht_acc_sys/blob/main/client1-cutting.html): `client1-cutting.html`
- [Offline shell](https://github.com/miladraza123/oht_acc_sys/blob/main/sw.js): `sw.js`

### Business operations

- [Accounting services](https://github.com/miladraza123/oht_acc_sys/tree/main/db): `db`
- [Cutting services](https://github.com/miladraza123/oht_acc_sys/tree/main/db): `db`
- [Costing engine](https://github.com/miladraza123/oht_acc_sys/blob/main/db/06_costing_engine.sql): `db/06_costing_engine.sql`
- [Permissions and RLS](https://github.com/miladraza123/oht_acc_sys/blob/main/db/10_rls_policies.sql): `db/10_rls_policies.sql`

### Database backend

- [PostgreSQL data](https://github.com/miladraza123/oht_acc_sys/blob/main/db/02_tables.sql): `db/02_tables.sql`

### Backup

- [Backup exporter](https://github.com/miladraza123/oht_acc_sys/blob/main/backup.js): `backup.js`
- [Excel and restore JSON](https://github.com/miladraza123/oht_acc_sys/blob/main/backup.js): `backup.js`

### Other components

- **User**
- **Supabase**
- **Supabase Auth**
- **Scheduled runner**
- **Email service**

## Connections

- User → App shell: opens
- App shell → Masters and reports: embeds
- App shell → Billing and inventory: embeds
- App shell → Daily ledger: embeds
- User → Cutting app: uses
- Masters and reports → Supabase: requests data
- Billing and inventory → Supabase: requests data
- Daily ledger → Supabase: requests data
- Cutting app → Supabase: requests data
- App shell → Offline shell: registers
- Supabase → Supabase Auth: authenticates
- Supabase → PostgreSQL data: accesses
- PostgreSQL data → Accounting services: runs
- PostgreSQL data → Cutting services: runs
- Accounting services → Costing engine: uses
- PostgreSQL data → Permissions and RLS: enforces
- Scheduled runner → Backup exporter: starts
- Backup exporter → Supabase: signs in and reads
- Backup exporter → Excel and restore JSON: generates
- Backup exporter → Email service: emails attachments
- Email service → User: delivers
