# vignesho6/onion-grader architecture

> Architecture diagram of the GitHub repository vignesho6/onion-grader, 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/onion-grader
- Repository: https://github.com/vignesho6/onion-grader

## Overview

Onion Quality AI is a farmer-facing onion grading application. Its documented workflow is to capture onion images, assess defects and size, estimate Grade A/URS proportions, and produce a quality report; authenticated routes also support farmer profiles and report history. The tree identifies separate analysis, reporting, and data modules, but their implementation and route-to-module calls were not sampled, so those links are not asserted. The sampled code confirms Supabase-backed authentication and client-side PDF generation.

Main entry points: [`src/integrations/supabase/client.ts`](https://github.com/vignesho6/onion-grader/blob/main/src/integrations/supabase/client.ts) (Supabase client), [`src/routes/auth.tsx`](https://github.com/vignesho6/onion-grader/blob/main/src/routes/auth.tsx) (Sign in), [`src/routes/_authenticated/route.tsx`](https://github.com/vignesho6/onion-grader/blob/main/src/routes/_authenticated/route.tsx) (Auth guard), [`src/lib/report-pdf.ts`](https://github.com/vignesho6/onion-grader/blob/main/src/lib/report-pdf.ts) (PDF export)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and app shell"]
  node_auth_page["Sign in<br/>[auth.tsx]"]
  node_auth_guard["Auth guard<br/>[route.tsx]"]
  node_app_shell["App shell<br/>[app-shell.tsx]"]
  node_farmer_profile["Farmer profile<br/>[profile.tsx]"]
  node_router["Application router<br/>[router.tsx]"]
end

subgraph group_grading["Image grading"]
  node_camera["Image capture<br/>[camera.tsx]"]
  node_vision["AI vision"]
  node_variety["Variety detection"]
  node_onion_logic["Onion grading<br/>[onion.server.ts]"]
  node_small_onion["Small onion grading"]
end

subgraph group_reports["Reports"]
  node_report_shape["Report model<br/>[report-shape.ts]"]
  node_report_view["Report display<br/>[report-view.tsx]"]
  node_report_list["Report history<br/>[reports.tsx]"]
  node_report_detail["Report detail<br/>[report.$id.tsx]"]
  node_pdf["PDF export<br/>[report-pdf.ts]"]
end

subgraph group_data["Supabase integration"]
  node_supabase_client["Supabase client<br/>[client.ts]"]
  node_supabase_admin["Admin client<br/>[client.server.ts]"]
  node_supabase[("Supabase")]
end

node_farmer(("Farmer"))

node_farmer -->|"signs in"| node_auth_page
node_auth_page -->|"authenticates"| node_supabase_client
node_auth_guard -->|"checks user"| node_supabase_client
node_supabase_client -->|"auth and data"| node_supabase
node_supabase_admin -.->|"admin access"| node_supabase
node_farmer -->|"captures images"| node_camera
node_farmer -->|"manages profile"| node_farmer_profile
node_farmer -->|"views reports"| node_report_list
node_farmer -->|"opens report"| node_report_detail
node_farmer -->|"exports report"| node_pdf
node_report_view -->|"formats verdict"| node_report_shape
node_pdf -->|"formats verdict"| node_report_shape
node_router -->|"routes access"| node_auth_guard

click node_auth_page "https://github.com/vignesho6/onion-grader/blob/main/src/routes/auth.tsx"
click node_auth_guard "https://github.com/vignesho6/onion-grader/blob/main/src/routes/_authenticated/route.tsx"
click node_app_shell "https://github.com/vignesho6/onion-grader/blob/main/src/components/app-shell.tsx"
click node_camera "https://github.com/vignesho6/onion-grader/blob/main/src/routes/_authenticated/camera.tsx"
click node_vision "https://github.com/vignesho6/onion-grader/blob/main/src/lib/ai-vision.server.ts"
click node_variety "https://github.com/vignesho6/onion-grader/blob/main/src/lib/variety-detect.server.ts"
click node_onion_logic "https://github.com/vignesho6/onion-grader/blob/main/src/lib/onion.server.ts"
click node_small_onion "https://github.com/vignesho6/onion-grader/blob/main/src/lib/small-onion.server.ts"
click node_report_shape "https://github.com/vignesho6/onion-grader/blob/main/src/lib/report-shape.ts"
click node_report_view "https://github.com/vignesho6/onion-grader/blob/main/src/components/report-view.tsx"
click node_report_list "https://github.com/vignesho6/onion-grader/blob/main/src/routes/_authenticated/reports.tsx"
click node_report_detail "https://github.com/vignesho6/onion-grader/blob/main/src/routes/_authenticated/report.%24id.tsx"
click node_pdf "https://github.com/vignesho6/onion-grader/blob/main/src/lib/report-pdf.ts"
click node_farmer_profile "https://github.com/vignesho6/onion-grader/blob/main/src/routes/_authenticated/profile.tsx"
click node_supabase_client "https://github.com/vignesho6/onion-grader/blob/main/src/integrations/supabase/client.ts"
click node_supabase_admin "https://github.com/vignesho6/onion-grader/blob/main/src/integrations/supabase/client.server.ts"
click node_router "https://github.com/vignesho6/onion-grader/blob/main/src/router.tsx"

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_page,node_auth_guard,node_app_shell,node_farmer_profile,node_router toneBlue
class node_camera,node_vision,node_variety,node_onion_logic,node_small_onion toneAmber
class node_report_shape,node_report_view,node_report_list,node_report_detail,node_pdf toneMint
class node_supabase_client,node_supabase_admin,node_supabase toneRose
class node_farmer toneIndigo
```

## Components

### Access and app shell

- [Sign in](https://github.com/vignesho6/onion-grader/blob/main/src/routes/auth.tsx): `src/routes/auth.tsx`
- [Auth guard](https://github.com/vignesho6/onion-grader/blob/main/src/routes/_authenticated/route.tsx): `src/routes/_authenticated/route.tsx`
- [App shell](https://github.com/vignesho6/onion-grader/blob/main/src/components/app-shell.tsx): `src/components/app-shell.tsx`
- [Farmer profile](https://github.com/vignesho6/onion-grader/blob/main/src/routes/_authenticated/profile.tsx): `src/routes/_authenticated/profile.tsx`
- [Application router](https://github.com/vignesho6/onion-grader/blob/main/src/router.tsx): `src/router.tsx`

### Image grading

- [Image capture](https://github.com/vignesho6/onion-grader/blob/main/src/routes/_authenticated/camera.tsx): `src/routes/_authenticated/camera.tsx`
- [AI vision](https://github.com/vignesho6/onion-grader/blob/main/src/lib/ai-vision.server.ts): `src/lib/ai-vision.server.ts`
- [Variety detection](https://github.com/vignesho6/onion-grader/blob/main/src/lib/variety-detect.server.ts): `src/lib/variety-detect.server.ts`
- [Onion grading](https://github.com/vignesho6/onion-grader/blob/main/src/lib/onion.server.ts): `src/lib/onion.server.ts`
- [Small onion grading](https://github.com/vignesho6/onion-grader/blob/main/src/lib/small-onion.server.ts): `src/lib/small-onion.server.ts`

### Reports

- [Report model](https://github.com/vignesho6/onion-grader/blob/main/src/lib/report-shape.ts): `src/lib/report-shape.ts`
- [Report display](https://github.com/vignesho6/onion-grader/blob/main/src/components/report-view.tsx): `src/components/report-view.tsx`
- [Report history](https://github.com/vignesho6/onion-grader/blob/main/src/routes/_authenticated/reports.tsx): `src/routes/_authenticated/reports.tsx`
- [Report detail](https://github.com/vignesho6/onion-grader/blob/main/src/routes/_authenticated/report.%24id.tsx): `src/routes/_authenticated/report.$id.tsx`
- [PDF export](https://github.com/vignesho6/onion-grader/blob/main/src/lib/report-pdf.ts): `src/lib/report-pdf.ts`

### Supabase integration

- [Supabase client](https://github.com/vignesho6/onion-grader/blob/main/src/integrations/supabase/client.ts): `src/integrations/supabase/client.ts`
- [Admin client](https://github.com/vignesho6/onion-grader/blob/main/src/integrations/supabase/client.server.ts): `src/integrations/supabase/client.server.ts`
- **Supabase**

### Other components

- **Farmer**

## Connections

- Farmer → Sign in: signs in
- Sign in → Supabase client: authenticates
- Auth guard → Supabase client: checks user
- Supabase client → Supabase: auth and data
- Admin client → Supabase: admin access
- Farmer → Image capture: captures images
- Farmer → Farmer profile: manages profile
- Farmer → Report history: views reports
- Farmer → Report detail: opens report
- Farmer → PDF export: exports report
- Report display → Report model: formats verdict
- PDF export → Report model: formats verdict
- Application router → Auth guard: routes access
