# shreyadeshmukh1030/maizescan_lite architecture

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

- Interactive diagram: https://gitdiagram.com/shreyadeshmukh1030/maizescan_lite
- Repository: https://github.com/shreyadeshmukh1030/maizescan_lite

## Overview

#### Purpose and Entry Points
MaizeScan is a full-stack maize-seed visual-quality analysis system. A React/Vite client captures or uploads seed images; a FastAPI service runs detection, calculates batch quality, and persists inspection history. Primary entry points are `frontend/src/main.jsx`, `frontend/src/App.jsx`, and `backend/main.py`.

#### Frontend Application Shell
The SPA is organized around page-level workflows rather than a separate API-client layer visible in the tree. `frontend/src/App.jsx` defines the application shell/routing; `frontend/src/main.jsx` bootstraps React. Major user surfaces include detection (`frontend/src/pages/DetectionPage.jsx`), operational dashboard (`frontend/src/pages/DashboardPage.jsx`), and analytics (`frontend/src/pages/AnalyticsPage.jsx`).

#### Image Detection and Inference Boundary
The backend detection subsystem owns computer-vision processing and model invocation in `backend/detection.py`. Model material is bundled as `backend/seed_model.onnx`, indicating ONNX-runtime-compatible inference in the deployed backend rather than browser-side inference. The API boundary is FastAPI in `backend/main.py`: image input enters here, is passed to detection, and results are returned to the client for visualization and downstream reporting.

#### Batch Quality and Presentation
Detection output is expected to represent five quality categories and feed aggregate batch metrics/final grading described by the product. The detection UI consumes those results in `frontend/src/pages/DetectionPage.jsx`; map-oriented quality visualization is isolated in `frontend/src/components/QualityMap.jsx`. Reporting and certification are separate presentation workflows in `frontend/src/pages/ReportsPage.jsx` and `frontend/src/pages/CertificatePage.jsx`.

#### Persistence and Domain Model
Database connectivity/lifecycle is centralized in `backend/database.py`. Persistent entities are defined in `backend/models.py`, while API request/response contracts are defined in `backend/schemas.py`. This forms the primary boundary between FastAPI handlers and PostgreSQL/NeonDB persistence, supporting user-scoped batch history and dashboard aggregation.

#### User, History, and Analytics Workflows
Account entry flows are represented by `frontend/src/pages/LoginPage.jsx` and `frontend/src/pages/RegisterPage.jsx`; user-facing history/identity surfaces include `frontend/src/pages/ProfilePage.jsx`. Analytics are presented through `frontend/src/pages/AnalyticsPage.jsx`, while dashboard summaries live in `frontend/src/pages/DashboardPage.jsx`. The README specifies JWT authentication, so credentials and authenticated requests are an API concern rooted in `backend/main.py`.

#### Data Bootstrap and Deployment
Geographic/reference data can be initialized through `backend/seed_geo_data.py` (with a root-level `seed_geo_data.py` also present). Runtime dependencies are Python/FastAPI/SQLAlchemy plus ONNX/OpenCV-class vision dependencies in `backend/requirements.txt`, and React/Vite in `frontend/package.json`. Deployment is Vercel-oriented, with frontend routing/build configuration in `frontend/vercel.json`, plus root `Dockerfile` for containerized execution. External infrastructure includes PostgreSQL via NeonDB and Vercel hosting.

Main entry points: [`backend/main.py`](https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/backend/main.py) (FastAPI API), [`frontend/src/App.jsx`](https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/frontend/src/App.jsx) (App shell & routing), [`frontend/src/pages/DetectionPage.jsx`](https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/frontend/src/pages/DetectionPage.jsx) (Detection workflow), [`frontend/src/pages/DashboardPage.jsx`](https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/frontend/src/pages/DashboardPage.jsx) (Dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["React/Vite Client"]
  node_react_bootstrap["React bootstrap<br/>entry point<br/>[main.jsx]"]
  node_app_shell["App shell &amp; routing<br/>SPA routing<br/>[App.jsx]"]
  node_detection_ui["Detection workflow<br/>page<br/>[DetectionPage.jsx]"]
  node_quality_map["Quality map<br/>visualization component<br/>[QualityMap.jsx]"]
  node_dashboard_ui["Dashboard<br/>page<br/>[DashboardPage.jsx]"]
  node_analytics_ui["Analytics<br/>page<br/>[AnalyticsPage.jsx]"]
  node_reporting_ui["Reports &amp; certificates<br/>pages<br/>[ReportsPage.jsx]"]
  node_account_ui["Account &amp; profile<br/>pages<br/>[LoginPage.jsx]"]
end

subgraph group_backend["FastAPI Backend"]
  node_fastapi{{"FastAPI API<br/>service entry point<br/>[main.py]"}}
  node_contracts["API schemas<br/>request/response contracts<br/>[schemas.py]"]
  node_detection["Vision detection<br/>CV processing<br/>[detection.py]"]
  node_onnx_model["Seed ONNX model<br/>model artifact<br/>[seed_model.onnx]"]
  node_domain_models["Persistent domain models<br/>SQLAlchemy models<br/>[models.py]"]
  node_database_layer["Database lifecycle<br/>database access<br/>[database.py]"]
  node_geo_bootstrap["Geographic data bootstrap<br/>seed script<br/>[seed_geo_data.py]"]
end

subgraph group_infra["Deployment &amp; Data"]
  node_postgres[("NeonDB PostgreSQL<br/>managed database")]
  node_vercel["Vercel hosting<br/>deployment platform"]
  node_container["Container runtime<br/>Docker deployment"]
end

node_react_bootstrap -->|"mounts"| node_app_shell
node_app_shell -->|"routes to"| node_detection_ui
node_app_shell -->|"routes to"| node_dashboard_ui
node_app_shell -->|"routes to"| node_analytics_ui
node_app_shell -->|"routes to"| node_reporting_ui
node_app_shell -->|"routes to"| node_account_ui
node_detection_ui -->|"renders results"| node_quality_map
node_detection_ui -->|"uploads image"| node_fastapi
node_dashboard_ui -->|"loads summaries"| node_fastapi
node_analytics_ui -->|"loads history"| node_fastapi
node_reporting_ui -->|"requests reports"| node_fastapi
node_account_ui -->|"authenticates"| node_fastapi
node_fastapi -->|"validates and serializes"| node_contracts
node_fastapi -->|"submits image"| node_detection
node_detection -->|"runs inference"| node_onnx_model
node_fastapi -->|"reads and writes"| node_domain_models
node_domain_models -->|"uses"| node_database_layer
node_database_layer -->|"connects to"| node_postgres
node_geo_bootstrap -.->|"initializes reference data"| node_postgres
node_vercel -.->|"hosts client"| node_app_shell
node_container -.->|"runs backend"| node_fastapi

click node_react_bootstrap "https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/frontend/src/main.jsx"
click node_app_shell "https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/frontend/src/App.jsx"
click node_detection_ui "https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/frontend/src/pages/DetectionPage.jsx"
click node_quality_map "https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/frontend/src/components/QualityMap.jsx"
click node_dashboard_ui "https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/frontend/src/pages/DashboardPage.jsx"
click node_analytics_ui "https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/frontend/src/pages/AnalyticsPage.jsx"
click node_reporting_ui "https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/frontend/src/pages/ReportsPage.jsx"
click node_account_ui "https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/frontend/src/pages/LoginPage.jsx"
click node_fastapi "https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/backend/main.py"
click node_contracts "https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/backend/schemas.py"
click node_detection "https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/backend/detection.py"
click node_onnx_model "https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/backend/seed_model.onnx"
click node_domain_models "https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/backend/models.py"
click node_database_layer "https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/backend/database.py"
click node_geo_bootstrap "https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/backend/seed_geo_data.py"
click node_container "https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/Dockerfile"

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_react_bootstrap,node_app_shell,node_detection_ui,node_quality_map,node_dashboard_ui,node_analytics_ui,node_reporting_ui,node_account_ui toneBlue
class node_fastapi,node_contracts,node_detection,node_onnx_model,node_domain_models,node_database_layer,node_geo_bootstrap toneAmber
class node_postgres,node_vercel,node_container toneMint
```

## Components

### React/Vite Client

- [React bootstrap](https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/frontend/src/main.jsx): entry point · `frontend/src/main.jsx`
- [App shell & routing](https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/frontend/src/App.jsx): SPA routing · `frontend/src/App.jsx`
- [Detection workflow](https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/frontend/src/pages/DetectionPage.jsx): page · Captures or uploads seed images and displays results. · `frontend/src/pages/DetectionPage.jsx`
- [Quality map](https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/frontend/src/components/QualityMap.jsx): visualization component · `frontend/src/components/QualityMap.jsx`
- [Dashboard](https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/frontend/src/pages/DashboardPage.jsx): page · Presents operational batch summaries. · `frontend/src/pages/DashboardPage.jsx`
- [Analytics](https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/frontend/src/pages/AnalyticsPage.jsx): page · `frontend/src/pages/AnalyticsPage.jsx`
- [Reports & certificates](https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/frontend/src/pages/ReportsPage.jsx): pages · `frontend/src/pages/ReportsPage.jsx`
- [Account & profile](https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/frontend/src/pages/LoginPage.jsx): pages · Login, registration, and user history surfaces. · `frontend/src/pages/LoginPage.jsx`

### FastAPI Backend

- [FastAPI API](https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/backend/main.py): service entry point · Handles JWT-authenticated requests, image input, and API contracts. · `backend/main.py`
- [API schemas](https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/backend/schemas.py): request/response contracts · `backend/schemas.py`
- [Vision detection](https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/backend/detection.py): CV processing · Runs seed detection and derives five quality categories and batch metrics. · `backend/detection.py`
- [Seed ONNX model](https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/backend/seed_model.onnx): model artifact · `backend/seed_model.onnx`
- [Persistent domain models](https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/backend/models.py): SQLAlchemy models · Stores users and inspection/batch history. · `backend/models.py`
- [Database lifecycle](https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/backend/database.py): database access · `backend/database.py`
- [Geographic data bootstrap](https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/backend/seed_geo_data.py): seed script · `backend/seed_geo_data.py`

### Deployment & Data

- **NeonDB PostgreSQL**: managed database
- **Vercel hosting**: deployment platform
- [Container runtime](https://github.com/shreyadeshmukh1030/maizescan_lite/blob/main/Dockerfile): Docker deployment · `Dockerfile`

## Connections

- React bootstrap → App shell & routing: mounts
- App shell & routing → Detection workflow: routes to
- App shell & routing → Dashboard: routes to
- App shell & routing → Analytics: routes to
- App shell & routing → Reports & certificates: routes to
- App shell & routing → Account & profile: routes to
- Detection workflow → Quality map: renders results
- Detection workflow → FastAPI API: uploads image
- Dashboard → FastAPI API: loads summaries
- Analytics → FastAPI API: loads history
- Reports & certificates → FastAPI API: requests reports
- Account & profile → FastAPI API: authenticates
- FastAPI API → API schemas: validates and serializes
- FastAPI API → Vision detection: submits image
- Vision detection → Seed ONNX model: runs inference
- FastAPI API → Persistent domain models: reads and writes
- Persistent domain models → Database lifecycle: uses
- Database lifecycle → NeonDB PostgreSQL: connects to
- Geographic data bootstrap → NeonDB PostgreSQL: initializes reference data
- Vercel hosting → App shell & routing: hosts client
- Container runtime → FastAPI API: runs backend
