# mxthor34/chickentown-cutsheets architecture

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

- Interactive diagram: https://gitdiagram.com/mxthor34/chickentown-cutsheets
- Repository: https://github.com/mxthor34/chickentown-cutsheets

## Overview

Chickentown Cut Sheets is a client cut-sheet PWA paired with a staff dashboard, backed directly by Supabase. Clients enter broiler or turkey details, save locally, and submit sheets or separate edit requests; managers review submissions and approve or reject edits. Supabase enforces access and records audit events. The README documents the schema and approval capabilities, while sampled app excerpts show browser-side requests and offline behavior. The migration’s implementation was not sampled, so its internal relationships are shown only where documented.

Main entry points: [`web/app.js`](https://github.com/mxthor34/chickentown-cutsheets/blob/main/web/app.js) (Cut-sheet form), [`staff/app.js`](https://github.com/mxthor34/chickentown-cutsheets/blob/main/staff/app.js) (Staff dashboard), [`supabase/migrations/20261203000000_create_cutsheet.sql`](https://github.com/mxthor34/chickentown-cutsheets/blob/main/supabase/migrations/20261203000000_create_cutsheet.sql) (Supabase API and data), [`web/sw.js`](https://github.com/mxthor34/chickentown-cutsheets/blob/main/web/sw.js) (Client app shell cache)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client PWA"]
  node_client_app["Cut-sheet form<br/>[app.js]"]
  node_client_local[("Local records and queue<br/>[app.js]")]
end

subgraph group_staff["Staff Dashboard"]
  node_staff_app["Staff dashboard<br/>[app.js]"]
end

subgraph group_backend["Supabase Backend"]
  node_supabase[("Supabase API and data")]
  node_policy_audit["Access, audit, approvals"]
end

subgraph group_offline["Offline Support"]
  node_client_sw[("Client app shell cache<br/>[sw.js]")]
  node_staff_sw[("Staff app shell cache<br/>[sw.js]")]
end

node_client_user(("Client"))
node_manager(("Manager"))

node_client_user -->|"enters sheets"| node_client_app
node_client_app -->|"saves drafts and queues"| node_client_local
node_client_app -->|"submits sheets and edit requests"| node_supabase
node_client_local -->|"supplies queued operations"| node_client_app
node_client_app -->|"uses cached shell"| node_client_sw
node_manager -->|"reviews and decides"| node_staff_app
node_staff_app -->|"authenticates and reads submissions"| node_supabase
node_staff_app -->|"calls approval RPCs"| node_policy_audit
node_staff_app -->|"uses cached shell"| node_staff_sw
node_supabase -->|"enforces and audits"| node_policy_audit

click node_client_app "https://github.com/mxthor34/chickentown-cutsheets/blob/main/web/app.js"
click node_client_local "https://github.com/mxthor34/chickentown-cutsheets/blob/main/web/app.js"
click node_client_sw "https://github.com/mxthor34/chickentown-cutsheets/blob/main/web/sw.js"
click node_staff_app "https://github.com/mxthor34/chickentown-cutsheets/blob/main/staff/app.js"
click node_staff_sw "https://github.com/mxthor34/chickentown-cutsheets/blob/main/staff/sw.js"
click node_supabase "https://github.com/mxthor34/chickentown-cutsheets/blob/main/supabase/migrations/20261203000000_create_cutsheet.sql"
click node_policy_audit "https://github.com/mxthor34/chickentown-cutsheets/blob/main/supabase/migrations/20261203000000_create_cutsheet.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_client_app,node_client_local,node_client_user toneBlue
class node_staff_app toneAmber
class node_supabase,node_policy_audit toneMint
class node_client_sw,node_staff_sw toneRose
class node_manager toneIndigo
```

## Components

### Client PWA

- [Cut-sheet form](https://github.com/mxthor34/chickentown-cutsheets/blob/main/web/app.js): `web/app.js`
- [Local records and queue](https://github.com/mxthor34/chickentown-cutsheets/blob/main/web/app.js): `web/app.js`

### Staff Dashboard

- [Staff dashboard](https://github.com/mxthor34/chickentown-cutsheets/blob/main/staff/app.js): `staff/app.js`

### Supabase Backend

- [Supabase API and data](https://github.com/mxthor34/chickentown-cutsheets/blob/main/supabase/migrations/20261203000000_create_cutsheet.sql): `supabase/migrations/20261203000000_create_cutsheet.sql`
- [Access, audit, approvals](https://github.com/mxthor34/chickentown-cutsheets/blob/main/supabase/migrations/20261203000000_create_cutsheet.sql): `supabase/migrations/20261203000000_create_cutsheet.sql`

### Offline Support

- [Client app shell cache](https://github.com/mxthor34/chickentown-cutsheets/blob/main/web/sw.js): `web/sw.js`
- [Staff app shell cache](https://github.com/mxthor34/chickentown-cutsheets/blob/main/staff/sw.js): `staff/sw.js`

### Other components

- **Client**
- **Manager**

## Connections

- Client → Cut-sheet form: enters sheets (evidence: `README.md`)
- Cut-sheet form → Local records and queue: saves drafts and queues (evidence: `web/app.js`)
- Cut-sheet form → Supabase API and data: submits sheets and edit requests (evidence: `web/app.js`)
- Local records and queue → Cut-sheet form: supplies queued operations (evidence: `web/app.js`)
- Cut-sheet form → Client app shell cache: uses cached shell (evidence: `web/sw.js`)
- Manager → Staff dashboard: reviews and decides (evidence: `README.md`)
- Staff dashboard → Supabase API and data: authenticates and reads submissions (evidence: `staff/app.js`)
- Staff dashboard → Access, audit, approvals: calls approval RPCs (evidence: `staff/app.js`)
- Staff dashboard → Staff app shell cache: uses cached shell (evidence: `staff/sw.js`)
- Supabase API and data → Access, audit, approvals: enforces and audits (evidence: `README.md`)
