# vignesho6/synergy_forge architecture

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

- Interactive diagram: https://gitdiagram.com/vignesho6/synergy_forge
- Repository: https://github.com/vignesho6/synergy_forge

## Overview

ONION_GRADE is a Flutter onion-grading and procurement app backed by a FastAPI computer-vision service. The main workflow is to capture and upload onion samples, classify and grade them, then review reports and track batches; seller screens also support QR-based receipt checks and quality comparison. The backend pipeline explicitly coordinates detection and lot classification. The README and tree document additional app capabilities whose wiring is not shown in the sampled source, so those links are omitted.

Main entry points: [`ONION_GRADE/backend/api/analysis.py`](https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/backend/api/analysis.py) (Analysis routes), [`ONION_GRADE/backend/dl/deep_pipeline.py`](https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/backend/dl/deep_pipeline.py) (Grading pipeline), [`ONION_GRADE/lib/providers/batch_provider.dart`](https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/lib/providers/batch_provider.dart) (Batch state), [`ONION_GRADE/backend/main.py`](https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/backend/main.py) (FastAPI app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Flutter app"]
  node_capture_review["Capture and review"]
  node_procurement_results["Procurement results"]
  node_seller_flows["Seller workflows"]
  node_batch_state["Batch state"]
  node_analysis_state["Analysis state"]
  node_analysis_client["Analysis client"]
  node_batch_repository["Batch repository"]
end

subgraph group_api["Backend API"]
  node_backend_app["FastAPI app<br/>[main.py]"]
  node_analysis_routes["Analysis routes<br/>[analysis.py]"]
  node_auth_routes["Auth routes<br/>[auth.py]"]
end

subgraph group_vision["Image grading"]
  node_analysis_service["Analysis service"]
  node_deep_pipeline["Grading pipeline<br/>[deep_pipeline.py]"]
  node_yolo_detector["Onion detector<br/>[yolo_detector.py]"]
  node_mobilenet["Lot classifier"]
  node_model_registry["Model registry<br/>[model_loader.py]"]
end

subgraph group_identity["Identity and data"]
  node_auth_manager["Supabase auth manager<br/>[supabase_auth.py]"]
  node_supabase_db["Supabase data service<br/>[supabase_db.py]"]
end

node_procurement_user(("Procurement user"))
node_seller_user(("Seller"))
node_supabase[("Supabase")]

node_procurement_user -->|"captures samples"| node_capture_review
node_capture_review -->|"submits analysis"| node_analysis_state
node_analysis_state -->|"requests analysis"| node_analysis_client
node_analysis_client -->|"uploads images"| node_analysis_routes
node_analysis_routes --> node_analysis_service
node_analysis_service -->|"runs grading"| node_deep_pipeline
node_deep_pipeline -->|"detects bulbs"| node_yolo_detector
node_deep_pipeline -->|"classifies lot"| node_mobilenet
node_yolo_detector -->|"loads detector"| node_model_registry
node_mobilenet -->|"loads classifier"| node_model_registry
node_analysis_routes -->|"returns analysis"| node_procurement_results
node_procurement_user -->|"manages batches"| node_batch_state
node_batch_state -->|"uses repository"| node_batch_repository
node_batch_repository -->|"persists batches"| node_supabase_db
node_seller_user -->|"checks batch"| node_seller_flows
node_seller_flows -->|"views batch"| node_batch_state
node_backend_app -->|"mounts routes"| node_analysis_routes
node_backend_app -->|"mounts routes"| node_auth_routes
node_auth_routes -->|"validates tokens"| node_auth_manager
node_auth_manager -.->|"verifies identity"| node_supabase
node_supabase_db -->|"reads and writes"| node_supabase

click node_capture_review "https://github.com/vignesho6/synergy_forge/tree/main/ONION_GRADE/lib/screens/procurement"
click node_procurement_results "https://github.com/vignesho6/synergy_forge/tree/main/ONION_GRADE/lib/screens/procurement"
click node_seller_flows "https://github.com/vignesho6/synergy_forge/tree/main/ONION_GRADE/lib/screens/seller"
click node_batch_state "https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/lib/providers/batch_provider.dart"
click node_analysis_state "https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/lib/providers/analysis_provider.dart"
click node_analysis_client "https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/lib/services/api_analysis_service.dart"
click node_batch_repository "https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/lib/services/batch_repository.dart"
click node_backend_app "https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/backend/main.py"
click node_analysis_routes "https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/backend/api/analysis.py"
click node_auth_routes "https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/backend/api/auth.py"
click node_analysis_service "https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/backend/services/analysis_service.py"
click node_deep_pipeline "https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/backend/dl/deep_pipeline.py"
click node_yolo_detector "https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/backend/dl/yolo_detector.py"
click node_mobilenet "https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/backend/dl/mobilenet_classifier.py"
click node_model_registry "https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/backend/dl/model_loader.py"
click node_auth_manager "https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/backend/auth/supabase_auth.py"
click node_supabase_db "https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/backend/services/supabase_db.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_capture_review,node_procurement_results,node_seller_flows,node_batch_state,node_analysis_state,node_analysis_client,node_batch_repository,node_procurement_user toneBlue
class node_backend_app,node_analysis_routes,node_auth_routes,node_supabase toneAmber
class node_analysis_service,node_deep_pipeline,node_yolo_detector,node_mobilenet,node_model_registry toneMint
class node_auth_manager,node_supabase_db toneRose
class node_seller_user toneIndigo
```

## Components

### Flutter app

- [Capture and review](https://github.com/vignesho6/synergy_forge/tree/main/ONION_GRADE/lib/screens/procurement): `ONION_GRADE/lib/screens/procurement`
- [Procurement results](https://github.com/vignesho6/synergy_forge/tree/main/ONION_GRADE/lib/screens/procurement): `ONION_GRADE/lib/screens/procurement`
- [Seller workflows](https://github.com/vignesho6/synergy_forge/tree/main/ONION_GRADE/lib/screens/seller): `ONION_GRADE/lib/screens/seller`
- [Batch state](https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/lib/providers/batch_provider.dart): `ONION_GRADE/lib/providers/batch_provider.dart`
- [Analysis state](https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/lib/providers/analysis_provider.dart): `ONION_GRADE/lib/providers/analysis_provider.dart`
- [Analysis client](https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/lib/services/api_analysis_service.dart): `ONION_GRADE/lib/services/api_analysis_service.dart`
- [Batch repository](https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/lib/services/batch_repository.dart): `ONION_GRADE/lib/services/batch_repository.dart`

### Backend API

- [FastAPI app](https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/backend/main.py): `ONION_GRADE/backend/main.py`
- [Analysis routes](https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/backend/api/analysis.py): `ONION_GRADE/backend/api/analysis.py`
- [Auth routes](https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/backend/api/auth.py): `ONION_GRADE/backend/api/auth.py`

### Image grading

- [Analysis service](https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/backend/services/analysis_service.py): `ONION_GRADE/backend/services/analysis_service.py`
- [Grading pipeline](https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/backend/dl/deep_pipeline.py): `ONION_GRADE/backend/dl/deep_pipeline.py`
- [Onion detector](https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/backend/dl/yolo_detector.py): `ONION_GRADE/backend/dl/yolo_detector.py`
- [Lot classifier](https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/backend/dl/mobilenet_classifier.py): `ONION_GRADE/backend/dl/mobilenet_classifier.py`
- [Model registry](https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/backend/dl/model_loader.py): `ONION_GRADE/backend/dl/model_loader.py`

### Identity and data

- [Supabase auth manager](https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/backend/auth/supabase_auth.py): `ONION_GRADE/backend/auth/supabase_auth.py`
- [Supabase data service](https://github.com/vignesho6/synergy_forge/blob/main/ONION_GRADE/backend/services/supabase_db.py): `ONION_GRADE/backend/services/supabase_db.py`

### Other components

- **Procurement user**
- **Seller**
- **Supabase**

## Connections

- Procurement user → Capture and review: captures samples
- Capture and review → Analysis state: submits analysis
- Analysis state → Analysis client: requests analysis
- Analysis client → Analysis routes: uploads images
- Analysis routes → Analysis service
- Analysis service → Grading pipeline: runs grading
- Grading pipeline → Onion detector: detects bulbs
- Grading pipeline → Lot classifier: classifies lot
- Onion detector → Model registry: loads detector
- Lot classifier → Model registry: loads classifier
- Analysis routes → Procurement results: returns analysis
- Procurement user → Batch state: manages batches
- Batch state → Batch repository: uses repository
- Batch repository → Supabase data service: persists batches
- Seller → Seller workflows: checks batch
- Seller workflows → Batch state: views batch
- FastAPI app → Analysis routes: mounts routes
- FastAPI app → Auth routes: mounts routes
- Auth routes → Supabase auth manager: validates tokens
- Supabase auth manager → Supabase: verifies identity
- Supabase data service → Supabase: reads and writes
