# kanagugaming/marudhan-cloud-src architecture

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

- Interactive diagram: https://gitdiagram.com/kanagugaming/marudhan-cloud-src
- Repository: https://github.com/kanagugaming/marudhan-cloud-src

## Overview

MARUDHAN is an agricultural monitoring and advisory system spanning field devices, edge processing, and cloud services. The visible workflow publishes sensor telemetry, evaluates irrigation locally, queues cloud synchronization, and processes telemetry through cloud APIs. The cloud also exposes farmer chat, drone-image analysis, digital-twin, finance, and resource endpoints. The README provides no capability details; some subsystem behavior is represented from module names and routing references, while unsampled internal connections are omitted.

Main entry points: [`cloud/app/api/router.py`](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/api/router.py) (Service Router), [`cloud/app/main.py`](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/main.py) (Cloud API App), [`cloud/api/endpoints.py`](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/api/endpoints.py) (Telemetry API), [`cloud/app/services/arivu_core.py`](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/services/arivu_core.py) (Telemetry Decisions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_field["Field Devices"]
  node_sensor_device["Sensor Device<br/>[main.cpp]"]
end

subgraph group_edge["Edge Runtime"]
  node_edge_runtime["Edge Coordinator<br/>[mfcu_main.py]"]
  node_mqtt_broker["Local MQTT Broker<br/>[local_broker.py]"]
  node_irrigation_rules["AARU Rules<br/>[aaru_rules.py]"]
  node_cloud_sync["Cloud Sync Queue<br/>[cloud_sync.py]"]
end

subgraph group_cloud_api["Cloud APIs"]
  node_cloud_app["Cloud API App<br/>[main.py]"]
  node_api_router["Service Router<br/>[router.py]"]
  node_farmer_chat["Farmer Chat API<br/>[farmer_chat.py]"]
  node_telemetry_schema["Request Schemas<br/>[schemas.py]"]
  node_legacy_api["Telemetry API<br/>[endpoints.py]"]
  node_legacy_app["Legacy API App<br/>[main.py]"]
end

subgraph group_services["Cloud Services"]
  node_arivu_service["Telemetry Decisions<br/>[arivu_core.py]"]
  node_weather_service["Weather Context<br/>[weather_api.py]"]
  node_pathivu_store[("PATHIVU Logging<br/>[pathivu.py]")]
  node_arivu_engine["Yield &amp; Disease<br/>[arivu_engine.py]"]
  node_kural_nlp["KURAL NLP<br/>[kural_nlp.py]"]
  node_kural_response["KURAL Responses<br/>[kural_unmai.py]"]
  node_vision["Drone Vision<br/>[nalam_vision.py]"]
  node_twin["Digital Twin<br/>[aadi_twin.py]"]
  node_finance["Farm Finance<br/>[varavu_valam.py]"]
  node_kanru_engine["KANRU Risk Engine<br/>[kanru_engine.py]"]
  node_kural_engine["KURAL Engine<br/>[engine.py]"]
  node_kural_ingest["KURAL Ingestion<br/>[ingest.py]"]
  node_legacy_store[("Digital Twin Store<br/>[database.py]")]
end

node_farmer(("Farmer"))
node_cloud_service(("Cloud Service"))

node_sensor_device -.->|"publishes MQTT"| node_mqtt_broker
node_edge_runtime -->|"uses broker"| node_mqtt_broker
node_edge_runtime -->|"queues sync"| node_cloud_sync
node_mqtt_broker -->|"evaluates telemetry"| node_irrigation_rules
node_cloud_sync -->|"POSTs telemetry"| node_legacy_api
node_cloud_service -->|"serves requests"| node_cloud_app
node_cloud_app -->|"mounts routes"| node_api_router
node_cloud_app -->|"mounts routes"| node_farmer_chat
node_api_router -->|"validates payloads"| node_telemetry_schema
node_api_router -->|"processes telemetry"| node_arivu_service
node_api_router -->|"analyzes imagery"| node_vision
node_api_router -->|"gets responses"| node_kural_response
node_api_router -->|"gets twin state"| node_twin
node_api_router -->|"calculates metrics"| node_finance
node_farmer_chat -->|"handles queries"| node_kural_nlp
node_arivu_service -->|"fetches weather"| node_weather_service
node_arivu_service -->|"logs telemetry"| node_pathivu_store
node_legacy_app -->|"mounts router"| node_legacy_api
node_legacy_app -->|"opens connection"| node_legacy_store
node_legacy_api -->|"processes telemetry"| node_arivu_engine
node_legacy_api -->|"reads and writes"| node_legacy_store
node_farmer -.->|"uses services"| node_cloud_app

click node_sensor_device "https://github.com/kanagugaming/marudhan-cloud-src/blob/main/device/src/main.cpp"
click node_edge_runtime "https://github.com/kanagugaming/marudhan-cloud-src/blob/main/edge/mfcu_main.py"
click node_mqtt_broker "https://github.com/kanagugaming/marudhan-cloud-src/blob/main/edge/local_broker.py"
click node_irrigation_rules "https://github.com/kanagugaming/marudhan-cloud-src/blob/main/edge/aaru_rules.py"
click node_cloud_sync "https://github.com/kanagugaming/marudhan-cloud-src/blob/main/edge/cloud_sync.py"
click node_cloud_app "https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/main.py"
click node_api_router "https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/api/router.py"
click node_farmer_chat "https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/api/farmer_chat.py"
click node_telemetry_schema "https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/models/schemas.py"
click node_legacy_api "https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/api/endpoints.py"
click node_legacy_app "https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/main.py"
click node_arivu_service "https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/services/arivu_core.py"
click node_weather_service "https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/services/weather_api.py"
click node_pathivu_store "https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/db/pathivu.py"
click node_arivu_engine "https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/core/arivu_engine.py"
click node_kural_nlp "https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/services/kural_nlp.py"
click node_kural_response "https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/services/kural_unmai.py"
click node_vision "https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/services/nalam_vision.py"
click node_twin "https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/services/aadi_twin.py"
click node_finance "https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/services/varavu_valam.py"
click node_kanru_engine "https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/core/kanru_engine.py"
click node_kural_engine "https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/core/kural/engine.py"
click node_kural_ingest "https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/core/kural/ingest.py"
click node_legacy_store "https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/db/database.py"

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_sensor_device toneBlue
class node_edge_runtime,node_mqtt_broker,node_irrigation_rules,node_cloud_sync toneAmber
class node_cloud_app,node_api_router,node_farmer_chat,node_telemetry_schema,node_legacy_api,node_legacy_app toneMint
class node_arivu_service,node_weather_service,node_pathivu_store,node_arivu_engine,node_kural_nlp,node_kural_response,node_vision,node_twin,node_finance,node_kanru_engine,node_kural_engine,node_kural_ingest,node_legacy_store toneRose
class node_farmer,node_cloud_service toneIndigo
```

## Components

### Field Devices

- [Sensor Device](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/device/src/main.cpp): `device/src/main.cpp`

### Edge Runtime

- [Edge Coordinator](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/edge/mfcu_main.py): `edge/mfcu_main.py`
- [Local MQTT Broker](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/edge/local_broker.py): `edge/local_broker.py`
- [AARU Rules](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/edge/aaru_rules.py): `edge/aaru_rules.py`
- [Cloud Sync Queue](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/edge/cloud_sync.py): `edge/cloud_sync.py`

### Cloud APIs

- [Cloud API App](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/main.py): `cloud/app/main.py`
- [Service Router](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/api/router.py): `cloud/app/api/router.py`
- [Farmer Chat API](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/api/farmer_chat.py): `cloud/app/api/farmer_chat.py`
- [Request Schemas](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/models/schemas.py): `cloud/app/models/schemas.py`
- [Telemetry API](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/api/endpoints.py): `cloud/api/endpoints.py`
- [Legacy API App](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/main.py): `cloud/main.py`

### Cloud Services

- [Telemetry Decisions](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/services/arivu_core.py): `cloud/app/services/arivu_core.py`
- [Weather Context](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/services/weather_api.py): `cloud/app/services/weather_api.py`
- [PATHIVU Logging](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/db/pathivu.py): `cloud/app/db/pathivu.py`
- [Yield & Disease](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/core/arivu_engine.py): `cloud/core/arivu_engine.py`
- [KURAL NLP](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/services/kural_nlp.py): `cloud/app/services/kural_nlp.py`
- [KURAL Responses](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/services/kural_unmai.py): `cloud/app/services/kural_unmai.py`
- [Drone Vision](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/services/nalam_vision.py): `cloud/app/services/nalam_vision.py`
- [Digital Twin](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/services/aadi_twin.py): `cloud/app/services/aadi_twin.py`
- [Farm Finance](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/app/services/varavu_valam.py): `cloud/app/services/varavu_valam.py`
- [KANRU Risk Engine](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/core/kanru_engine.py): `cloud/core/kanru_engine.py`
- [KURAL Engine](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/core/kural/engine.py): `cloud/core/kural/engine.py`
- [KURAL Ingestion](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/core/kural/ingest.py): `cloud/core/kural/ingest.py`
- [Digital Twin Store](https://github.com/kanagugaming/marudhan-cloud-src/blob/main/cloud/db/database.py): `cloud/db/database.py`

### Other components

- **Farmer**
- **Cloud Service**

## Connections

- Sensor Device → Local MQTT Broker: publishes MQTT
- Edge Coordinator → Local MQTT Broker: uses broker (evidence: `edge/mfcu_main.py`)
- Edge Coordinator → Cloud Sync Queue: queues sync (evidence: `edge/mfcu_main.py`)
- Local MQTT Broker → AARU Rules: evaluates telemetry (evidence: `edge/local_broker.py`)
- Cloud Sync Queue → Telemetry API: POSTs telemetry (evidence: `edge/cloud_sync.py`)
- Cloud Service → Cloud API App: serves requests (evidence: `cloud/app/main.py`)
- Cloud API App → Service Router: mounts routes (evidence: `cloud/app/main.py`)
- Cloud API App → Farmer Chat API: mounts routes (evidence: `cloud/app/main.py`)
- Service Router → Request Schemas: validates payloads (evidence: `cloud/app/api/router.py`)
- Service Router → Telemetry Decisions: processes telemetry (evidence: `cloud/app/api/router.py`)
- Service Router → Drone Vision: analyzes imagery (evidence: `cloud/app/api/router.py`)
- Service Router → KURAL Responses: gets responses (evidence: `cloud/app/api/router.py`)
- Service Router → Digital Twin: gets twin state (evidence: `cloud/app/api/router.py`)
- Service Router → Farm Finance: calculates metrics (evidence: `cloud/app/api/router.py`)
- Farmer Chat API → KURAL NLP: handles queries (evidence: `cloud/app/api/farmer_chat.py`)
- Telemetry Decisions → Weather Context: fetches weather (evidence: `cloud/app/services/arivu_core.py`)
- Telemetry Decisions → PATHIVU Logging: logs telemetry (evidence: `cloud/app/services/arivu_core.py`)
- Legacy API App → Telemetry API: mounts router (evidence: `cloud/main.py`)
- Legacy API App → Digital Twin Store: opens connection (evidence: `cloud/main.py`)
- Telemetry API → Yield & Disease: processes telemetry (evidence: `cloud/api/endpoints.py`)
- Telemetry API → Digital Twin Store: reads and writes (evidence: `cloud/api/endpoints.py`)
- Farmer → Cloud API App: uses services
