# john210706/farmiq architecture

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

- Interactive diagram: https://gitdiagram.com/john210706/farmiq
- Repository: https://github.com/john210706/farmiq

## Overview

FarmIQ is a multi-role machinery-rental marketplace. Farmers discover equipment and submit a quote-backed request; owners approve it, the farmer pays, and a driver completes inspected delivery and return handovers before the rental is closed. The frontend is organized around role workflows and sends API requests to an Express backend, where routes coordinate booking, dispatch, payment, and supporting services. The README documents additional account, administration, learning, community, and planning capabilities. Some subsystem connections are included from explicit README documentation or source-index references; unsampled implementation details are not assumed.

Main entry points: [`frontend/src/Workspace.jsx`](https://github.com/john210706/farmiq/blob/main/frontend/src/Workspace.jsx) (Role workspace), [`backend/src/routes/platform.js`](https://github.com/john210706/farmiq/blob/main/backend/src/routes/platform.js) (Marketplace routes), [`frontend/src/lib/api.js`](https://github.com/john210706/farmiq/blob/main/frontend/src/lib/api.js) (API client), [`backend/src/app.js`](https://github.com/john210706/farmiq/blob/main/backend/src/app.js) (HTTP application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User experience"]
  node_workspace["Role workspace<br/>[Workspace.jsx]"]
  node_catalog["Machine catalogue<br/>[Catalog.jsx]"]
  node_bookingui["Booking workflows<br/>[Bookings.jsx]"]
  node_management["Owner management<br/>[Manage.jsx]"]
  node_operationsui["Operations console<br/>[Operations.jsx]"]
  node_learningui["Learning content<br/>[Learning.jsx]"]
  node_communityui["Community tools<br/>[Community.jsx]"]
  node_location["Location tools<br/>[location.jsx]"]
  node_api_client["API client<br/>[api.js]"]
end

subgraph group_api["API and identity"]
  node_express_app["HTTP application<br/>[app.js]"]
  node_auth["Authentication<br/>[platform-auth.js]"]
  node_authorization["Access control<br/>[auth.js]"]
  node_platform_routes["Marketplace routes<br/>[platform.js]"]
  node_channel_routes["Channels and SMS<br/>[channels.js]"]
  node_payment_routes["Payment routes<br/>[payments.js]"]
  node_intelligence["Planning assistance<br/>[intelligence.js]"]
  node_operations_routes["Admin operations<br/>[operations.js]"]
end

subgraph group_rental["Rental operations"]
  node_domain["Rental rules<br/>[domain.js]"]
  node_booking["Booking lifecycle<br/>[booking.js]"]
  node_dispatch["Driver dispatch<br/>[dispatch.js]"]
end

subgraph group_support["Supporting services"]
  node_database[("PostgreSQL")]
  node_storage["Private documents<br/>[storage.js]"]
  node_worker["Background worker<br/>[worker.js]"]
  node_outbox["SMS outbox<br/>[outbox.js]"]
  node_tutorials["Tutorial service<br/>[tutorials.js]"]
  node_translations["Localization<br/>[i18n.js]"]
  node_geo["Geospatial utilities<br/>[geo.js]"]
end

node_farmers(("Farmers"))
node_owners(("Owners"))
node_drivers(("Delivery partners"))
node_admins(("Administrators"))
node_sms_provider["SMS provider"]
node_payment_provider["Razorpay"]

node_farmers -->|"use"| node_workspace
node_owners -->|"use"| node_workspace
node_drivers -->|"use"| node_workspace
node_admins -->|"use"| node_workspace
node_workspace -->|"renders"| node_catalog
node_workspace -->|"renders"| node_bookingui
node_workspace -->|"renders"| node_management
node_workspace -->|"renders"| node_operationsui
node_workspace -->|"renders"| node_learningui
node_workspace -->|"renders"| node_communityui
node_catalog -->|"requests"| node_api_client
node_bookingui -->|"requests"| node_api_client
node_management -->|"requests"| node_api_client
node_operationsui -->|"requests"| node_api_client
node_learningui -->|"requests"| node_api_client
node_communityui -->|"requests"| node_api_client
node_catalog -->|"uses"| node_location
node_bookingui -->|"submits rental details"| node_database
node_api_client -->|"HTTP requests"| node_express_app
node_express_app -->|"mounts"| node_auth
node_express_app -->|"mounts"| node_channel_routes
node_express_app -->|"mounts"| node_payment_routes
node_express_app -->|"mounts"| node_operations_routes
node_express_app -->|"mounts"| node_platform_routes
node_express_app -->|"mounts"| node_intelligence
node_auth -->|"checks sessions"| node_authorization
node_auth -->|"reads and updates users"| node_database
node_platform_routes -->|"requires roles"| node_authorization
node_platform_routes -->|"delegates"| node_booking
node_platform_routes -->|"uses rules"| node_domain
node_platform_routes -->|"dispatches drivers"| node_dispatch
node_platform_routes -->|"handles documents"| node_storage
node_platform_routes -->|"manages tutorials"| node_tutorials
node_platform_routes -->|"uses distance tools"| node_geo
node_booking -->|"applies transitions"| node_domain
node_booking -->|"persists bookings"| node_database
node_payment_routes -->|"coordinates payment state"| node_booking
node_payment_routes -.->|"optional checkout"| node_payment_provider
node_dispatch -->|"assigns drivers"| node_booking
node_dispatch -->|"uses distance tools"| node_geo
node_channel_routes -->|"reads booking context"| node_booking
node_channel_routes -->|"queues notices"| node_outbox
node_outbox -.->|"sends messages"| node_sms_provider
node_worker -->|"runs dispatch"| node_dispatch
node_worker -->|"processes messages"| node_outbox
node_intelligence -->|"uses domain rules"| node_domain
node_location -->|"requests address lookup"| node_api_client
node_bookingui -->|"starts checkout"| node_api_client

click node_workspace "https://github.com/john210706/farmiq/blob/main/frontend/src/Workspace.jsx"
click node_catalog "https://github.com/john210706/farmiq/blob/main/frontend/src/pages/Catalog.jsx"
click node_bookingui "https://github.com/john210706/farmiq/blob/main/frontend/src/pages/Bookings.jsx"
click node_management "https://github.com/john210706/farmiq/blob/main/frontend/src/pages/Manage.jsx"
click node_operationsui "https://github.com/john210706/farmiq/blob/main/frontend/src/pages/Operations.jsx"
click node_learningui "https://github.com/john210706/farmiq/blob/main/frontend/src/pages/Learning.jsx"
click node_communityui "https://github.com/john210706/farmiq/blob/main/frontend/src/pages/Community.jsx"
click node_location "https://github.com/john210706/farmiq/blob/main/frontend/src/location.jsx"
click node_api_client "https://github.com/john210706/farmiq/blob/main/frontend/src/lib/api.js"
click node_express_app "https://github.com/john210706/farmiq/blob/main/backend/src/app.js"
click node_auth "https://github.com/john210706/farmiq/blob/main/backend/src/routes/platform-auth.js"
click node_authorization "https://github.com/john210706/farmiq/blob/main/backend/src/middleware/auth.js"
click node_platform_routes "https://github.com/john210706/farmiq/blob/main/backend/src/routes/platform.js"
click node_channel_routes "https://github.com/john210706/farmiq/blob/main/backend/src/routes/channels.js"
click node_payment_routes "https://github.com/john210706/farmiq/blob/main/backend/src/routes/payments.js"
click node_intelligence "https://github.com/john210706/farmiq/blob/main/backend/src/routes/intelligence.js"
click node_operations_routes "https://github.com/john210706/farmiq/blob/main/backend/src/routes/operations.js"
click node_domain "https://github.com/john210706/farmiq/blob/main/backend/src/domain.js"
click node_booking "https://github.com/john210706/farmiq/blob/main/backend/src/services/booking.js"
click node_dispatch "https://github.com/john210706/farmiq/blob/main/backend/src/services/dispatch.js"
click node_storage "https://github.com/john210706/farmiq/blob/main/backend/src/services/storage.js"
click node_worker "https://github.com/john210706/farmiq/blob/main/backend/src/services/worker.js"
click node_outbox "https://github.com/john210706/farmiq/blob/main/backend/src/services/outbox.js"
click node_tutorials "https://github.com/john210706/farmiq/blob/main/backend/src/services/tutorials.js"
click node_translations "https://github.com/john210706/farmiq/blob/main/backend/src/i18n.js"
click node_geo "https://github.com/john210706/farmiq/blob/main/backend/src/utils/geo.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_workspace,node_catalog,node_bookingui,node_management,node_operationsui,node_learningui,node_communityui,node_location,node_api_client toneBlue
class node_express_app,node_auth,node_authorization,node_platform_routes,node_channel_routes,node_payment_routes,node_intelligence,node_operations_routes toneAmber
class node_domain,node_booking,node_dispatch toneMint
class node_database,node_storage,node_worker,node_outbox,node_tutorials,node_translations,node_geo toneRose
class node_farmers,node_owners,node_drivers,node_admins,node_sms_provider,node_payment_provider toneIndigo
```

## Components

### User experience

- [Role workspace](https://github.com/john210706/farmiq/blob/main/frontend/src/Workspace.jsx): `frontend/src/Workspace.jsx`
- [Machine catalogue](https://github.com/john210706/farmiq/blob/main/frontend/src/pages/Catalog.jsx): `frontend/src/pages/Catalog.jsx`
- [Booking workflows](https://github.com/john210706/farmiq/blob/main/frontend/src/pages/Bookings.jsx): `frontend/src/pages/Bookings.jsx`
- [Owner management](https://github.com/john210706/farmiq/blob/main/frontend/src/pages/Manage.jsx): `frontend/src/pages/Manage.jsx`
- [Operations console](https://github.com/john210706/farmiq/blob/main/frontend/src/pages/Operations.jsx): `frontend/src/pages/Operations.jsx`
- [Learning content](https://github.com/john210706/farmiq/blob/main/frontend/src/pages/Learning.jsx): `frontend/src/pages/Learning.jsx`
- [Community tools](https://github.com/john210706/farmiq/blob/main/frontend/src/pages/Community.jsx): `frontend/src/pages/Community.jsx`
- [Location tools](https://github.com/john210706/farmiq/blob/main/frontend/src/location.jsx): `frontend/src/location.jsx`
- [API client](https://github.com/john210706/farmiq/blob/main/frontend/src/lib/api.js): `frontend/src/lib/api.js`

### API and identity

- [HTTP application](https://github.com/john210706/farmiq/blob/main/backend/src/app.js): `backend/src/app.js`
- [Authentication](https://github.com/john210706/farmiq/blob/main/backend/src/routes/platform-auth.js): `backend/src/routes/platform-auth.js`
- [Access control](https://github.com/john210706/farmiq/blob/main/backend/src/middleware/auth.js): `backend/src/middleware/auth.js`
- [Marketplace routes](https://github.com/john210706/farmiq/blob/main/backend/src/routes/platform.js): `backend/src/routes/platform.js`
- [Channels and SMS](https://github.com/john210706/farmiq/blob/main/backend/src/routes/channels.js): `backend/src/routes/channels.js`
- [Payment routes](https://github.com/john210706/farmiq/blob/main/backend/src/routes/payments.js): `backend/src/routes/payments.js`
- [Planning assistance](https://github.com/john210706/farmiq/blob/main/backend/src/routes/intelligence.js): `backend/src/routes/intelligence.js`
- [Admin operations](https://github.com/john210706/farmiq/blob/main/backend/src/routes/operations.js): `backend/src/routes/operations.js`

### Rental operations

- [Rental rules](https://github.com/john210706/farmiq/blob/main/backend/src/domain.js): `backend/src/domain.js`
- [Booking lifecycle](https://github.com/john210706/farmiq/blob/main/backend/src/services/booking.js): `backend/src/services/booking.js`
- [Driver dispatch](https://github.com/john210706/farmiq/blob/main/backend/src/services/dispatch.js): `backend/src/services/dispatch.js`

### Supporting services

- **PostgreSQL**
- [Private documents](https://github.com/john210706/farmiq/blob/main/backend/src/services/storage.js): `backend/src/services/storage.js`
- [Background worker](https://github.com/john210706/farmiq/blob/main/backend/src/services/worker.js): `backend/src/services/worker.js`
- [SMS outbox](https://github.com/john210706/farmiq/blob/main/backend/src/services/outbox.js): `backend/src/services/outbox.js`
- [Tutorial service](https://github.com/john210706/farmiq/blob/main/backend/src/services/tutorials.js): `backend/src/services/tutorials.js`
- [Localization](https://github.com/john210706/farmiq/blob/main/backend/src/i18n.js): `backend/src/i18n.js`
- [Geospatial utilities](https://github.com/john210706/farmiq/blob/main/backend/src/utils/geo.js): `backend/src/utils/geo.js`

### Other components

- **Farmers**
- **Owners**
- **Delivery partners**
- **Administrators**
- **SMS provider**
- **Razorpay**

## Connections

- Farmers → Role workspace: use (evidence: `README.md`)
- Owners → Role workspace: use (evidence: `README.md`)
- Delivery partners → Role workspace: use (evidence: `README.md`)
- Administrators → Role workspace: use (evidence: `README.md`)
- Role workspace → Machine catalogue: renders (evidence: `frontend/src/Workspace.jsx`)
- Role workspace → Booking workflows: renders (evidence: `frontend/src/Workspace.jsx`)
- Role workspace → Owner management: renders (evidence: `frontend/src/Workspace.jsx`)
- Role workspace → Operations console: renders (evidence: `frontend/src/Workspace.jsx`)
- Role workspace → Learning content: renders (evidence: `frontend/src/Workspace.jsx`)
- Role workspace → Community tools: renders (evidence: `frontend/src/Workspace.jsx`)
- Machine catalogue → API client: requests (evidence: `frontend/src/pages/Catalog.jsx`)
- Booking workflows → API client: requests (evidence: `frontend/src/pages/Bookings.jsx`)
- Owner management → API client: requests (evidence: `frontend/src/pages/Manage.jsx`)
- Operations console → API client: requests (evidence: `frontend/src/pages/Operations.jsx`)
- Learning content → API client: requests (evidence: `frontend/src/pages/Learning.jsx`)
- Community tools → API client: requests (evidence: `frontend/src/pages/Community.jsx`)
- Machine catalogue → Location tools: uses (evidence: `frontend/src/pages/Catalog.jsx`)
- Booking workflows → PostgreSQL: submits rental details (evidence: `README.md`)
- API client → HTTP application: HTTP requests (evidence: `README.md`)
- HTTP application → Authentication: mounts (evidence: `backend/src/app.js`)
- HTTP application → Channels and SMS: mounts (evidence: `backend/src/app.js`)
- HTTP application → Payment routes: mounts (evidence: `backend/src/app.js`)
- HTTP application → Admin operations: mounts (evidence: `backend/src/app.js`)
- HTTP application → Marketplace routes: mounts (evidence: `backend/src/app.js`)
- HTTP application → Planning assistance: mounts (evidence: `backend/src/app.js`)
- Authentication → Access control: checks sessions (evidence: `backend/src/routes/platform-auth.js`)
- Authentication → PostgreSQL: reads and updates users (evidence: `backend/src/routes/platform-auth.js`)
- Marketplace routes → Access control: requires roles (evidence: `backend/src/routes/platform.js`)
- Marketplace routes → Booking lifecycle: delegates (evidence: `backend/src/routes/platform.js`)
- Marketplace routes → Rental rules: uses rules (evidence: `backend/src/routes/platform.js`)
- Marketplace routes → Driver dispatch: dispatches drivers (evidence: `backend/src/routes/platform.js`)
- Marketplace routes → Private documents: handles documents (evidence: `backend/src/routes/platform.js`)
- Marketplace routes → Tutorial service: manages tutorials (evidence: `backend/src/routes/platform.js`)
- Marketplace routes → Geospatial utilities: uses distance tools (evidence: `backend/src/routes/platform.js`)
- Booking lifecycle → Rental rules: applies transitions (evidence: `backend/src/services/booking.js`)
- Booking lifecycle → PostgreSQL: persists bookings (evidence: `backend/src/services/booking.js`)
- Payment routes → Booking lifecycle: coordinates payment state (evidence: `backend/src/routes/payments.js`)
- Payment routes → Razorpay: optional checkout (evidence: `README.md`)
- Driver dispatch → Booking lifecycle: assigns drivers (evidence: `backend/src/services/dispatch.js`)
- Driver dispatch → Geospatial utilities: uses distance tools (evidence: `backend/src/services/dispatch.js`)
- Channels and SMS → Booking lifecycle: reads booking context (evidence: `backend/src/routes/channels.js`)
- Channels and SMS → SMS outbox: queues notices (evidence: `backend/src/routes/channels.js`)
- SMS outbox → SMS provider: sends messages (evidence: `README.md`)
- Background worker → Driver dispatch: runs dispatch (evidence: `backend/src/services/worker.js`)
- Background worker → SMS outbox: processes messages (evidence: `backend/src/services/worker.js`)
- Planning assistance → Rental rules: uses domain rules (evidence: `backend/src/routes/intelligence.js`)
- Location tools → API client: requests address lookup (evidence: `frontend/src/location.jsx`)
- Booking workflows → API client: starts checkout (evidence: `frontend/src/pages/Bookings.jsx`)
