# sebas-ap/agrovia architecture

> Architecture diagram of the GitHub repository sebas-ap/agrovia, 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/sebas-ap/agrovia
- Repository: https://github.com/sebas-ap/agrovia

## Overview

AGROVÍA supports plot-specific agricultural decision-making: a farmer records a parcel, then reviews environmental indicators, crop-rotation strategies, economic scenarios, and VÍA explanations. The backend owns application decision logic and persistence; the Python Model supplies environmental data, crop evaluation, and predictions. The mobile UI has parcel, intelligence, and market modules, but the README describes it as a prototype not yet fully connected to the backend; sampled UI service code does show limited backend requests. Several backend and UI internals were not sampled, so those relationships are shown only where documented.

Main entry points: [`Backend/src/routes/plots.ts`](https://github.com/sebas-ap/agrovia/blob/main/Backend/src/routes/plots.ts) (Plot workflows), [`AppMovil/app-src/src/App.tsx`](https://github.com/sebas-ap/agrovia/blob/main/AppMovil/app-src/src/App.tsx) (App shell), [`Modelo/agrovia_api/service.py`](https://github.com/sebas-ap/agrovia/blob/main/Modelo/agrovia_api/service.py) (Evaluation service), [`AppMovil/app-src/src/services/index.ts`](https://github.com/sebas-ap/agrovia/blob/main/AppMovil/app-src/src/services/index.ts) (UI services)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_mobile["Mobile experience"]
  node_app["App shell<br/>[App.tsx]"]
  node_parcel_ui["My Plot<br/>[Parcel.tsx]"]
  node_intel_ui["Intelligence<br/>[Intel.tsx]"]
  node_market_ui["Market<br/>[Market.tsx]"]
  node_ui_services["UI services<br/>[index.ts]"]
  node_backend_client["API client<br/>[backend.ts]"]
end

subgraph group_backend["Backend decisions"]
  node_api["Express API<br/>[app.ts]"]
  node_plot_routes["Plot workflows<br/>[plots.ts]"]
  node_indicators["Indicators<br/>[index.ts]"]
  node_rotation["Rotation strategies<br/>[index.ts]"]
  node_economics["Economics<br/>[index.ts]"]
  node_via["VÍA assistant<br/>[index.ts]"]
  node_providers["Data providers<br/>[runtime.ts]"]
  node_model_adapter["Model integration<br/>[modeloClient.ts]"]
end

subgraph group_model["Environmental model"]
  node_model_api["Model API<br/>[main.py]"]
  node_model_service["Evaluation service<br/>[service.py]"]
  node_climate["NASA POWER<br/>[nasa_power.py]"]
  node_ndvi["MODIS NDVI<br/>[ornl_modis.py]"]
end

subgraph group_storage["Application data"]
  node_firestore[("Firestore<br/>[admin.ts]")]
end

node_farmer(("Farmer"))
node_external_nasa{{"NASA POWER service"}}
node_external_ornl{{"ORNL DAAC"}}
node_external_siap{{"SIAP prices"}}

node_farmer -->|"uses"| node_app
node_app -->|"renders"| node_parcel_ui
node_app -->|"renders"| node_intel_ui
node_app -->|"renders"| node_market_ui
node_parcel_ui -->|"requests data"| node_ui_services
node_market_ui -->|"requests data"| node_ui_services
node_ui_services -->|"calls"| node_backend_client
node_backend_client -.->|"HTTP requests"| node_api
node_api -->|"mounts"| node_plot_routes
node_plot_routes -.->|"computes"| node_indicators
node_plot_routes -.->|"generates"| node_rotation
node_plot_routes -.->|"recalculates"| node_economics
node_plot_routes -.->|"answers through"| node_via
node_plot_routes -.->|"persists"| node_firestore
node_providers -.->|"uses when live"| node_model_adapter
node_model_adapter -.->|"HTTP integration"| node_model_api
node_model_api -->|"delegates"| node_model_service
node_model_service -->|"fetches climate"| node_climate
node_model_service -->|"fetches NDVI"| node_ndvi
node_climate -->|"queries"| node_external_nasa
node_ndvi -->|"queries"| node_external_ornl
node_model_service -.->|"loads prices"| node_external_siap

click node_app "https://github.com/sebas-ap/agrovia/blob/main/AppMovil/app-src/src/App.tsx"
click node_parcel_ui "https://github.com/sebas-ap/agrovia/blob/main/AppMovil/app-src/src/screens/Parcel.tsx"
click node_intel_ui "https://github.com/sebas-ap/agrovia/blob/main/AppMovil/app-src/src/screens/Intel.tsx"
click node_market_ui "https://github.com/sebas-ap/agrovia/blob/main/AppMovil/app-src/src/screens/Market.tsx"
click node_ui_services "https://github.com/sebas-ap/agrovia/blob/main/AppMovil/app-src/src/services/index.ts"
click node_backend_client "https://github.com/sebas-ap/agrovia/blob/main/AppMovil/app-src/src/services/backend.ts"
click node_api "https://github.com/sebas-ap/agrovia/blob/main/Backend/src/app.ts"
click node_plot_routes "https://github.com/sebas-ap/agrovia/blob/main/Backend/src/routes/plots.ts"
click node_indicators "https://github.com/sebas-ap/agrovia/blob/main/Backend/src/engines/indicators/index.ts"
click node_rotation "https://github.com/sebas-ap/agrovia/blob/main/Backend/src/engines/rotation/index.ts"
click node_economics "https://github.com/sebas-ap/agrovia/blob/main/Backend/src/engines/economics/index.ts"
click node_via "https://github.com/sebas-ap/agrovia/blob/main/Backend/src/engines/via/index.ts"
click node_providers "https://github.com/sebas-ap/agrovia/blob/main/Backend/src/providers/runtime.ts"
click node_model_adapter "https://github.com/sebas-ap/agrovia/blob/main/Backend/src/integration/modeloClient.ts"
click node_firestore "https://github.com/sebas-ap/agrovia/blob/main/Backend/src/firestore/admin.ts"
click node_model_api "https://github.com/sebas-ap/agrovia/blob/main/Modelo/agrovia_api/main.py"
click node_model_service "https://github.com/sebas-ap/agrovia/blob/main/Modelo/agrovia_api/service.py"
click node_climate "https://github.com/sebas-ap/agrovia/blob/main/Modelo/agrovia_api/clients/nasa_power.py"
click node_ndvi "https://github.com/sebas-ap/agrovia/blob/main/Modelo/agrovia_api/clients/ornl_modis.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_app,node_parcel_ui,node_intel_ui,node_market_ui,node_ui_services,node_backend_client toneBlue
class node_api,node_plot_routes,node_indicators,node_rotation,node_economics,node_via,node_providers,node_model_adapter toneAmber
class node_model_api,node_model_service,node_climate,node_ndvi toneMint
class node_firestore toneRose
class node_farmer,node_external_nasa,node_external_ornl,node_external_siap toneIndigo
```

## Components

### Mobile experience

- [App shell](https://github.com/sebas-ap/agrovia/blob/main/AppMovil/app-src/src/App.tsx): `AppMovil/app-src/src/App.tsx`
- [My Plot](https://github.com/sebas-ap/agrovia/blob/main/AppMovil/app-src/src/screens/Parcel.tsx): `AppMovil/app-src/src/screens/Parcel.tsx`
- [Intelligence](https://github.com/sebas-ap/agrovia/blob/main/AppMovil/app-src/src/screens/Intel.tsx): `AppMovil/app-src/src/screens/Intel.tsx`
- [Market](https://github.com/sebas-ap/agrovia/blob/main/AppMovil/app-src/src/screens/Market.tsx): `AppMovil/app-src/src/screens/Market.tsx`
- [UI services](https://github.com/sebas-ap/agrovia/blob/main/AppMovil/app-src/src/services/index.ts): `AppMovil/app-src/src/services/index.ts`
- [API client](https://github.com/sebas-ap/agrovia/blob/main/AppMovil/app-src/src/services/backend.ts): `AppMovil/app-src/src/services/backend.ts`

### Backend decisions

- [Express API](https://github.com/sebas-ap/agrovia/blob/main/Backend/src/app.ts): `Backend/src/app.ts`
- [Plot workflows](https://github.com/sebas-ap/agrovia/blob/main/Backend/src/routes/plots.ts): `Backend/src/routes/plots.ts`
- [Indicators](https://github.com/sebas-ap/agrovia/blob/main/Backend/src/engines/indicators/index.ts): `Backend/src/engines/indicators/index.ts`
- [Rotation strategies](https://github.com/sebas-ap/agrovia/blob/main/Backend/src/engines/rotation/index.ts): `Backend/src/engines/rotation/index.ts`
- [Economics](https://github.com/sebas-ap/agrovia/blob/main/Backend/src/engines/economics/index.ts): `Backend/src/engines/economics/index.ts`
- [VÍA assistant](https://github.com/sebas-ap/agrovia/blob/main/Backend/src/engines/via/index.ts): `Backend/src/engines/via/index.ts`
- [Data providers](https://github.com/sebas-ap/agrovia/blob/main/Backend/src/providers/runtime.ts): `Backend/src/providers/runtime.ts`
- [Model integration](https://github.com/sebas-ap/agrovia/blob/main/Backend/src/integration/modeloClient.ts): `Backend/src/integration/modeloClient.ts`

### Environmental model

- [Model API](https://github.com/sebas-ap/agrovia/blob/main/Modelo/agrovia_api/main.py): `Modelo/agrovia_api/main.py`
- [Evaluation service](https://github.com/sebas-ap/agrovia/blob/main/Modelo/agrovia_api/service.py): `Modelo/agrovia_api/service.py`
- [NASA POWER](https://github.com/sebas-ap/agrovia/blob/main/Modelo/agrovia_api/clients/nasa_power.py): `Modelo/agrovia_api/clients/nasa_power.py`
- [MODIS NDVI](https://github.com/sebas-ap/agrovia/blob/main/Modelo/agrovia_api/clients/ornl_modis.py): `Modelo/agrovia_api/clients/ornl_modis.py`

### Application data

- [Firestore](https://github.com/sebas-ap/agrovia/blob/main/Backend/src/firestore/admin.ts): `Backend/src/firestore/admin.ts`

### Other components

- **Farmer**
- **NASA POWER service**
- **ORNL DAAC**
- **SIAP prices**

## Connections

- Farmer → App shell: uses (evidence: `README.md`)
- App shell → My Plot: renders (evidence: `AppMovil/app-src/src/App.tsx`)
- App shell → Intelligence: renders (evidence: `AppMovil/app-src/src/App.tsx`)
- App shell → Market: renders (evidence: `AppMovil/app-src/src/App.tsx`)
- My Plot → UI services: requests data (evidence: `AppMovil/app-src/src/screens/Parcel.tsx`)
- Market → UI services: requests data (evidence: `AppMovil/app-src/src/screens/Market.tsx`)
- UI services → API client: calls (evidence: `AppMovil/app-src/src/services/index.ts`)
- API client → Express API: HTTP requests
- Express API → Plot workflows: mounts (evidence: `Backend/src/app.ts`)
- Plot workflows → Indicators: computes (evidence: `README.md`)
- Plot workflows → Rotation strategies: generates (evidence: `README.md`)
- Plot workflows → Economics: recalculates (evidence: `README.md`)
- Plot workflows → VÍA assistant: answers through (evidence: `README.md`)
- Plot workflows → Firestore: persists (evidence: `README.md`)
- Data providers → Model integration: uses when live (evidence: `README.md`)
- Model integration → Model API: HTTP integration (evidence: `README.md`)
- Model API → Evaluation service: delegates (evidence: `Modelo/agrovia_api/main.py`)
- Evaluation service → NASA POWER: fetches climate (evidence: `Modelo/agrovia_api/service.py`)
- Evaluation service → MODIS NDVI: fetches NDVI (evidence: `Modelo/agrovia_api/service.py`)
- NASA POWER → NASA POWER service: queries (evidence: `Modelo/agrovia_api/clients/nasa_power.py`)
- MODIS NDVI → ORNL DAAC: queries (evidence: `Modelo/agrovia_api/clients/ornl_modis.py`)
- Evaluation service → SIAP prices: loads prices (evidence: `README.md`)
