# fistonuzabumwana/rcei-platform architecture

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

- Interactive diagram: https://gitdiagram.com/fistonuzabumwana/rcei-platform
- Repository: https://github.com/fistonuzabumwana/rcei-platform

## Overview

RCEI is a Rwanda clean-cooking policy decision platform. The main user workflow is viewing district baselines, configuring a subsidy scenario, reviewing projected impacts and forecasts, then exporting policy or research outputs. Its domain spans survey-data preparation, model training, API-backed district analysis and simulation, and interactive presentation. The README documents broader agricultural bioeconomy and carbon-finance capabilities. Backend implementation details are limited in the excerpts, so those connections rely on documented behavior rather than inspected endpoint code.

Main entry points: [`frontend/src/App.tsx`](https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/App.tsx) (Dashboard orchestration), [`frontend/src/components/MapView.tsx`](https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/components/MapView.tsx) (District map), [`backend/app/main.py`](https://github.com/fistonuzabumwana/rcei-platform/blob/main/backend/app/main.py) (REST API), [`frontend/src/components/SimulationResults.tsx`](https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/components/SimulationResults.tsx) (Impact results)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Policy dashboard"]
  node_app["Dashboard orchestration<br/>[App.tsx]"]
  node_map["District map<br/>[MapView.tsx]"]
  node_leaderboard["District leaderboard"]
  node_matrix["District explorer"]
  node_simulator["Subsidy controls<br/>[Simulator.tsx]"]
  node_results["Impact results"]
  node_forecast["Trajectory chart<br/>[ForecastChart.tsx]"]
  node_methodology["Methodology view"]
  node_theme_toggle["Theme toggle<br/>[ThemeToggle.tsx]"]
  node_theme["Theme state<br/>[ThemeContext.tsx]"]
  node_geojson["District boundaries"]
end

subgraph group_backend["Analysis API"]
  node_api_client["API client<br/>[api.ts]"]
  node_service["REST API<br/>[main.py]"]
  node_district_data["District metrics"]
  node_model_artifact["Trained model<br/>[adoption_model.pkl]"]
end

subgraph group_modeling["Data and modeling"]
  node_cleaning["Survey preparation<br/>[clean_eicv.py]"]
  node_training["Model training<br/>[train_model.py]"]
end

subgraph group_exports["Policy outputs"]
  node_csv["Research CSV export<br/>[csvExport.ts]"]
  node_pdf["Policy brief PDF<br/>[pdfExport.ts]"]
end

node_planner(("Policy user"))

node_planner -->|"uses"| node_app
node_app -->|"requests data and simulations"| node_api_client
node_api_client -->|"calls REST API"| node_service
node_service -->|"serves district metrics"| node_district_data
node_service -->|"uses for simulation"| node_model_artifact
node_app -->|"renders"| node_map
node_app -->|"renders"| node_leaderboard
node_app -->|"renders"| node_matrix
node_app -->|"renders"| node_simulator
node_app -->|"renders"| node_results
node_results -->|"renders"| node_forecast
node_app -->|"renders"| node_methodology
node_app -->|"renders"| node_theme_toggle
node_theme_toggle -->|"uses"| node_theme
node_map -->|"reads theme"| node_theme
node_map -->|"loads boundaries"| node_geojson
node_app -->|"generates policy brief"| node_pdf
node_app -->|"exports district data"| node_csv
node_cleaning -.->|"prepares model data"| node_training
node_training -.->|"produces model"| node_model_artifact

click node_app "https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/App.tsx"
click node_map "https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/components/MapView.tsx"
click node_leaderboard "https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/components/DistrictLeaderboard.tsx"
click node_matrix "https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/components/DistrictMatrixTable.tsx"
click node_simulator "https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/components/Simulator.tsx"
click node_results "https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/components/SimulationResults.tsx"
click node_forecast "https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/components/ForecastChart.tsx"
click node_methodology "https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/components/MethodologyModal.tsx"
click node_theme_toggle "https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/components/ThemeToggle.tsx"
click node_theme "https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/context/ThemeContext.tsx"
click node_geojson "https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/public/rwanda_districts.geojson"
click node_api_client "https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/services/api.ts"
click node_service "https://github.com/fistonuzabumwana/rcei-platform/blob/main/backend/app/main.py"
click node_district_data "https://github.com/fistonuzabumwana/rcei-platform/blob/main/backend/app/data/processed/district_metrics.json"
click node_model_artifact "https://github.com/fistonuzabumwana/rcei-platform/blob/main/backend/app/core/adoption_model.pkl"
click node_cleaning "https://github.com/fistonuzabumwana/rcei-platform/blob/main/backend/pipeline/clean_eicv.py"
click node_training "https://github.com/fistonuzabumwana/rcei-platform/blob/main/backend/pipeline/train_model.py"
click node_csv "https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/services/csvExport.ts"
click node_pdf "https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/services/pdfExport.ts"

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_map,node_leaderboard,node_matrix,node_simulator,node_results,node_forecast,node_methodology,node_theme_toggle,node_theme,node_geojson,node_planner toneBlue
class node_api_client,node_service,node_district_data,node_model_artifact toneAmber
class node_cleaning,node_training toneMint
class node_csv,node_pdf toneRose
```

## Components

### Policy dashboard

- [Dashboard orchestration](https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [District map](https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/components/MapView.tsx): `frontend/src/components/MapView.tsx`
- [District leaderboard](https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/components/DistrictLeaderboard.tsx): `frontend/src/components/DistrictLeaderboard.tsx`
- [District explorer](https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/components/DistrictMatrixTable.tsx): `frontend/src/components/DistrictMatrixTable.tsx`
- [Subsidy controls](https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/components/Simulator.tsx): `frontend/src/components/Simulator.tsx`
- [Impact results](https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/components/SimulationResults.tsx): `frontend/src/components/SimulationResults.tsx`
- [Trajectory chart](https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/components/ForecastChart.tsx): `frontend/src/components/ForecastChart.tsx`
- [Methodology view](https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/components/MethodologyModal.tsx): `frontend/src/components/MethodologyModal.tsx`
- [Theme toggle](https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/components/ThemeToggle.tsx): `frontend/src/components/ThemeToggle.tsx`
- [Theme state](https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/context/ThemeContext.tsx): `frontend/src/context/ThemeContext.tsx`
- [District boundaries](https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/public/rwanda_districts.geojson): `frontend/public/rwanda_districts.geojson`

### Analysis API

- [API client](https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/services/api.ts): `frontend/src/services/api.ts`
- [REST API](https://github.com/fistonuzabumwana/rcei-platform/blob/main/backend/app/main.py): `backend/app/main.py`
- [District metrics](https://github.com/fistonuzabumwana/rcei-platform/blob/main/backend/app/data/processed/district_metrics.json): `backend/app/data/processed/district_metrics.json`
- [Trained model](https://github.com/fistonuzabumwana/rcei-platform/blob/main/backend/app/core/adoption_model.pkl): `backend/app/core/adoption_model.pkl`

### Data and modeling

- [Survey preparation](https://github.com/fistonuzabumwana/rcei-platform/blob/main/backend/pipeline/clean_eicv.py): `backend/pipeline/clean_eicv.py`
- [Model training](https://github.com/fistonuzabumwana/rcei-platform/blob/main/backend/pipeline/train_model.py): `backend/pipeline/train_model.py`

### Policy outputs

- [Research CSV export](https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/services/csvExport.ts): `frontend/src/services/csvExport.ts`
- [Policy brief PDF](https://github.com/fistonuzabumwana/rcei-platform/blob/main/frontend/src/services/pdfExport.ts): `frontend/src/services/pdfExport.ts`

### Other components

- **Policy user**

## Connections

- Policy user → Dashboard orchestration: uses (evidence: `README.md`)
- Dashboard orchestration → API client: requests data and simulations (evidence: `frontend/src/App.tsx`)
- API client → REST API: calls REST API (evidence: `README.md`)
- REST API → District metrics: serves district metrics (evidence: `README.md`)
- REST API → Trained model: uses for simulation (evidence: `README.md`)
- Dashboard orchestration → District map: renders (evidence: `frontend/src/App.tsx`)
- Dashboard orchestration → District leaderboard: renders (evidence: `frontend/src/App.tsx`)
- Dashboard orchestration → District explorer: renders (evidence: `frontend/src/App.tsx`)
- Dashboard orchestration → Subsidy controls: renders (evidence: `frontend/src/App.tsx`)
- Dashboard orchestration → Impact results: renders (evidence: `frontend/src/App.tsx`)
- Impact results → Trajectory chart: renders (evidence: `frontend/src/components/SimulationResults.tsx`)
- Dashboard orchestration → Methodology view: renders (evidence: `frontend/src/App.tsx`)
- Dashboard orchestration → Theme toggle: renders (evidence: `frontend/src/App.tsx`)
- Theme toggle → Theme state: uses (evidence: `frontend/src/components/ThemeToggle.tsx`)
- District map → Theme state: reads theme (evidence: `frontend/src/components/MapView.tsx`)
- District map → District boundaries: loads boundaries (evidence: `frontend/src/components/MapView.tsx`)
- Dashboard orchestration → Policy brief PDF: generates policy brief (evidence: `frontend/src/App.tsx`)
- Dashboard orchestration → Research CSV export: exports district data (evidence: `frontend/src/App.tsx`)
- Survey preparation → Model training: prepares model data
- Model training → Trained model: produces model
