# mjsaidhanush/sfa-project architecture

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

- Interactive diagram: https://gitdiagram.com/mjsaidhanush/sfa-project
- Repository: https://github.com/mjsaidhanush/sfa-project

## Overview

Smart Farm Assistant is a farmer-facing web platform combining account access, agricultural guidance, and marketplace and government-scheme discovery, with an admin portal. The main user journey runs from sign-in or registration into the dashboard, where users can request crop and weather predictions or explore other services. The sampled pages show direct crop and weather requests to the ML service; the README documents broader platform capabilities. Some unsampled integrations and the disease-analysis implementation are represented conservatively, with evidence limits noted by dashed edges.

Main entry points: [`frontend/app/dashboard/page.tsx`](https://github.com/mjsaidhanush/sfa-project/blob/main/frontend/app/dashboard/page.tsx) (Dashboard), [`backend/server.js`](https://github.com/mjsaidhanush/sfa-project/blob/main/backend/server.js) (Backend API), [`frontend/app/page.tsx`](https://github.com/mjsaidhanush/sfa-project/blob/main/frontend/app/page.tsx) (Sign In), [`backend/adminRoutes.js`](https://github.com/mjsaidhanush/sfa-project/blob/main/backend/adminRoutes.js) (Admin Management API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Farmer Web App"]
  node_entry["Sign In<br/>[page.tsx]"]
  node_registration["Registration<br/>[page.tsx]"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
  node_market["Marketplace<br/>[page.tsx]"]
  node_schemes["Schemes Discovery<br/>[page.tsx]"]
  node_chatbot["Farm Chatbot<br/>[page.tsx]"]
end

subgraph group_services["Platform Services"]
  node_api_server["Backend API<br/>[server.js]"]
  node_auth["Authentication<br/>[auth.js]"]
  node_user_model[("User Accounts<br/>[User.js]")]
  node_database[("MongoDB Connection<br/>[db.js]")]
end

subgraph group_intelligence["AI Guidance"]
  node_crop_ui["Crop Recommendation UI<br/>[page.tsx]"]
  node_weather_ui["Weather &amp; Rain UI<br/>[page.tsx]"]
  node_disease_ui["Disease Detection UI<br/>[page.tsx]"]
  node_ml_service["ML Inference Service"]
end

subgraph group_admin["Administration"]
  node_admin_ui["Admin Portal<br/>[page.tsx]"]
  node_admin_routes["Admin Management API<br/>[adminRoutes.js]"]
end

node_farmer(("Farmer"))

node_farmer -->|"signs in"| node_entry
node_farmer -->|"registers"| node_registration
node_entry -.->|"enters"| node_dashboard
node_dashboard -.->|"opens"| node_crop_ui
node_dashboard -.->|"opens"| node_weather_ui
node_dashboard -.->|"opens"| node_disease_ui
node_dashboard -.->|"opens"| node_market
node_dashboard -.->|"opens"| node_schemes
node_dashboard -.->|"opens"| node_chatbot
node_crop_ui -->|"requests prediction"| node_ml_service
node_weather_ui -->|"requests forecast"| node_ml_service
node_disease_ui -.->|"analyzes image"| node_ml_service
node_entry -.->|"authenticates"| node_api_server
node_registration -.->|"creates account"| node_api_server
node_api_server -->|"routes auth"| node_auth
node_api_server -->|"routes admin"| node_admin_routes
node_api_server -->|"connects"| node_database
node_auth -->|"reads and updates"| node_user_model
node_admin_routes -->|"queries users"| node_user_model
node_admin_ui -.->|"manages resources"| node_admin_routes

click node_entry "https://github.com/mjsaidhanush/sfa-project/blob/main/frontend/app/page.tsx"
click node_registration "https://github.com/mjsaidhanush/sfa-project/blob/main/frontend/app/register/page.tsx"
click node_dashboard "https://github.com/mjsaidhanush/sfa-project/blob/main/frontend/app/dashboard/page.tsx"
click node_market "https://github.com/mjsaidhanush/sfa-project/blob/main/frontend/app/dashboard/market/page.tsx"
click node_schemes "https://github.com/mjsaidhanush/sfa-project/blob/main/frontend/app/dashboard/schemes/page.tsx"
click node_chatbot "https://github.com/mjsaidhanush/sfa-project/blob/main/frontend/app/dashboard/chatbot/page.tsx"
click node_crop_ui "https://github.com/mjsaidhanush/sfa-project/blob/main/frontend/app/dashboard/crop/page.tsx"
click node_weather_ui "https://github.com/mjsaidhanush/sfa-project/blob/main/frontend/app/dashboard/rain/page.tsx"
click node_disease_ui "https://github.com/mjsaidhanush/sfa-project/blob/main/frontend/app/dashboard/disease/page.tsx"
click node_ml_service "https://github.com/mjsaidhanush/sfa-project/tree/main/ml-services"
click node_api_server "https://github.com/mjsaidhanush/sfa-project/blob/main/backend/server.js"
click node_auth "https://github.com/mjsaidhanush/sfa-project/blob/main/backend/auth.js"
click node_user_model "https://github.com/mjsaidhanush/sfa-project/blob/main/backend/User.js"
click node_database "https://github.com/mjsaidhanush/sfa-project/blob/main/backend/db.js"
click node_admin_ui "https://github.com/mjsaidhanush/sfa-project/blob/main/frontend/app/admin/page.tsx"
click node_admin_routes "https://github.com/mjsaidhanush/sfa-project/blob/main/backend/adminRoutes.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_entry,node_registration,node_dashboard,node_market,node_schemes,node_chatbot toneBlue
class node_api_server,node_auth,node_user_model,node_database toneAmber
class node_crop_ui,node_weather_ui,node_disease_ui,node_ml_service toneMint
class node_admin_ui,node_admin_routes toneRose
class node_farmer toneIndigo
```

## Components

### Farmer Web App

- [Sign In](https://github.com/mjsaidhanush/sfa-project/blob/main/frontend/app/page.tsx): `frontend/app/page.tsx`
- [Registration](https://github.com/mjsaidhanush/sfa-project/blob/main/frontend/app/register/page.tsx): `frontend/app/register/page.tsx`
- [Dashboard](https://github.com/mjsaidhanush/sfa-project/blob/main/frontend/app/dashboard/page.tsx): `frontend/app/dashboard/page.tsx`
- [Marketplace](https://github.com/mjsaidhanush/sfa-project/blob/main/frontend/app/dashboard/market/page.tsx): `frontend/app/dashboard/market/page.tsx`
- [Schemes Discovery](https://github.com/mjsaidhanush/sfa-project/blob/main/frontend/app/dashboard/schemes/page.tsx): `frontend/app/dashboard/schemes/page.tsx`
- [Farm Chatbot](https://github.com/mjsaidhanush/sfa-project/blob/main/frontend/app/dashboard/chatbot/page.tsx): `frontend/app/dashboard/chatbot/page.tsx`

### Platform Services

- [Backend API](https://github.com/mjsaidhanush/sfa-project/blob/main/backend/server.js): `backend/server.js`
- [Authentication](https://github.com/mjsaidhanush/sfa-project/blob/main/backend/auth.js): `backend/auth.js`
- [User Accounts](https://github.com/mjsaidhanush/sfa-project/blob/main/backend/User.js): `backend/User.js`
- [MongoDB Connection](https://github.com/mjsaidhanush/sfa-project/blob/main/backend/db.js): `backend/db.js`

### AI Guidance

- [Crop Recommendation UI](https://github.com/mjsaidhanush/sfa-project/blob/main/frontend/app/dashboard/crop/page.tsx): `frontend/app/dashboard/crop/page.tsx`
- [Weather & Rain UI](https://github.com/mjsaidhanush/sfa-project/blob/main/frontend/app/dashboard/rain/page.tsx): `frontend/app/dashboard/rain/page.tsx`
- [Disease Detection UI](https://github.com/mjsaidhanush/sfa-project/blob/main/frontend/app/dashboard/disease/page.tsx): `frontend/app/dashboard/disease/page.tsx`
- [ML Inference Service](https://github.com/mjsaidhanush/sfa-project/tree/main/ml-services): `ml-services`

### Administration

- [Admin Portal](https://github.com/mjsaidhanush/sfa-project/blob/main/frontend/app/admin/page.tsx): `frontend/app/admin/page.tsx`
- [Admin Management API](https://github.com/mjsaidhanush/sfa-project/blob/main/backend/adminRoutes.js): `backend/adminRoutes.js`

### Other components

- **Farmer**

## Connections

- Farmer → Sign In: signs in (evidence: `frontend/app/page.tsx`)
- Farmer → Registration: registers (evidence: `frontend/app/register/page.tsx`)
- Sign In → Dashboard: enters
- Dashboard → Crop Recommendation UI: opens
- Dashboard → Weather & Rain UI: opens
- Dashboard → Disease Detection UI: opens
- Dashboard → Marketplace: opens
- Dashboard → Schemes Discovery: opens
- Dashboard → Farm Chatbot: opens
- Crop Recommendation UI → ML Inference Service: requests prediction (evidence: `frontend/app/dashboard/crop/page.tsx`)
- Weather & Rain UI → ML Inference Service: requests forecast (evidence: `frontend/app/dashboard/rain/page.tsx`)
- Disease Detection UI → ML Inference Service: analyzes image
- Sign In → Backend API: authenticates
- Registration → Backend API: creates account
- Backend API → Authentication: routes auth (evidence: `backend/server.js`)
- Backend API → Admin Management API: routes admin (evidence: `backend/server.js`)
- Backend API → MongoDB Connection: connects (evidence: `backend/server.js`)
- Authentication → User Accounts: reads and updates (evidence: `backend/auth.js`)
- Admin Management API → User Accounts: queries users (evidence: `backend/adminRoutes.js`)
- Admin Portal → Admin Management API: manages resources
