# soraou/toda-sb architecture

> Architecture diagram of the GitHub repository soraou/toda-sb, 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/soraou/toda-sb
- Repository: https://github.com/soraou/toda-sb

## Overview

MTPFMS is a browser-based municipal franchise and permit management system. Users sign in, receive a role-appropriate menu, load holder records, and work with roster, monitoring, reporting, directory, and activity pages. The sampled authentication flow checks a Supabase session and role before loading records and drawing the application; the data layer synchronizes holder and history changes and subscribes to live updates. README capability descriptions establish several page-level features, but their specific implementations were not sampled, so those branches are represented without guessed internal links.

Main entry points: [`js/db.js`](https://github.com/soraou/toda-sb/blob/main/js/db.js) (Record data layer), [`js/auth.js`](https://github.com/soraou/toda-sb/blob/main/js/auth.js) (Session and role gate), [`js/app.js`](https://github.com/soraou/toda-sb/blob/main/js/app.js) (Shared application), [`login.html`](https://github.com/soraou/toda-sb/blob/main/login.html) (Login page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and navigation"]
  node_login["Login page<br/>[login.html]"]
  node_auth["Session and role gate<br/>[auth.js]"]
  node_app["Shared application<br/>[app.js]"]
end

subgraph group_records["Holder records"]
  node_holders["Franchise holders<br/>[holders.html]"]
  node_toda["TODA holders<br/>[toda.html]"]
  node_poda["PODA holders<br/>[poda.html]"]
  node_allfranchise["All franchise<br/>[all-franchise.html]"]
end

subgraph group_operations["Monitoring and operations"]
  node_dashboard["Dashboard<br/>[dashboard.html]"]
  node_expiration["Expiration monitoring<br/>[expiration.html]"]
  node_renewal["Renewal season<br/>[renewal.html]"]
  node_permit["Permit layout fitting<br/>[permit.js]"]
end

subgraph group_insights["Reporting and directory"]
  node_reports["Reports<br/>[reports.html]"]
  node_quality["Data quality<br/>[data-quality.html]"]
  node_directory["Public directory<br/>[directory.html]"]
  node_activity["Activity logs<br/>[activity.html]"]
end

subgraph group_persistence["Data services"]
  node_db["Record data layer<br/>[db.js]"]
  node_supabase[("Supabase service")]
end

node_user(("Staff user"))

node_user -->|"signs in"| node_login
node_auth -->|"checks session and role"| node_supabase
node_auth -->|"loads records"| node_db
node_auth -->|"loads after authorization"| node_app
node_app -->|"persists changes"| node_db
node_db -->|"reads and writes"| node_supabase
node_db -->|"subscribes to changes"| node_supabase
node_app -->|"loads permit fitter"| node_permit

click node_login "https://github.com/soraou/toda-sb/blob/main/login.html"
click node_auth "https://github.com/soraou/toda-sb/blob/main/js/auth.js"
click node_app "https://github.com/soraou/toda-sb/blob/main/js/app.js"
click node_dashboard "https://github.com/soraou/toda-sb/blob/main/dashboard.html"
click node_holders "https://github.com/soraou/toda-sb/blob/main/holders.html"
click node_toda "https://github.com/soraou/toda-sb/blob/main/toda.html"
click node_poda "https://github.com/soraou/toda-sb/blob/main/poda.html"
click node_allfranchise "https://github.com/soraou/toda-sb/blob/main/all-franchise.html"
click node_expiration "https://github.com/soraou/toda-sb/blob/main/expiration.html"
click node_renewal "https://github.com/soraou/toda-sb/blob/main/renewal.html"
click node_reports "https://github.com/soraou/toda-sb/blob/main/reports.html"
click node_quality "https://github.com/soraou/toda-sb/blob/main/data-quality.html"
click node_directory "https://github.com/soraou/toda-sb/blob/main/directory.html"
click node_activity "https://github.com/soraou/toda-sb/blob/main/activity.html"
click node_db "https://github.com/soraou/toda-sb/blob/main/js/db.js"
click node_permit "https://github.com/soraou/toda-sb/blob/main/js/permit.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_login,node_auth,node_app,node_user toneBlue
class node_holders,node_toda,node_poda,node_allfranchise toneAmber
class node_dashboard,node_expiration,node_renewal,node_permit toneMint
class node_reports,node_quality,node_directory,node_activity toneRose
class node_db,node_supabase toneIndigo
```

## Components

### Access and navigation

- [Login page](https://github.com/soraou/toda-sb/blob/main/login.html): `login.html`
- [Session and role gate](https://github.com/soraou/toda-sb/blob/main/js/auth.js): `js/auth.js`
- [Shared application](https://github.com/soraou/toda-sb/blob/main/js/app.js): `js/app.js`

### Holder records

- [Franchise holders](https://github.com/soraou/toda-sb/blob/main/holders.html): `holders.html`
- [TODA holders](https://github.com/soraou/toda-sb/blob/main/toda.html): `toda.html`
- [PODA holders](https://github.com/soraou/toda-sb/blob/main/poda.html): `poda.html`
- [All franchise](https://github.com/soraou/toda-sb/blob/main/all-franchise.html): `all-franchise.html`

### Monitoring and operations

- [Dashboard](https://github.com/soraou/toda-sb/blob/main/dashboard.html): `dashboard.html`
- [Expiration monitoring](https://github.com/soraou/toda-sb/blob/main/expiration.html): `expiration.html`
- [Renewal season](https://github.com/soraou/toda-sb/blob/main/renewal.html): `renewal.html`
- [Permit layout fitting](https://github.com/soraou/toda-sb/blob/main/js/permit.js): `js/permit.js`

### Reporting and directory

- [Reports](https://github.com/soraou/toda-sb/blob/main/reports.html): `reports.html`
- [Data quality](https://github.com/soraou/toda-sb/blob/main/data-quality.html): `data-quality.html`
- [Public directory](https://github.com/soraou/toda-sb/blob/main/directory.html): `directory.html`
- [Activity logs](https://github.com/soraou/toda-sb/blob/main/activity.html): `activity.html`

### Data services

- [Record data layer](https://github.com/soraou/toda-sb/blob/main/js/db.js): `js/db.js`
- **Supabase service**

### Other components

- **Staff user**

## Connections

- Staff user → Login page: signs in (evidence: `README.md`)
- Session and role gate → Supabase service: checks session and role (evidence: `js/auth.js`)
- Session and role gate → Record data layer: loads records (evidence: `js/auth.js`)
- Session and role gate → Shared application: loads after authorization (evidence: `js/auth.js`)
- Shared application → Record data layer: persists changes (evidence: `js/db.js`)
- Record data layer → Supabase service: reads and writes (evidence: `js/db.js`)
- Record data layer → Supabase service: subscribes to changes (evidence: `js/db.js`)
- Shared application → Permit layout fitting: loads permit fitter (evidence: `js/app.js`)
