# sanhith2117s/phenopredictor architecture

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

## Overview

Pheno-Predict is a rice analytics web application for genomic trait prediction, leaf-disease diagnosis, and disease advice, with account access and saved histories. Users sign in, then upload SNP CSV data for trait results or leaf imagery for a diagnosis and guidance; they can review prediction history and charts. The frontend uses a Node/Express API for authentication and history, and a FastAPI service for ML capabilities. The README documents disease advisory and visualization features whose detailed wiring was not sampled, so those links are limited to documented service boundaries.

Main entry points: [`client/src/App.jsx`](https://github.com/sanhith2117s/phenopredictor/blob/main/client/src/App.jsx) (React app), [`client/src/api.js`](https://github.com/sanhith2117s/phenopredictor/blob/main/client/src/api.js) (HTTP client), [`server/ml_service/main.py`](https://github.com/sanhith2117s/phenopredictor/blob/main/server/ml_service/main.py) (Unified ML API), [`server/server.js`](https://github.com/sanhith2117s/phenopredictor/blob/main/server/server.js) (Express server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["React app<br/>[App.jsx]"]
  node_authui["Account screens<br/>[Login.jsx]"]
  node_traitui["Trait upload/results<br/>[TraitPredict.jsx]"]
  node_diseaseui["Disease diagnosis<br/>[PredictDisease.jsx]"]
  node_historyui["Disease history<br/>[DiseaseHistory.jsx]"]
  node_visualui["History charts<br/>[visualize.jsx]"]
  node_clientapi["HTTP client<br/>[api.js]"]
end

subgraph group_api["Backend API"]
  node_express["Express server<br/>[server.js]"]
  node_auth["Authentication routes<br/>[auth.js]"]
  node_traitapi["Trait history routes<br/>[prediction.js]"]
  node_diseaseapi["Disease history routes<br/>[diseases.js]"]
end

subgraph group_ml["ML services"]
  node_fastapi["Unified ML API<br/>[main.py]"]
  node_traitml["Genomic prediction<br/>[ml_service.py]"]
  node_diseaseml["Disease detection<br/>[disease_api.py]"]
  node_advisory["AI advisory<br/>[predict_with_hf.py]"]
  node_traitmodels["Trait models"]
  node_cnnmodel["Disease CNN<br/>[best_phase1.keras]"]
end

subgraph group_state["Persistence"]
  node_mongo[("MongoDB")]
  node_users[("User records<br/>[User.js]")]
  node_traitrecords[("Trait history records")]
  node_diseaserecords[("Disease history records<br/>[DiseaseHistory.js]")]
end

node_user(("Agriculture user"))
node_email["Email service"]
node_hf["HuggingFace API"]

node_user -->|"uses"| node_app
node_app -->|"routes to"| node_authui
node_app -->|"routes to"| node_traitui
node_app -->|"routes to"| node_diseaseui
node_app -->|"routes to"| node_historyui
node_app -->|"routes to"| node_visualui
node_authui -->|"requests auth"| node_clientapi
node_traitui -->|"requests prediction"| node_clientapi
node_diseaseui -->|"sends image"| node_clientapi
node_historyui -->|"requests history"| node_clientapi
node_visualui -->|"requests history"| node_clientapi
node_clientapi -->|"HTTP requests"| node_express
node_express -->|"dispatches auth"| node_auth
node_express -->|"dispatches traits"| node_traitapi
node_express -->|"dispatches disease"| node_diseaseapi
node_auth -->|"reads/writes"| node_users
node_auth -->|"sends verification"| node_email
node_traitapi -->|"reads/writes"| node_traitrecords
node_diseaseapi -->|"reads/writes"| node_diseaserecords
node_traitrecords -->|"persists in"| node_mongo
node_diseaserecords -->|"persists in"| node_mongo
node_users -->|"persists in"| node_mongo
node_traitui -->|"uploads CSV"| node_fastapi
node_diseaseui -->|"uploads image"| node_fastapi
node_fastapi -->|"dispatches traits"| node_traitml
node_fastapi -->|"dispatches diagnosis"| node_diseaseml
node_fastapi -->|"dispatches advisory"| node_advisory
node_traitml -->|"loads models"| node_traitmodels
node_diseaseml -->|"loads model"| node_cnnmodel
node_advisory -.->|"requests inference"| node_hf

click node_app "https://github.com/sanhith2117s/phenopredictor/blob/main/client/src/App.jsx"
click node_authui "https://github.com/sanhith2117s/phenopredictor/blob/main/client/src/Components/Login.jsx"
click node_traitui "https://github.com/sanhith2117s/phenopredictor/blob/main/client/src/Components/TraitPredict.jsx"
click node_diseaseui "https://github.com/sanhith2117s/phenopredictor/blob/main/client/src/Components/PredictDisease.jsx"
click node_historyui "https://github.com/sanhith2117s/phenopredictor/blob/main/client/src/Components/DiseaseHistory.jsx"
click node_visualui "https://github.com/sanhith2117s/phenopredictor/blob/main/client/src/Components/visualize.jsx"
click node_clientapi "https://github.com/sanhith2117s/phenopredictor/blob/main/client/src/api.js"
click node_express "https://github.com/sanhith2117s/phenopredictor/blob/main/server/server.js"
click node_auth "https://github.com/sanhith2117s/phenopredictor/blob/main/server/routes/auth.js"
click node_traitapi "https://github.com/sanhith2117s/phenopredictor/blob/main/server/routes/prediction.js"
click node_diseaseapi "https://github.com/sanhith2117s/phenopredictor/blob/main/server/routes/diseases.js"
click node_fastapi "https://github.com/sanhith2117s/phenopredictor/blob/main/server/ml_service/main.py"
click node_traitml "https://github.com/sanhith2117s/phenopredictor/blob/main/server/ml_service/ml_service.py"
click node_diseaseml "https://github.com/sanhith2117s/phenopredictor/blob/main/server/ml_service/disease_api.py"
click node_advisory "https://github.com/sanhith2117s/phenopredictor/blob/main/server/ml_service/predict_with_hf.py"
click node_traitmodels "https://github.com/sanhith2117s/phenopredictor/tree/main/server/ml_service/multi_trait_models"
click node_cnnmodel "https://github.com/sanhith2117s/phenopredictor/blob/main/server/ml_service/best_phase1.keras"
click node_users "https://github.com/sanhith2117s/phenopredictor/blob/main/server/models/User.js"
click node_traitrecords "https://github.com/sanhith2117s/phenopredictor/blob/main/server/models/PredictionHistory.js"
click node_diseaserecords "https://github.com/sanhith2117s/phenopredictor/blob/main/server/models/DiseaseHistory.js"

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_authui,node_traitui,node_diseaseui,node_historyui,node_visualui,node_clientapi,node_user toneBlue
class node_express,node_auth,node_traitapi,node_diseaseapi toneAmber
class node_fastapi,node_traitml,node_diseaseml,node_advisory,node_traitmodels,node_cnnmodel,node_hf toneMint
class node_mongo,node_users,node_traitrecords,node_diseaserecords toneRose
class node_email toneIndigo
```

## Components

### Web application

- [React app](https://github.com/sanhith2117s/phenopredictor/blob/main/client/src/App.jsx): `client/src/App.jsx`
- [Account screens](https://github.com/sanhith2117s/phenopredictor/blob/main/client/src/Components/Login.jsx): `client/src/Components/Login.jsx`
- [Trait upload/results](https://github.com/sanhith2117s/phenopredictor/blob/main/client/src/Components/TraitPredict.jsx): `client/src/Components/TraitPredict.jsx`
- [Disease diagnosis](https://github.com/sanhith2117s/phenopredictor/blob/main/client/src/Components/PredictDisease.jsx): `client/src/Components/PredictDisease.jsx`
- [Disease history](https://github.com/sanhith2117s/phenopredictor/blob/main/client/src/Components/DiseaseHistory.jsx): `client/src/Components/DiseaseHistory.jsx`
- [History charts](https://github.com/sanhith2117s/phenopredictor/blob/main/client/src/Components/visualize.jsx): `client/src/Components/visualize.jsx`
- [HTTP client](https://github.com/sanhith2117s/phenopredictor/blob/main/client/src/api.js): `client/src/api.js`

### Backend API

- [Express server](https://github.com/sanhith2117s/phenopredictor/blob/main/server/server.js): `server/server.js`
- [Authentication routes](https://github.com/sanhith2117s/phenopredictor/blob/main/server/routes/auth.js): `server/routes/auth.js`
- [Trait history routes](https://github.com/sanhith2117s/phenopredictor/blob/main/server/routes/prediction.js): `server/routes/prediction.js`
- [Disease history routes](https://github.com/sanhith2117s/phenopredictor/blob/main/server/routes/diseases.js): `server/routes/diseases.js`

### ML services

- [Unified ML API](https://github.com/sanhith2117s/phenopredictor/blob/main/server/ml_service/main.py): `server/ml_service/main.py`
- [Genomic prediction](https://github.com/sanhith2117s/phenopredictor/blob/main/server/ml_service/ml_service.py): `server/ml_service/ml_service.py`
- [Disease detection](https://github.com/sanhith2117s/phenopredictor/blob/main/server/ml_service/disease_api.py): `server/ml_service/disease_api.py`
- [AI advisory](https://github.com/sanhith2117s/phenopredictor/blob/main/server/ml_service/predict_with_hf.py): `server/ml_service/predict_with_hf.py`
- [Trait models](https://github.com/sanhith2117s/phenopredictor/tree/main/server/ml_service/multi_trait_models): `server/ml_service/multi_trait_models`
- [Disease CNN](https://github.com/sanhith2117s/phenopredictor/blob/main/server/ml_service/best_phase1.keras): `server/ml_service/best_phase1.keras`

### Persistence

- **MongoDB**
- [User records](https://github.com/sanhith2117s/phenopredictor/blob/main/server/models/User.js): `server/models/User.js`
- [Trait history records](https://github.com/sanhith2117s/phenopredictor/blob/main/server/models/PredictionHistory.js): `server/models/PredictionHistory.js`
- [Disease history records](https://github.com/sanhith2117s/phenopredictor/blob/main/server/models/DiseaseHistory.js): `server/models/DiseaseHistory.js`

### Other components

- **Agriculture user**
- **Email service**
- **HuggingFace API**

## Connections

- Agriculture user → React app: uses
- React app → Account screens: routes to
- React app → Trait upload/results: routes to
- React app → Disease diagnosis: routes to
- React app → Disease history: routes to
- React app → History charts: routes to
- Account screens → HTTP client: requests auth
- Trait upload/results → HTTP client: requests prediction
- Disease diagnosis → HTTP client: sends image
- Disease history → HTTP client: requests history
- History charts → HTTP client: requests history
- HTTP client → Express server: HTTP requests
- Express server → Authentication routes: dispatches auth
- Express server → Trait history routes: dispatches traits
- Express server → Disease history routes: dispatches disease
- Authentication routes → User records: reads/writes
- Authentication routes → Email service: sends verification
- Trait history routes → Trait history records: reads/writes
- Disease history routes → Disease history records: reads/writes
- Trait history records → MongoDB: persists in
- Disease history records → MongoDB: persists in
- User records → MongoDB: persists in
- Trait upload/results → Unified ML API: uploads CSV
- Disease diagnosis → Unified ML API: uploads image
- Unified ML API → Genomic prediction: dispatches traits
- Unified ML API → Disease detection: dispatches diagnosis
- Unified ML API → AI advisory: dispatches advisory
- Genomic prediction → Trait models: loads models
- Disease detection → Disease CNN: loads model
- AI advisory → HuggingFace API: requests inference
