# manojyadav2005/kishan-sathi architecture

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

- Interactive diagram: https://gitdiagram.com/manojyadav2005/kishan-sathi
- Repository: https://github.com/manojyadav2005/kishan-sathi

## Overview

1. **Overall shape**
   - This repository is a hybrid farming app: a mostly static frontend in `frontend/` plus a Node.js backend in `backend/`.
   - The frontend delivers the product experience directly in the browser, while the backend mainly supports account/auth-related server functions and persistence.

2. **Frontend presentation layer**
   - `frontend/` is organized as multiple standalone HTML pages rather than a single SPA.
   - Key pages include `index.html`, `weather.html`, `market-price.html`, `crop-planner.html`, `education.html`, `ploughing-services.html`, `store.html`, `my-areastore.html`, `loan-calculator.html`, `comparison.html`, and auth pages like `login.html`, `register.html`, `forgot-password.html`, `reset-password.html`, `profile.html`.
   - `style.css` acts as the shared design system across the pages.

3. **Frontend client-side logic**
   - `frontend/api.js` is the shared browser-side API client for talking to backend endpoints.
   - `frontend/auth.js` handles user auth flows in the browser.
   - `frontend/nav.js` centralizes navigation behavior, and `frontend/i18n.js` suggests language/localization support.
   - This implies a page-driven UI where shared JS modules coordinate cross-page behavior.

4. **Browser-only feature set**
   - Several parts of the app are meant to work without the backend, using browser APIs and local state.
   - The README describes weather data, mandi prices, store/forum data, and other utilities that can run with external APIs or `localStorage`.
   - This creates a split architecture: some features are server-backed, while others are client-only or can degrade gracefully offline.

5. **Backend service boundary**
   - `backend/server.js` is the application entry point and likely mounts the Express app, middleware, and routes.
   - `backend/routes/authRoutes.js` and `backend/controllers/authController.js` define the authentication boundary.
   - Based on the file tree, the backend snapshot is focused on auth and user-account functionality rather than the full marketplace/forum feature set described in the README.

6. **Data model layer**
   - `backend/models/User.js` is the primary account model.
   - `backend/models/Notification.js` suggests server-side notification records.
   - `backend/models/PloughingService.js` indicates a domain model for service listings.
   - These models form the persistence boundary for backend-managed entities.

7. **Persistence**
   - The repository includes `db/kisan_sathi.db` plus SQLite WAL files (`.db-shm`, `.db-wal`), which indicates the current snapshot uses a local SQLite database.
   - This is an important architectural detail because it differs from the README’s MongoDB/Mongoose description.
   - For diagrams, the durable store should be shown as a local database file under `db/`, not as a remote database service.

8. **Email and notification flow**
   - `backend/utils/sendEmail.js` handles outgoing email, likely for password reset or account-related notifications.
   - The auth controller and notification model together imply a flow where user actions on the frontend can trigger backend-side email and notification side effects.

9. **Uploads and file handling**
   - `backend/uploads/avatars/` is the visible upload area in the repo, suggesting profile-image storage on disk.
   - The README also mentions other upload folders, but only avatars are present in the tree.
   - This means the backend has a filesystem-based asset boundary in addition to database persistence.

10. **Domain features surfaced in the UI**
   - The frontend pages map to user-facing product areas: weather intelligence, market prices, crop planning, education, community, store browsing, local agricultural services, comparison tools, and loan calculation.
   - Some of these are likely self-contained visual/educational tools; others rely on backend data or browser storage.
   - For an architecture diagram, these should be shown as separate frontend feature areas with only some connected to the backend.

11. **External integrations**
   - The README explicitly references OpenWeatherMap and data.gov.in for weather and mandi prices.
   - These are external API dependencies from the frontend, not from the backend tree shown here.
   - They matter because they bypass the application server for key live-data features.

12. **Repository caveat**
   - The README describes a broader full-stack system with forum, store, and order APIs, but the checked-in backend tree does not include those route/controller files.
   - So the safest architecture read is: a frontend-heavy app, a focused auth backend, SQLite persistence, disk-based uploads, and direct browser calls to third-party data providers.

Main entry points: [`backend/controllers/authController.js`](https://github.com/manojyadav2005/kishan-sathi/blob/main/backend/controllers/authController.js) (Auth controller), [`frontend/api.js`](https://github.com/manojyadav2005/kishan-sathi/blob/main/frontend/api.js) (API client), [`frontend/index.html`](https://github.com/manojyadav2005/kishan-sathi/blob/main/frontend/index.html) (Frontend app), [`backend/server.js`](https://github.com/manojyadav2005/kishan-sathi/blob/main/backend/server.js) (Server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_frontend_shell["Frontend app<br/>page bundle<br/>[index.html]"]
  node_frontend_auth["Auth pages<br/>[login.html]"]
  node_frontend_agri_tools["Agri tools<br/>pages<br/>[weather.html]"]
  node_frontend_marketplace["Marketplace<br/>pages<br/>[store.html]"]
  node_frontend_learning["Learning pages<br/>[education.html]"]
  node_frontend_chat["Community chat<br/>page<br/>[chat.html]"]
  node_frontend_style["Shared style<br/>css<br/>[style.css]"]
  node_frontend_api["API client<br/>browser module<br/>[api.js]"]
  node_frontend_auth_js["Auth logic<br/>browser module<br/>[auth.js]"]
  node_frontend_nav["Navigation<br/>browser module<br/>[nav.js]"]
  node_frontend_i18n["i18n<br/>browser module<br/>[i18n.js]"]
end

subgraph group_backend["Backend"]
  node_backend_server["Server<br/>Express entrypoint<br/>[server.js]"]
  node_backend_routes["Auth routes<br/>HTTP routes<br/>[authRoutes.js]"]
  node_backend_controller["Auth controller<br/>[authController.js]"]
  node_backend_user[("User model<br/>data model<br/>[User.js]")]
  node_backend_notice[("Notification model<br/>data model<br/>[Notification.js]")]
  node_backend_service[("Service model<br/>data model")]
  node_backend_email["Email sender<br/>[sendEmail.js]"]
end

subgraph group_data["Persistence"]
  node_db_file[("SQLite DB<br/>local database<br/>[kisan_sathi.db]")]
  node_uploads["Avatar uploads<br/>filesystem store"]
end

subgraph group_external["External APIs"]
  node_weather_api(("Weather API<br/>external service"))
  node_mandi_api(("Price API<br/>external service"))
end

node_frontend_shell -->|"uses"| node_frontend_style
node_frontend_shell -->|"shares"| node_frontend_nav
node_frontend_shell -->|"shares"| node_frontend_i18n
node_frontend_auth -->|"uses"| node_frontend_auth_js
node_frontend_auth -->|"calls"| node_frontend_api
node_frontend_agri_tools -->|"fetches"| node_weather_api
node_frontend_agri_tools -->|"fetches"| node_mandi_api
node_frontend_marketplace -->|"reads"| node_frontend_api
node_frontend_chat -->|"syncs"| node_frontend_api
node_frontend_api -->|"requests"| node_backend_server
node_backend_server -->|"mounts"| node_backend_routes
node_backend_routes -->|"delegates"| node_backend_controller
node_backend_controller -->|"persists"| node_backend_user
node_backend_controller -->|"writes"| node_backend_notice
node_backend_controller -->|"persists"| node_backend_service
node_backend_controller -->|"sends"| node_backend_email
node_backend_user -->|"stored in"| node_db_file
node_backend_notice -->|"stored in"| node_db_file
node_backend_service -->|"stored in"| node_db_file
node_backend_server -->|"serves"| node_uploads
node_backend_controller -->|"writes"| node_uploads

click node_frontend_shell "https://github.com/manojyadav2005/kishan-sathi/blob/main/frontend/index.html"
click node_frontend_auth "https://github.com/manojyadav2005/kishan-sathi/blob/main/frontend/login.html"
click node_frontend_agri_tools "https://github.com/manojyadav2005/kishan-sathi/blob/main/frontend/weather.html"
click node_frontend_marketplace "https://github.com/manojyadav2005/kishan-sathi/blob/main/frontend/store.html"
click node_frontend_learning "https://github.com/manojyadav2005/kishan-sathi/blob/main/frontend/education.html"
click node_frontend_chat "https://github.com/manojyadav2005/kishan-sathi/blob/main/frontend/chat.html"
click node_frontend_style "https://github.com/manojyadav2005/kishan-sathi/blob/main/frontend/style.css"
click node_frontend_api "https://github.com/manojyadav2005/kishan-sathi/blob/main/frontend/api.js"
click node_frontend_auth_js "https://github.com/manojyadav2005/kishan-sathi/blob/main/frontend/auth.js"
click node_frontend_nav "https://github.com/manojyadav2005/kishan-sathi/blob/main/frontend/nav.js"
click node_frontend_i18n "https://github.com/manojyadav2005/kishan-sathi/blob/main/frontend/i18n.js"
click node_backend_server "https://github.com/manojyadav2005/kishan-sathi/blob/main/backend/server.js"
click node_backend_routes "https://github.com/manojyadav2005/kishan-sathi/blob/main/backend/routes/authRoutes.js"
click node_backend_controller "https://github.com/manojyadav2005/kishan-sathi/blob/main/backend/controllers/authController.js"
click node_backend_user "https://github.com/manojyadav2005/kishan-sathi/blob/main/backend/models/User.js"
click node_backend_notice "https://github.com/manojyadav2005/kishan-sathi/blob/main/backend/models/Notification.js"
click node_backend_service "https://github.com/manojyadav2005/kishan-sathi/blob/main/backend/models/PloughingService.js"
click node_backend_email "https://github.com/manojyadav2005/kishan-sathi/blob/main/backend/utils/sendEmail.js"
click node_db_file "https://github.com/manojyadav2005/kishan-sathi/blob/main/db/kisan_sathi.db"
click node_uploads "https://github.com/manojyadav2005/kishan-sathi/tree/main/backend/uploads/avatars"

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_frontend_shell,node_frontend_auth,node_frontend_agri_tools,node_frontend_marketplace,node_frontend_learning,node_frontend_chat,node_frontend_style,node_frontend_api,node_frontend_auth_js,node_frontend_nav,node_frontend_i18n toneBlue
class node_backend_server,node_backend_routes,node_backend_controller,node_backend_user,node_backend_notice,node_backend_service,node_backend_email toneAmber
class node_db_file,node_uploads toneMint
class node_weather_api,node_mandi_api toneRose
```

## Components

### Frontend

Browser-facing pages and shared client scripts

- [Frontend app](https://github.com/manojyadav2005/kishan-sathi/blob/main/frontend/index.html): page bundle · Multi-page browser UI for the farming product · `frontend/index.html`
- [Auth pages](https://github.com/manojyadav2005/kishan-sathi/blob/main/frontend/login.html): pages · Login, registration, password reset, and profile screens · `frontend/login.html`
- [Agri tools](https://github.com/manojyadav2005/kishan-sathi/blob/main/frontend/weather.html): pages · Weather, market price, crop planning, and loan tools · `frontend/weather.html`
- [Marketplace](https://github.com/manojyadav2005/kishan-sathi/blob/main/frontend/store.html): pages · Store, area store, ploughing services, and comparison views · `frontend/store.html`
- [Learning pages](https://github.com/manojyadav2005/kishan-sathi/blob/main/frontend/education.html): pages · Education and guide-oriented browser content · `frontend/education.html`
- [Community chat](https://github.com/manojyadav2005/kishan-sathi/blob/main/frontend/chat.html): page · Standalone browser chat surface · `frontend/chat.html`
- [Shared style](https://github.com/manojyadav2005/kishan-sathi/blob/main/frontend/style.css): css · Common visual system across pages · `frontend/style.css`
- [API client](https://github.com/manojyadav2005/kishan-sathi/blob/main/frontend/api.js): browser module · Shared browser-side client for backend requests · `frontend/api.js`
- [Auth logic](https://github.com/manojyadav2005/kishan-sathi/blob/main/frontend/auth.js): browser module · Browser authentication and session flow handling · `frontend/auth.js`
- [Navigation](https://github.com/manojyadav2005/kishan-sathi/blob/main/frontend/nav.js): browser module · Cross-page navigation behavior · `frontend/nav.js`
- [i18n](https://github.com/manojyadav2005/kishan-sathi/blob/main/frontend/i18n.js): browser module · Language and localization support · `frontend/i18n.js`

### Backend

Express entrypoint, auth flow, models, and server utilities

- [Server](https://github.com/manojyadav2005/kishan-sathi/blob/main/backend/server.js): Express entrypoint · Backend application bootstrap and routing entrypoint · `backend/server.js`
- [Auth routes](https://github.com/manojyadav2005/kishan-sathi/blob/main/backend/routes/authRoutes.js): HTTP routes · Authentication-related API endpoints · `backend/routes/authRoutes.js`
- [Auth controller](https://github.com/manojyadav2005/kishan-sathi/blob/main/backend/controllers/authController.js): controller · Login, register, reset, and account actions · `backend/controllers/authController.js`
- [User model](https://github.com/manojyadav2005/kishan-sathi/blob/main/backend/models/User.js): data model · Primary account record · `backend/models/User.js`
- [Notification model](https://github.com/manojyadav2005/kishan-sathi/blob/main/backend/models/Notification.js): data model · Server-side notification records · `backend/models/Notification.js`
- [Service model](https://github.com/manojyadav2005/kishan-sathi/blob/main/backend/models/PloughingService.js): data model · Ploughing service listing records · `backend/models/PloughingService.js`
- [Email sender](https://github.com/manojyadav2005/kishan-sathi/blob/main/backend/utils/sendEmail.js): utility · Outward email delivery for account flows · `backend/utils/sendEmail.js`

### Persistence

Local database and disk-based assets

- [SQLite DB](https://github.com/manojyadav2005/kishan-sathi/blob/main/db/kisan_sathi.db): local database · Durable application data stored on disk · `db/kisan_sathi.db`
- [Avatar uploads](https://github.com/manojyadav2005/kishan-sathi/tree/main/backend/uploads/avatars): filesystem store · Disk-based uploaded profile images · `backend/uploads/avatars`

### External APIs

Third-party live data providers used from the browser

- **Weather API**: external service · Live weather data provider used by browser features
- **Price API**: external service · Live mandi or market-price data source

## Connections

- Frontend app → Shared style: uses · Shared presentation across pages
- Frontend app → Navigation: shares · Navigation behavior across pages
- Frontend app → i18n: shares · Localized UI text
- Auth pages → Auth logic: uses · Browser authentication flow support
- Auth pages → API client: calls · Account actions sent to backend
- Agri tools → Weather API: fetches · Browser calls to live weather data
- Agri tools → Price API: fetches · Browser calls to live price data
- Marketplace → API client: reads · Shared client data access where needed
- Community chat → API client: syncs · Uses shared API client for application data
- API client → Server: requests · Browser-to-server API boundary
- Server → Auth routes: mounts · Registers authentication routes
- Auth routes → Auth controller: delegates · Route handlers forward to controller logic
- Auth controller → User model: persists · Account records
- Auth controller → Notification model: writes · Notification side effects
- Auth controller → Service model: persists · Service listing records
- Auth controller → Email sender: sends · Password reset and account emails
- User model → SQLite DB: stored in · Primary durable persistence
- Notification model → SQLite DB: stored in · Notification persistence
- Service model → SQLite DB: stored in · Service listing persistence
- Server → Avatar uploads: serves · Filesystem upload boundary
- Auth controller → Avatar uploads: writes · Profile image uploads
