# gestaupcompany/caderneta-digital-gesta-up architecture

> Architecture diagram of the GitHub repository gestaupcompany/caderneta-digital-gesta-up, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/gestaupcompany/caderneta-digital-gesta-up
- Repository: https://github.com/gestaupcompany/caderneta-digital-gesta-up

## Overview

Gesta’Up is an offline-first farm-field PWA for recording production data and syncing it to Supabase when connectivity returns. The primary workflow is peão access, navigation to a caderneta, local-first entry, queued synchronization, and review of sync status or conflicts. The app also exposes reports, inventory, checklists, routines, and farm maps. The README documents the sync architecture; most individual screens and services were not sampled, so edges for documented but unsampled behavior cite the README rather than implying source inspection.

Main entry points: [`frontend/src/services/indexedDB.ts`](https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/services/indexedDB.ts) (Sync queue), [`frontend/src/App.tsx`](https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/App.tsx) (App routes), [`frontend/src/pages/Home.tsx`](https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/pages/Home.tsx) (Farm home), [`frontend/src/pages/cadernetas`](https://github.com/gestaupcompany/caderneta-digital-gesta-up/tree/master/frontend/src/pages/cadernetas) (Caderneta forms)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["PWA shell"]
  node_app["App routes<br/>[App.tsx]"]
  node_home["Farm home<br/>[Home.tsx]"]
  node_auth["Peão authentication<br/>[authService.ts]"]
end

subgraph group_records["Field records"]
  node_forms["Caderneta forms"]
  node_maternidade["Birth records"]
  node_movimentacao["Herd movements"]
  node_pastagens["Pasture management<br/>[PastagensPage.tsx]"]
  node_rodeio["Herd records<br/>[RodeioPage.tsx]"]
  node_suplementacao["Supplement records"]
  node_bebedouros["Water records<br/>[BebedourosPage.tsx]"]
  node_lists["Record lists"]
end

subgraph group_data["Offline and cloud data"]
  node_queue["Sync queue<br/>[indexedDB.ts]"]
  node_sync["Sync worker<br/>[useSync.ts]"]
  node_syncservice["Supabase sync<br/>[syncService.ts]"]
  node_cache[("Cadastro cache<br/>[cadastroCache.ts]")]
  node_supabaseaccess["Supabase data access<br/>[supabaseService.ts]"]
end

subgraph group_farm["Farm operations"]
  node_inventory["Inventory screens"]
  node_reports["Herd reports"]
  node_checklists["Checklist rules"]
  node_routines["Farm routines<br/>[rotinasService.ts]"]
  node_map["Farm map"]
end

subgraph group_legacy["Legacy services"]
  node_backend["Legacy API<br/>[app.ts]"]
  node_legacylogin["Legacy peão login<br/>[authController.ts]"]
  node_version["Version endpoint"]
end

node_peao(("Field worker"))
node_supabase[("Supabase")]

node_peao -->|"uses"| node_app
node_app -->|"routes"| node_home
node_app -->|"routes"| node_forms
node_app -->|"reauthenticates via"| node_auth
node_peao -->|"authenticates"| node_auth
node_forms -->|"writes pending entries"| node_queue
node_maternidade -->|"queues entries"| node_queue
node_movimentacao -->|"queues entries"| node_queue
node_pastagens -->|"queues entries"| node_queue
node_rodeio -->|"queues entries"| node_queue
node_suplementacao -->|"queues entries"| node_queue
node_bebedouros -->|"queues entries"| node_queue
node_sync -->|"drains"| node_queue
node_sync -->|"syncs each item"| node_syncservice
node_syncservice -->|"inserts or updates"| node_supabase
node_syncservice -->|"logs failures"| node_supabase
node_forms -->|"paired with"| node_lists
node_home -.->|"opens reports"| node_reports
node_home -.->|"opens modules"| node_inventory
node_app -->|"preloads rules"| node_checklists
node_home -.->|"accesses"| node_routines
node_home -.->|"opens"| node_map
node_supabaseaccess -->|"queries farm data"| node_supabase
node_cache -.->|"caches cadastro data"| node_supabaseaccess
node_backend -->|"mounts auth route"| node_legacylogin
node_backend -->|"mounts version route"| node_version

click node_app "https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/App.tsx"
click node_home "https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/pages/Home.tsx"
click node_auth "https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/services/authService.ts"
click node_forms "https://github.com/gestaupcompany/caderneta-digital-gesta-up/tree/master/frontend/src/pages/cadernetas"
click node_maternidade "https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/pages/cadernetas/MaternidadePage.tsx"
click node_movimentacao "https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/pages/cadernetas/MovimentacaoPage.tsx"
click node_pastagens "https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/pages/cadernetas/PastagensPage.tsx"
click node_rodeio "https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/pages/cadernetas/RodeioPage.tsx"
click node_suplementacao "https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/pages/cadernetas/SuplementacaoPage.tsx"
click node_bebedouros "https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/pages/cadernetas/BebedourosPage.tsx"
click node_lists "https://github.com/gestaupcompany/caderneta-digital-gesta-up/tree/master/frontend/src/pages/cadernetas"
click node_inventory "https://github.com/gestaupcompany/caderneta-digital-gesta-up/tree/master/frontend/src/pages/estoque-insumos"
click node_reports "https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/pages/RelatorioLotePage.tsx"
click node_checklists "https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/services/checklistRegrasService.ts"
click node_routines "https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/services/rotinasService.ts"
click node_map "https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/pages/MapaFazendaPage.tsx"
click node_queue "https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/services/indexedDB.ts"
click node_sync "https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/hooks/useSync.ts"
click node_syncservice "https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/services/syncService.ts"
click node_cache "https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/services/cadastroCache.ts"
click node_supabaseaccess "https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/services/supabaseService.ts"
click node_backend "https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/backend/src/app.ts"
click node_legacylogin "https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/backend/src/controllers/authController.ts"
click node_version "https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/backend/src/controllers/versionController.ts"

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_app,node_home,node_auth toneBlue
class node_forms,node_maternidade,node_movimentacao,node_pastagens,node_rodeio,node_suplementacao,node_bebedouros,node_lists,node_supabase toneAmber
class node_queue,node_sync,node_syncservice,node_cache,node_supabaseaccess toneMint
class node_inventory,node_reports,node_checklists,node_routines,node_map,node_peao toneRose
class node_backend,node_legacylogin,node_version toneIndigo
```

## Components

### PWA shell

- [App routes](https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Farm home](https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/pages/Home.tsx): `frontend/src/pages/Home.tsx`
- [Peão authentication](https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/services/authService.ts): `frontend/src/services/authService.ts`

### Field records

- [Caderneta forms](https://github.com/gestaupcompany/caderneta-digital-gesta-up/tree/master/frontend/src/pages/cadernetas): `frontend/src/pages/cadernetas`
- [Birth records](https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/pages/cadernetas/MaternidadePage.tsx): `frontend/src/pages/cadernetas/MaternidadePage.tsx`
- [Herd movements](https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/pages/cadernetas/MovimentacaoPage.tsx): `frontend/src/pages/cadernetas/MovimentacaoPage.tsx`
- [Pasture management](https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/pages/cadernetas/PastagensPage.tsx): `frontend/src/pages/cadernetas/PastagensPage.tsx`
- [Herd records](https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/pages/cadernetas/RodeioPage.tsx): `frontend/src/pages/cadernetas/RodeioPage.tsx`
- [Supplement records](https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/pages/cadernetas/SuplementacaoPage.tsx): `frontend/src/pages/cadernetas/SuplementacaoPage.tsx`
- [Water records](https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/pages/cadernetas/BebedourosPage.tsx): `frontend/src/pages/cadernetas/BebedourosPage.tsx`
- [Record lists](https://github.com/gestaupcompany/caderneta-digital-gesta-up/tree/master/frontend/src/pages/cadernetas): `frontend/src/pages/cadernetas`

### Offline and cloud data

- [Sync queue](https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/services/indexedDB.ts): `frontend/src/services/indexedDB.ts`
- [Sync worker](https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/hooks/useSync.ts): `frontend/src/hooks/useSync.ts`
- [Supabase sync](https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/services/syncService.ts): `frontend/src/services/syncService.ts`
- [Cadastro cache](https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/services/cadastroCache.ts): `frontend/src/services/cadastroCache.ts`
- [Supabase data access](https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/services/supabaseService.ts): `frontend/src/services/supabaseService.ts`

### Farm operations

- [Inventory screens](https://github.com/gestaupcompany/caderneta-digital-gesta-up/tree/master/frontend/src/pages/estoque-insumos): `frontend/src/pages/estoque-insumos`
- [Herd reports](https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/pages/RelatorioLotePage.tsx): `frontend/src/pages/RelatorioLotePage.tsx`
- [Checklist rules](https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/services/checklistRegrasService.ts): `frontend/src/services/checklistRegrasService.ts`
- [Farm routines](https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/services/rotinasService.ts): `frontend/src/services/rotinasService.ts`
- [Farm map](https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/frontend/src/pages/MapaFazendaPage.tsx): `frontend/src/pages/MapaFazendaPage.tsx`

### Legacy services

- [Legacy API](https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/backend/src/app.ts): `backend/src/app.ts`
- [Legacy peão login](https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/backend/src/controllers/authController.ts): `backend/src/controllers/authController.ts`
- [Version endpoint](https://github.com/gestaupcompany/caderneta-digital-gesta-up/blob/master/backend/src/controllers/versionController.ts): `backend/src/controllers/versionController.ts`

### Other components

- **Field worker**
- **Supabase**

## Connections

- Field worker → App routes: uses
- App routes → Farm home: routes (evidence: `frontend/src/App.tsx`)
- App routes → Caderneta forms: routes (evidence: `frontend/src/App.tsx`)
- App routes → Peão authentication: reauthenticates via (evidence: `frontend/src/App.tsx`)
- Field worker → Peão authentication: authenticates
- Caderneta forms → Sync queue: writes pending entries
- Birth records → Sync queue: queues entries
- Herd movements → Sync queue: queues entries
- Pasture management → Sync queue: queues entries
- Herd records → Sync queue: queues entries
- Supplement records → Sync queue: queues entries
- Water records → Sync queue: queues entries
- Sync worker → Sync queue: drains
- Sync worker → Supabase sync: syncs each item
- Supabase sync → Supabase: inserts or updates
- Supabase sync → Supabase: logs failures
- Caderneta forms → Record lists: paired with
- Farm home → Herd reports: opens reports
- Farm home → Inventory screens: opens modules
- App routes → Checklist rules: preloads rules (evidence: `frontend/src/App.tsx`)
- Farm home → Farm routines: accesses
- Farm home → Farm map: opens
- Supabase data access → Supabase: queries farm data (evidence: `frontend/src/services/supabaseService.ts`)
- Cadastro cache → Supabase data access: caches cadastro data
- Legacy API → Legacy peão login: mounts auth route (evidence: `backend/src/app.ts`)
- Legacy API → Version endpoint: mounts version route (evidence: `backend/src/app.ts`)
