Uganda Farm-to-Table Intelligence Platform
# AgriBridge Uganda
Farm-to-table agri-tech platform connecting Ugandan smallholder farmers directly to
buyers — crops **and** livestock — with live market prices, an AI crop/animal doctor,
delivery tracking, reviews, mobile-money payments, and USSD access for basic phones.
- **Live site:**
agribrige.com
- **Backend API:**
agribridge-1-og7a.onrender.…
- **USSD:** `*789#`
> New here? Read this file for how the system works, then **GO-LIVE.md** for the
> accounts/keys/toggles needed to turn everything on.
---
## 1. Architecture at a glance
```
Buyers / Farmers (phone or web)
│
┌───────────┴────────────┐
│ │
Web app (PWA) USSD / SMS
static/index.html *789#
│ │
│ (direct, PostgREST) │ (HTTP)
▼ ▼
Supabase Flask backend (app.py)
Postgres + Auth on Render
+ Storage + RLS · USSD + SMS (Africa's Talking)
▲ · AI assistant (Groq)
│ · Payments (Flutterwave)
└───────── service role ─┘
```
**Key idea:** the web app talks **directly** to the database through Supabase's
auto-generated REST API (PostgREST), using a *publishable* key that is meant to be
public. Security is enforced entirely by **Row Level Security (RLS)** policies in the
database — not by hiding the key. The Flask backend handles only the things a browser
can't: USSD/SMS, the AI proxy, and payment webhooks.
---
## 2. Tech stack
| Layer | Technology | Hosting |
|-------|-----------|---------|
| Web app | Single-file HTML/CSS/JS + PWA (`manifest.json`, `sw.js`) | Cloudflare Pages (from GitHub) |
| Database / Auth / Storage | Supabase (Postgres, GoTrue auth, Storage, PostgREST) | Supabase cloud (project `vyrctsiyaihsysgpozdm`) |
| Backend API | Python Flask (`app.py`) | Render (service `agribridge-1`) |
| SMS / USSD | Africa's Talking | — |
| AI assistant | Groq (`llama-3.3-70b-versatile`) | via backend |
| Payments | Flutterwave (plug …