# katefaithritcha-png/egg-system architecture

> Architecture diagram of the GitHub repository katefaithritcha-png/egg-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/katefaithritcha-png/egg-system
- Repository: https://github.com/katefaithritcha-png/egg-system

## Overview

Egg System combines a Flutter farm interface with a farm-PC inspection and classification backend, exposed through Cloudflare. The documented user journey is staff access the UI, authenticate, and use farm workflows; camera/classification work remains on the farm PC. The tree does not include Flutter application source, so the UI’s internal routes and their backend calls cannot be mapped precisely. The graph retains documented product capabilities and sampled backend dependencies; unsampled implementation details are omitted rather than inferred.

Main entry points: [`backend/live_inspection_backend.py`](https://github.com/katefaithritcha-png/egg-system/blob/main/backend/live_inspection_backend.py) (Inspection backend), [`backend/auth.py`](https://github.com/katefaithritcha-png/egg-system/blob/main/backend/auth.py) (Accounts and sessions), [`backend/farm_store.py`](https://github.com/katefaithritcha-png/egg-system/blob/main/backend/farm_store.py) (Farm ledger storage), [`deploy/cloudflare/src/worker.js`](https://github.com/katefaithritcha-png/egg-system/blob/main/deploy/cloudflare/src/worker.js) (Cloudflare Worker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and identity"]
  node_auth_server["Auth server<br/>[auth_server.py]"]
  node_auth["Accounts and sessions<br/>[auth.py]"]
  node_sms["SMS delivery<br/>[philsms.py]"]
end

subgraph group_farm_data["Farm records"]
  node_farm_store[("Farm ledger storage<br/>[farm_store.py]")]
  node_firebase_store[("Firebase access<br/>[firebase_store.py]")]
  node_egg_sync["Egg synchronization<br/>[egg_sync.py]"]
end

subgraph group_inspection["Inspection and detection"]
  node_farm_gateway["Farm API gateway<br/>[farm_gateway.py]"]
  node_inspection_backend["Inspection backend"]
  node_inspection_client["Live inspection<br/>[live_inspection.py]"]
  node_quality_relay["Egg quality relay"]
  node_runtime_log["Runtime logging<br/>[runtime_log.py]"]
  node_roboflow["Roboflow detection<br/>[roboflow_egg.py]"]
end

subgraph group_edge["Public access"]
  node_cloudflare["Cloudflare Worker<br/>[worker.js]"]
end

node_staff(("Farm staff"))
node_farm_ui["Farm UI"]

node_staff -->|"uses"| node_farm_ui
node_farm_ui -->|"accesses UI"| node_cloudflare
node_farm_ui -->|"accesses farm API"| node_cloudflare
node_cloudflare -.->|"routes farm API"| node_farm_gateway
node_farm_gateway -.-> node_inspection_backend
node_auth_server -->|"initializes"| node_auth
node_auth_server -.->|"serves authentication"| node_farm_ui
node_auth -->|"uses storage"| node_farm_store
node_auth -->|"uses SMS"| node_sms
node_farm_store -->|"uses Firebase"| node_firebase_store
node_egg_sync -->|"uses storage"| node_farm_store
node_inspection_client -.->|"connects to"| node_inspection_backend
node_inspection_backend -.-> node_quality_relay
node_quality_relay -->|"logs events"| node_runtime_log
node_inspection_backend -.-> node_roboflow

click node_cloudflare "https://github.com/katefaithritcha-png/egg-system/blob/main/deploy/cloudflare/src/worker.js"
click node_auth_server "https://github.com/katefaithritcha-png/egg-system/blob/main/backend/auth_server.py"
click node_auth "https://github.com/katefaithritcha-png/egg-system/blob/main/backend/auth.py"
click node_sms "https://github.com/katefaithritcha-png/egg-system/blob/main/backend/philsms.py"
click node_farm_store "https://github.com/katefaithritcha-png/egg-system/blob/main/backend/farm_store.py"
click node_firebase_store "https://github.com/katefaithritcha-png/egg-system/blob/main/backend/firebase_store.py"
click node_egg_sync "https://github.com/katefaithritcha-png/egg-system/blob/main/backend/egg_sync.py"
click node_farm_gateway "https://github.com/katefaithritcha-png/egg-system/blob/main/backend/farm_gateway.py"
click node_inspection_backend "https://github.com/katefaithritcha-png/egg-system/blob/main/backend/live_inspection_backend.py"
click node_inspection_client "https://github.com/katefaithritcha-png/egg-system/blob/main/live_inspection.py"
click node_quality_relay "https://github.com/katefaithritcha-png/egg-system/blob/main/backend/egg_quality_relay.py"
click node_runtime_log "https://github.com/katefaithritcha-png/egg-system/blob/main/backend/runtime_log.py"
click node_roboflow "https://github.com/katefaithritcha-png/egg-system/blob/main/backend/roboflow_egg.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_auth_server,node_auth,node_sms,node_farm_ui toneBlue
class node_farm_store,node_firebase_store,node_egg_sync toneAmber
class node_farm_gateway,node_inspection_backend,node_inspection_client,node_quality_relay,node_runtime_log,node_roboflow toneMint
class node_cloudflare toneRose
class node_staff toneIndigo
```

## Components

### Access and identity

- [Auth server](https://github.com/katefaithritcha-png/egg-system/blob/main/backend/auth_server.py): `backend/auth_server.py`
- [Accounts and sessions](https://github.com/katefaithritcha-png/egg-system/blob/main/backend/auth.py): `backend/auth.py`
- [SMS delivery](https://github.com/katefaithritcha-png/egg-system/blob/main/backend/philsms.py): `backend/philsms.py`

### Farm records

- [Farm ledger storage](https://github.com/katefaithritcha-png/egg-system/blob/main/backend/farm_store.py): `backend/farm_store.py`
- [Firebase access](https://github.com/katefaithritcha-png/egg-system/blob/main/backend/firebase_store.py): `backend/firebase_store.py`
- [Egg synchronization](https://github.com/katefaithritcha-png/egg-system/blob/main/backend/egg_sync.py): `backend/egg_sync.py`

### Inspection and detection

- [Farm API gateway](https://github.com/katefaithritcha-png/egg-system/blob/main/backend/farm_gateway.py): `backend/farm_gateway.py`
- [Inspection backend](https://github.com/katefaithritcha-png/egg-system/blob/main/backend/live_inspection_backend.py): `backend/live_inspection_backend.py`
- [Live inspection](https://github.com/katefaithritcha-png/egg-system/blob/main/live_inspection.py): `live_inspection.py`
- [Egg quality relay](https://github.com/katefaithritcha-png/egg-system/blob/main/backend/egg_quality_relay.py): `backend/egg_quality_relay.py`
- [Runtime logging](https://github.com/katefaithritcha-png/egg-system/blob/main/backend/runtime_log.py): `backend/runtime_log.py`
- [Roboflow detection](https://github.com/katefaithritcha-png/egg-system/blob/main/backend/roboflow_egg.py): `backend/roboflow_egg.py`

### Public access

- [Cloudflare Worker](https://github.com/katefaithritcha-png/egg-system/blob/main/deploy/cloudflare/src/worker.js): `deploy/cloudflare/src/worker.js`

### Other components

- **Farm staff**
- **Farm UI**

## Connections

- Farm staff → Farm UI: uses
- Farm UI → Cloudflare Worker: accesses UI
- Farm UI → Cloudflare Worker: accesses farm API
- Cloudflare Worker → Farm API gateway: routes farm API
- Farm API gateway → Inspection backend
- Auth server → Accounts and sessions: initializes (evidence: `backend/auth_server.py`)
- Auth server → Farm UI: serves authentication
- Accounts and sessions → Farm ledger storage: uses storage (evidence: `backend/auth.py`)
- Accounts and sessions → SMS delivery: uses SMS (evidence: `backend/auth.py`)
- Farm ledger storage → Firebase access: uses Firebase (evidence: `backend/farm_store.py`)
- Egg synchronization → Farm ledger storage: uses storage (evidence: `backend/egg_sync.py`)
- Live inspection → Inspection backend: connects to
- Inspection backend → Egg quality relay
- Egg quality relay → Runtime logging: logs events (evidence: `backend/egg_quality_relay.py`)
- Inspection backend → Roboflow detection
