# 🌾 Smart-Shamba: Local Analytics Lakehouse for Agricultural Decisions
A complete, local-first analytics lakehouse that provides data-driven crop planting recommendations for Ugandan smallholder farmers.
---
## đź“– Project Overview
**Problem:** Farmers make planting decisions based on intuition, leading to losses from weather volatility and market fluctuations.
**Solution:** Smart-Shamba integrates weather, vegetation health (NDVI), and market price data to generate explainable, district-level crop recommendations.
**Tech Stack:** 100% free-tier tools running locally
- **Orchestration:** Mage.ai
- **Storage:** DuckDB
- **Transformation:** dbt Core
- **Visualization:** Streamlit
- **Language:** Python & SQL
---
## 🏗️ Architecture
```
External APIs → Mage.ai → DuckDB (Raw) → dbt (Transform) → Streamlit
↓
Business Logic
↓
Crop Recommendations
```
### Data Flow (ELT Pattern)
1. **Extract & Load:** Mage pipelines pull data from APIs and load into DuckDB raw tables
2. **Transform:** dbt models clean data (staging) and apply business rules (marts)
3. **Analyze:** Streamlit dashboard visualizes recommendations
---
## đź“‚ Project Structure
```
smart-shamba-lakehouse/
│
├── requirements.txt # Python dependencies
├── setup_project.py # Automated setup script
├── .env.template # Environment variables template
│
├── mage_load_weather.py # Weather data loader
├── mage_load_prices.py # Price data loader
├── mage_load_vegetation.py # Vegetation data loader
│
├── warehouse/
│ └── duckdb/
│ └── agri_analytics.db # DuckDB database file
│
├── dbt/
│ ├── dbt_project.yml # dbt configuration
│ ├── profiles.yml # Database connection config
│ ├── dbt_sources.yml # Raw data sources
│ │
│ └── models/
│ ├── staging/
│ │ ├── dbt_stg_weather.sql # Clean weather data
│ │ ├── dbt_stg_prices.sql # Clean price data
│ │ └── dbt_stg_vegetat …