# uvindu12/agroedge-frontend architecture

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

## Overview

AgroEdge is a farmer-facing agricultural management platform: farmers create crop sessions, record farm activities, and review session summaries and reports, alongside crop recommendations and a farmer community. The repository separates a Next.js client from several backend services. Sampled activity controllers show session and upload persistence and summary calculation; the README documents recommendation, machine-learning, and community capabilities. Their detailed client wiring is not established by the sampled source, so those links are kept conservative.

Main entry points: [`client/src/lib/api.ts`](https://github.com/uvindu12/agroedge-frontend/blob/main/client/src/lib/api.ts) (API client), [`client/src/app`](https://github.com/uvindu12/agroedge-frontend/tree/main/client/src/app) (Next.js app), [`server/activity/server.js`](https://github.com/uvindu12/agroedge-frontend/blob/main/server/activity/server.js) (Activity API), [`server/activity/controllers/uploadController.js`](https://github.com/uvindu12/agroedge-frontend/blob/main/server/activity/controllers/uploadController.js) (Activity uploads)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Farmer interface"]
  node_web["Next.js app"]
  node_farm_ui["Farm dashboards"]
  node_activity_ui["Activity pages"]
  node_reports_ui["Reports<br/>[page.tsx]"]
  node_client_api["API client<br/>[api.ts]"]
end

subgraph group_farm["Farm operations"]
  node_activity_service["Activity API<br/>[server.js]"]
  node_sessions["Session handling"]
  node_uploads["Activity uploads"]
  node_activity_routes["Upload routes<br/>[uploadRoutes.js]"]
  node_session_routes["Session routes<br/>[sessionRoutes.js]"]
  node_farm_store[("Farm records<br/>[Session.js]")]
  node_calculations["Session summaries"]
  node_kpi_routes["KPI reporting<br/>[kpiRoutes.js]"]
end

subgraph group_intelligence["Decision support"]
  node_crop_api["Crop recommender<br/>[api.js]"]
  node_ml_api["ML service<br/>[main.py]"]
  node_recommendation["KPI computation<br/>[main.py]"]
end

subgraph group_community["Community and profiles"]
  node_community_service["Community API<br/>[server.js]"]
  node_community_chat["Live chat<br/>[chat.js]"]
  node_profile_service["User profiles<br/>[api.js]"]
  node_community_store[("Community data<br/>[db.js]")]
end

node_farmer(("Farmer"))

node_farmer -->|"uses"| node_web
node_web -->|"opens"| node_farm_ui
node_web -->|"opens"| node_activity_ui
node_web -->|"opens"| node_reports_ui
node_farm_ui -->|"requests data"| node_client_api
node_activity_ui -->|"submits activity"| node_client_api
node_reports_ui -->|"requests reports"| node_client_api
node_client_api -->|"API requests"| node_activity_service
node_activity_service -->|"mounts routes"| node_session_routes
node_activity_service -->|"mounts routes"| node_activity_routes
node_session_routes -->|"dispatches"| node_sessions
node_activity_routes -->|"dispatches"| node_uploads
node_sessions -->|"reads and writes"| node_farm_store
node_uploads -->|"checks sessions"| node_farm_store
node_uploads -->|"calculates summaries"| node_calculations
node_calculations -->|"summarizes records"| node_farm_store
node_client_api -.->|"recommendation requests"| node_crop_api
node_client_api -.->|"ML requests"| node_ml_api
node_client_api -.->|"community requests"| node_community_service
node_community_service -->|"sets up sockets"| node_community_chat
node_community_service -->|"uses database"| node_community_store
node_client_api -.->|"profile requests"| node_profile_service
node_kpi_routes -->|"posts KPI"| node_recommendation

click node_web "https://github.com/uvindu12/agroedge-frontend/tree/main/client/src/app"
click node_farm_ui "https://github.com/uvindu12/agroedge-frontend/tree/main/client/src/app/components/dashboard"
click node_activity_ui "https://github.com/uvindu12/agroedge-frontend/tree/main/client/src/app/activities"
click node_reports_ui "https://github.com/uvindu12/agroedge-frontend/blob/main/client/src/app/farmer-report/page.tsx"
click node_client_api "https://github.com/uvindu12/agroedge-frontend/blob/main/client/src/lib/api.ts"
click node_activity_service "https://github.com/uvindu12/agroedge-frontend/blob/main/server/activity/server.js"
click node_sessions "https://github.com/uvindu12/agroedge-frontend/blob/main/server/activity/controllers/sessionController.js"
click node_uploads "https://github.com/uvindu12/agroedge-frontend/blob/main/server/activity/controllers/uploadController.js"
click node_activity_routes "https://github.com/uvindu12/agroedge-frontend/blob/main/server/activity/routes/uploadRoutes.js"
click node_session_routes "https://github.com/uvindu12/agroedge-frontend/blob/main/server/management/server/routes/sessionRoutes.js"
click node_farm_store "https://github.com/uvindu12/agroedge-frontend/blob/main/server/activity/models/Session.js"
click node_calculations "https://github.com/uvindu12/agroedge-frontend/blob/main/server/activity/services/calculationService.js"
click node_kpi_routes "https://github.com/uvindu12/agroedge-frontend/blob/main/server/activity/routes/kpiRoutes.js"
click node_crop_api "https://github.com/uvindu12/agroedge-frontend/blob/main/server/crop-recommendation-system/routes/api.js"
click node_ml_api "https://github.com/uvindu12/agroedge-frontend/blob/main/server/ML_backend/app/main.py"
click node_recommendation "https://github.com/uvindu12/agroedge-frontend/blob/main/server/ML_part/recommendation_part/app/main.py"
click node_community_service "https://github.com/uvindu12/agroedge-frontend/blob/main/server/community/server.js"
click node_community_chat "https://github.com/uvindu12/agroedge-frontend/blob/main/server/community/sockets/chat.js"
click node_profile_service "https://github.com/uvindu12/agroedge-frontend/blob/main/server/user-profile/routes/api.js"
click node_community_store "https://github.com/uvindu12/agroedge-frontend/blob/main/server/community/config/db.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_web,node_farm_ui,node_activity_ui,node_reports_ui,node_client_api toneBlue
class node_activity_service,node_sessions,node_uploads,node_activity_routes,node_session_routes,node_farm_store,node_calculations,node_kpi_routes toneAmber
class node_crop_api,node_ml_api,node_recommendation toneMint
class node_community_service,node_community_chat,node_profile_service,node_community_store toneRose
class node_farmer toneIndigo
```

## Components

### Farmer interface

- [Next.js app](https://github.com/uvindu12/agroedge-frontend/tree/main/client/src/app): `client/src/app`
- [Farm dashboards](https://github.com/uvindu12/agroedge-frontend/tree/main/client/src/app/components/dashboard): `client/src/app/components/dashboard`
- [Activity pages](https://github.com/uvindu12/agroedge-frontend/tree/main/client/src/app/activities): `client/src/app/activities`
- [Reports](https://github.com/uvindu12/agroedge-frontend/blob/main/client/src/app/farmer-report/page.tsx): `client/src/app/farmer-report/page.tsx`
- [API client](https://github.com/uvindu12/agroedge-frontend/blob/main/client/src/lib/api.ts): `client/src/lib/api.ts`

### Farm operations

- [Activity API](https://github.com/uvindu12/agroedge-frontend/blob/main/server/activity/server.js): `server/activity/server.js`
- [Session handling](https://github.com/uvindu12/agroedge-frontend/blob/main/server/activity/controllers/sessionController.js): `server/activity/controllers/sessionController.js`
- [Activity uploads](https://github.com/uvindu12/agroedge-frontend/blob/main/server/activity/controllers/uploadController.js): `server/activity/controllers/uploadController.js`
- [Upload routes](https://github.com/uvindu12/agroedge-frontend/blob/main/server/activity/routes/uploadRoutes.js): `server/activity/routes/uploadRoutes.js`
- [Session routes](https://github.com/uvindu12/agroedge-frontend/blob/main/server/management/server/routes/sessionRoutes.js): `server/management/server/routes/sessionRoutes.js`
- [Farm records](https://github.com/uvindu12/agroedge-frontend/blob/main/server/activity/models/Session.js): `server/activity/models/Session.js`
- [Session summaries](https://github.com/uvindu12/agroedge-frontend/blob/main/server/activity/services/calculationService.js): `server/activity/services/calculationService.js`
- [KPI reporting](https://github.com/uvindu12/agroedge-frontend/blob/main/server/activity/routes/kpiRoutes.js): `server/activity/routes/kpiRoutes.js`

### Decision support

- [Crop recommender](https://github.com/uvindu12/agroedge-frontend/blob/main/server/crop-recommendation-system/routes/api.js): `server/crop-recommendation-system/routes/api.js`
- [ML service](https://github.com/uvindu12/agroedge-frontend/blob/main/server/ML_backend/app/main.py): `server/ML_backend/app/main.py`
- [KPI computation](https://github.com/uvindu12/agroedge-frontend/blob/main/server/ML_part/recommendation_part/app/main.py): `server/ML_part/recommendation_part/app/main.py`

### Community and profiles

- [Community API](https://github.com/uvindu12/agroedge-frontend/blob/main/server/community/server.js): `server/community/server.js`
- [Live chat](https://github.com/uvindu12/agroedge-frontend/blob/main/server/community/sockets/chat.js): `server/community/sockets/chat.js`
- [User profiles](https://github.com/uvindu12/agroedge-frontend/blob/main/server/user-profile/routes/api.js): `server/user-profile/routes/api.js`
- [Community data](https://github.com/uvindu12/agroedge-frontend/blob/main/server/community/config/db.js): `server/community/config/db.js`

### Other components

- **Farmer**

## Connections

- Farmer → Next.js app: uses
- Next.js app → Farm dashboards: opens
- Next.js app → Activity pages: opens
- Next.js app → Reports: opens
- Farm dashboards → API client: requests data
- Activity pages → API client: submits activity
- Reports → API client: requests reports
- API client → Activity API: API requests
- Activity API → Session routes: mounts routes
- Activity API → Upload routes: mounts routes
- Session routes → Session handling: dispatches
- Upload routes → Activity uploads: dispatches
- Session handling → Farm records: reads and writes
- Activity uploads → Farm records: checks sessions
- Activity uploads → Session summaries: calculates summaries
- Session summaries → Farm records: summarizes records
- API client → Crop recommender: recommendation requests
- API client → ML service: ML requests
- API client → Community API: community requests
- Community API → Live chat: sets up sockets
- Community API → Community data: uses database
- API client → User profiles: profile requests
- KPI reporting → KPI computation: posts KPI
