# mxthor34/rbf-daily-production architecture

> Architecture diagram of the GitHub repository mxthor34/rbf-daily-production, 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/rbf-daily-production
- Repository: https://github.com/mxthor34/rbf-daily-production

## Overview

RBF Daily Production collects farm reports in an offline-capable PWA, stores submissions and server-side audit events in Supabase, mirrors them to local CSVs, and renders a Rogue Branch Farm dashboard section. The graph preserves submission, polling, audit, and reporting stages. Source excerpts show the app’s API submission and service-worker registration, the poller’s fetch/merge/write behavior, and dashboard CSV processing; other links rely on the README’s documented architecture.

Main entry points: [`bridge/poll_submissions.py`](https://github.com/mxthor34/rbf-daily-production/blob/main/bridge/poll_submissions.py) (Submission poller), [`web/app.js`](https://github.com/mxthor34/rbf-daily-production/blob/main/web/app.js) (Entry PWA), [`web/sw.js`](https://github.com/mxthor34/rbf-daily-production/blob/main/web/sw.js) (Offline app shell), [`dashboard/production_section.py`](https://github.com/mxthor34/rbf-daily-production/blob/main/dashboard/production_section.py) (Production section)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_capture["Field capture"]
  node_pwa["Entry PWA<br/>[app.js]"]
  node_offline_shell["Offline app shell<br/>[sw.js]"]
  node_browser_storage[("Browser local storage")]
end

subgraph group_cloud["Cloud records"]
  node_supabase[("Supabase")]
  node_production_schema["Production schema"]
end

subgraph group_bridge["Local bridge"]
  node_poller["Submission poller"]
  node_daily_csv["Daily production CSV"]
  node_audit_csv["Production audit CSV"]
  node_poll_state["Poll state file"]
end

subgraph group_reporting["Dashboard reporting"]
  node_dashboard_renderer["Production section"]
  node_dashboard["RBF dashboard"]
end

node_employee(("Farm employee"))

node_employee -->|"enters reports"| node_pwa
node_pwa -->|"queues locally"| node_browser_storage
node_pwa -->|"submits records"| node_supabase
node_pwa -->|"registers worker"| node_offline_shell
node_offline_shell -->|"caches app shell"| node_offline_shell
node_production_schema -->|"defines tables"| node_supabase
node_supabase -->|"serves submissions"| node_poller
node_poller -->|"fetches records"| node_supabase
node_poller -->|"writes updates"| node_daily_csv
node_poller -->|"writes events"| node_audit_csv
node_poller -->|"saves polling state"| node_poll_state
node_daily_csv -->|"provides records"| node_dashboard_renderer
node_dashboard_renderer -->|"renders section"| node_dashboard
node_supabase -->|"audit-logs edits"| node_supabase

click node_pwa "https://github.com/mxthor34/rbf-daily-production/blob/main/web/app.js"
click node_offline_shell "https://github.com/mxthor34/rbf-daily-production/blob/main/web/sw.js"
click node_production_schema "https://github.com/mxthor34/rbf-daily-production/blob/main/supabase/migrations/20261202000000_create_production_tables.sql"
click node_poller "https://github.com/mxthor34/rbf-daily-production/blob/main/bridge/poll_submissions.py"
click node_dashboard_renderer "https://github.com/mxthor34/rbf-daily-production/blob/main/dashboard/production_section.py"

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_pwa,node_offline_shell,node_browser_storage toneBlue
class node_supabase,node_production_schema toneAmber
class node_poller,node_daily_csv,node_audit_csv,node_poll_state toneMint
class node_dashboard_renderer,node_dashboard toneRose
class node_employee toneIndigo
```

## Components

### Field capture

- [Entry PWA](https://github.com/mxthor34/rbf-daily-production/blob/main/web/app.js): `web/app.js`
- [Offline app shell](https://github.com/mxthor34/rbf-daily-production/blob/main/web/sw.js): `web/sw.js`
- **Browser local storage**

### Cloud records

- **Supabase**
- [Production schema](https://github.com/mxthor34/rbf-daily-production/blob/main/supabase/migrations/20261202000000_create_production_tables.sql): `supabase/migrations/20261202000000_create_production_tables.sql`

### Local bridge

- [Submission poller](https://github.com/mxthor34/rbf-daily-production/blob/main/bridge/poll_submissions.py): `bridge/poll_submissions.py`
- **Daily production CSV**
- **Production audit CSV**
- **Poll state file**

### Dashboard reporting

- [Production section](https://github.com/mxthor34/rbf-daily-production/blob/main/dashboard/production_section.py): `dashboard/production_section.py`
- **RBF dashboard**

### Other components

- **Farm employee**

## Connections

- Farm employee → Entry PWA: enters reports (evidence: `README.md`)
- Entry PWA → Browser local storage: queues locally (evidence: `web/app.js`)
- Entry PWA → Supabase: submits records (evidence: `web/app.js`)
- Entry PWA → Offline app shell: registers worker (evidence: `web/app.js`)
- Offline app shell → Offline app shell: caches app shell (evidence: `web/sw.js`)
- Production schema → Supabase: defines tables (evidence: `README.md`)
- Supabase → Submission poller: serves submissions (evidence: `README.md`)
- Submission poller → Supabase: fetches records (evidence: `bridge/poll_submissions.py`)
- Submission poller → Daily production CSV: writes updates (evidence: `bridge/poll_submissions.py`)
- Submission poller → Production audit CSV: writes events (evidence: `bridge/poll_submissions.py`)
- Submission poller → Poll state file: saves polling state (evidence: `bridge/poll_submissions.py`)
- Daily production CSV → Production section: provides records (evidence: `dashboard/production_section.py`)
- Production section → RBF dashboard: renders section (evidence: `README.md`)
- Supabase → Supabase: audit-logs edits (evidence: `README.md`)
