# sachinacharya08/geoagrilink architecture

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

- Interactive diagram: https://gitdiagram.com/sachinacharya08/geoagrilink
- Repository: https://github.com/sachinacharya08/geoagrilink
- Video tour (about a minute): https://gitdiagram.com/sachinacharya08/geoagrilink/video

## Overview

This is a GeoAgriLink agricultural platform API: farmers manage farms and production, inspect satellite-derived conditions and AI analyses, trade produce, and use a conversational assistant. The main interaction path is a user request into the API domain handlers; the chatbot can retrieve authorized farm, crop, insight, and marketplace data, or prepare writes that require confirmation. The README describes a generic template API and does not document these domain features, so the graph relies on sampled source and the source index. Unsampled route wiring is omitted.

Main entry points: [`apps/chatbot/tools/registry.py`](https://github.com/sachinacharya08/geoagrilink/blob/main/apps/chatbot/tools/registry.py) (Tool Registry), [`apps/chatbot/services/gemini.py`](https://github.com/sachinacharya08/geoagrilink/blob/main/apps/chatbot/services/gemini.py) (Gemini Chat), [`apps/chatbot/tools/writes.py`](https://github.com/sachinacharya08/geoagrilink/blob/main/apps/chatbot/tools/writes.py) (Prepared Actions), [`apps/marketplaces/models.py`](https://github.com/sachinacharya08/geoagrilink/blob/main/apps/marketplaces/models.py) (Products and Orders)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_identity["Identity"]
  node_user_api["User API<br/>[views.py]"]
  node_user_service["User Service<br/>[services.py]"]
  node_users[("User Records<br/>[models.py]")]
end

subgraph group_agriculture["Farm and Crop Data"]
  node_farm_api["Farm API<br/>[views.py]"]
  node_farm_service["Farm Service<br/>[services.py]"]
  node_farm_records[("Farm and History<br/>[models.py]")]
  node_earth_engine["Satellite Analysis<br/>[gee_services.py]"]
  node_crop_api["Crop API<br/>[views.py]"]
  node_crop_records[("Crop and Production<br/>[models.py]")]
end

subgraph group_insights["Insights and Assistant"]
  node_insight_api["Insight API<br/>[views.py]"]
  node_insight_records[("AI Insights<br/>[models.py]")]
  node_vegetation_ai{{"Vegetation AI"}}
  node_chat_api["Chat API<br/>[views.py]"]
  node_chat_service["Gemini Chat<br/>[gemini.py]"]
  node_chat_prompts["Assistant Prompts<br/>[prompts.py]"]
  node_chat_tools["Tool Registry<br/>[registry.py]"]
  node_chat_writes["Prepared Actions<br/>[writes.py]"]
  node_chat_records[("Chat and Pending Actions<br/>[models.py]")]
end

subgraph group_commerce["Marketplace"]
  node_market_api["Marketplace API<br/>[views.py]"]
  node_market_service["Order Service<br/>[services.py]"]
  node_market_records[("Products and Orders<br/>[models.py]")]
end

node_farmer(("Farmer"))
node_gee{{"Google Earth Engine"}}
node_gemini{{"Google Gemini"}}
node_django_db[("Application Database")]

node_farmer -->|"requests account actions"| node_user_api
node_user_api -.->|"delegates account logic"| node_user_service
node_user_service -->|"creates and updates"| node_users
node_farmer -.->|"manages farms"| node_farm_api
node_farm_service -->|"reads and stores history"| node_farm_records
node_farm_service -->|"fetches measurements"| node_earth_engine
node_earth_engine -.->|"queries satellite data"| node_gee
node_farm_service -->|"posts index payload"| node_vegetation_ai
node_farmer -.->|"manages production"| node_crop_api
node_farmer -.->|"requests insights"| node_insight_api
node_farmer -.->|"asks farming questions"| node_chat_api
node_chat_api -->|"dispatches chat"| node_chat_service
node_chat_service -->|"uses instructions"| node_chat_prompts
node_chat_service -->|"invokes tools"| node_chat_tools
node_chat_service -.->|"sends model requests"| node_gemini
node_chat_api -->|"handles confirmations"| node_chat_writes
node_chat_writes -->|"creates pending actions"| node_chat_records
node_chat_tools -->|"queries production data"| node_crop_records
node_chat_tools -->|"queries farm data"| node_farm_records
node_chat_tools -->|"queries insight data"| node_insight_records
node_chat_tools -->|"queries listings and orders"| node_market_records
node_chat_writes -->|"prepares production records"| node_crop_records
node_chat_writes -->|"prepares listings and orders"| node_market_records
node_farmer -.->|"trades produce"| node_market_api
node_market_api -->|"creates orders"| node_market_service
node_market_service -->|"writes order and stock"| node_market_records
node_users -.->|"persists records"| node_django_db
node_farm_records -.->|"persists records"| node_django_db
node_crop_records -.->|"persists records"| node_django_db
node_insight_records -.->|"persists records"| node_django_db
node_chat_records -.->|"persists records"| node_django_db
node_market_records -.->|"persists records"| node_django_db

click node_user_api "https://github.com/sachinacharya08/geoagrilink/blob/main/apps/users/views.py"
click node_user_service "https://github.com/sachinacharya08/geoagrilink/blob/main/apps/users/services.py"
click node_users "https://github.com/sachinacharya08/geoagrilink/blob/main/apps/users/models.py"
click node_farm_api "https://github.com/sachinacharya08/geoagrilink/blob/main/apps/farms/views.py"
click node_farm_service "https://github.com/sachinacharya08/geoagrilink/blob/main/apps/farms/services.py"
click node_farm_records "https://github.com/sachinacharya08/geoagrilink/blob/main/apps/farms/models.py"
click node_earth_engine "https://github.com/sachinacharya08/geoagrilink/blob/main/apps/farms/gee_services.py"
click node_crop_api "https://github.com/sachinacharya08/geoagrilink/blob/main/apps/crops/views.py"
click node_crop_records "https://github.com/sachinacharya08/geoagrilink/blob/main/apps/crops/models.py"
click node_insight_api "https://github.com/sachinacharya08/geoagrilink/blob/main/apps/ai_insights/views.py"
click node_insight_records "https://github.com/sachinacharya08/geoagrilink/blob/main/apps/ai_insights/models.py"
click node_chat_api "https://github.com/sachinacharya08/geoagrilink/blob/main/apps/chatbot/views.py"
click node_chat_service "https://github.com/sachinacharya08/geoagrilink/blob/main/apps/chatbot/services/gemini.py"
click node_chat_prompts "https://github.com/sachinacharya08/geoagrilink/blob/main/apps/chatbot/services/prompts.py"
click node_chat_tools "https://github.com/sachinacharya08/geoagrilink/blob/main/apps/chatbot/tools/registry.py"
click node_chat_writes "https://github.com/sachinacharya08/geoagrilink/blob/main/apps/chatbot/tools/writes.py"
click node_chat_records "https://github.com/sachinacharya08/geoagrilink/blob/main/apps/chatbot/models.py"
click node_market_api "https://github.com/sachinacharya08/geoagrilink/blob/main/apps/marketplaces/views.py"
click node_market_service "https://github.com/sachinacharya08/geoagrilink/blob/main/apps/marketplaces/services.py"
click node_market_records "https://github.com/sachinacharya08/geoagrilink/blob/main/apps/marketplaces/models.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_user_api,node_user_service,node_users toneBlue
class node_farm_api,node_farm_service,node_farm_records,node_earth_engine,node_crop_api,node_crop_records,node_django_db toneAmber
class node_insight_api,node_insight_records,node_vegetation_ai,node_chat_api,node_chat_service,node_chat_prompts,node_chat_tools,node_chat_writes,node_chat_records toneMint
class node_market_api,node_market_service,node_market_records toneRose
class node_farmer,node_gee,node_gemini toneIndigo
```

## Components

### Identity

- [User API](https://github.com/sachinacharya08/geoagrilink/blob/main/apps/users/views.py): `apps/users/views.py`
- [User Service](https://github.com/sachinacharya08/geoagrilink/blob/main/apps/users/services.py): `apps/users/services.py`
- [User Records](https://github.com/sachinacharya08/geoagrilink/blob/main/apps/users/models.py): `apps/users/models.py`

### Farm and Crop Data

- [Farm API](https://github.com/sachinacharya08/geoagrilink/blob/main/apps/farms/views.py): `apps/farms/views.py`
- [Farm Service](https://github.com/sachinacharya08/geoagrilink/blob/main/apps/farms/services.py): `apps/farms/services.py`
- [Farm and History](https://github.com/sachinacharya08/geoagrilink/blob/main/apps/farms/models.py): `apps/farms/models.py`
- [Satellite Analysis](https://github.com/sachinacharya08/geoagrilink/blob/main/apps/farms/gee_services.py): `apps/farms/gee_services.py`
- [Crop API](https://github.com/sachinacharya08/geoagrilink/blob/main/apps/crops/views.py): `apps/crops/views.py`
- [Crop and Production](https://github.com/sachinacharya08/geoagrilink/blob/main/apps/crops/models.py): `apps/crops/models.py`

### Insights and Assistant

- [Insight API](https://github.com/sachinacharya08/geoagrilink/blob/main/apps/ai_insights/views.py): `apps/ai_insights/views.py`
- [AI Insights](https://github.com/sachinacharya08/geoagrilink/blob/main/apps/ai_insights/models.py): `apps/ai_insights/models.py`
- **Vegetation AI**
- [Chat API](https://github.com/sachinacharya08/geoagrilink/blob/main/apps/chatbot/views.py): `apps/chatbot/views.py`
- [Gemini Chat](https://github.com/sachinacharya08/geoagrilink/blob/main/apps/chatbot/services/gemini.py): `apps/chatbot/services/gemini.py`
- [Assistant Prompts](https://github.com/sachinacharya08/geoagrilink/blob/main/apps/chatbot/services/prompts.py): `apps/chatbot/services/prompts.py`
- [Tool Registry](https://github.com/sachinacharya08/geoagrilink/blob/main/apps/chatbot/tools/registry.py): `apps/chatbot/tools/registry.py`
- [Prepared Actions](https://github.com/sachinacharya08/geoagrilink/blob/main/apps/chatbot/tools/writes.py): `apps/chatbot/tools/writes.py`
- [Chat and Pending Actions](https://github.com/sachinacharya08/geoagrilink/blob/main/apps/chatbot/models.py): `apps/chatbot/models.py`

### Marketplace

- [Marketplace API](https://github.com/sachinacharya08/geoagrilink/blob/main/apps/marketplaces/views.py): `apps/marketplaces/views.py`
- [Order Service](https://github.com/sachinacharya08/geoagrilink/blob/main/apps/marketplaces/services.py): `apps/marketplaces/services.py`
- [Products and Orders](https://github.com/sachinacharya08/geoagrilink/blob/main/apps/marketplaces/models.py): `apps/marketplaces/models.py`

### Other components

- **Farmer**
- **Google Earth Engine**
- **Google Gemini**
- **Application Database**

## Connections

- Farmer → User API: requests account actions (evidence: `README.md`)
- User API → User Service: delegates account logic
- User Service → User Records: creates and updates (evidence: `apps/users/services.py`)
- Farmer → Farm API: manages farms
- Farm Service → Farm and History: reads and stores history (evidence: `apps/farms/services.py`)
- Farm Service → Satellite Analysis: fetches measurements (evidence: `apps/farms/services.py`)
- Satellite Analysis → Google Earth Engine: queries satellite data
- Farm Service → Vegetation AI: posts index payload (evidence: `apps/farms/services.py`)
- Farmer → Crop API: manages production
- Farmer → Insight API: requests insights
- Farmer → Chat API: asks farming questions
- Chat API → Gemini Chat: dispatches chat (evidence: `apps/chatbot/views.py`)
- Gemini Chat → Assistant Prompts: uses instructions (evidence: `apps/chatbot/services/gemini.py`)
- Gemini Chat → Tool Registry: invokes tools (evidence: `apps/chatbot/services/gemini.py`)
- Gemini Chat → Google Gemini: sends model requests
- Chat API → Prepared Actions: handles confirmations (evidence: `apps/chatbot/views.py`)
- Prepared Actions → Chat and Pending Actions: creates pending actions (evidence: `apps/chatbot/tools/writes.py`)
- Tool Registry → Crop and Production: queries production data (evidence: `apps/chatbot/tools/registry.py`)
- Tool Registry → Farm and History: queries farm data (evidence: `apps/chatbot/tools/registry.py`)
- Tool Registry → AI Insights: queries insight data (evidence: `apps/chatbot/tools/registry.py`)
- Tool Registry → Products and Orders: queries listings and orders (evidence: `apps/chatbot/tools/registry.py`)
- Prepared Actions → Crop and Production: prepares production records (evidence: `apps/chatbot/tools/writes.py`)
- Prepared Actions → Products and Orders: prepares listings and orders (evidence: `apps/chatbot/tools/writes.py`)
- Farmer → Marketplace API: trades produce
- Marketplace API → Order Service: creates orders (evidence: `apps/marketplaces/views.py`)
- Order Service → Products and Orders: writes order and stock (evidence: `apps/marketplaces/services.py`)
- User Records → Application Database: persists records
- Farm and History → Application Database: persists records
- Crop and Production → Application Database: persists records
- AI Insights → Application Database: persists records
- Chat and Pending Actions → Application Database: persists records
- Products and Orders → Application Database: persists records
