Predict. Detect. Recommend. Measure.
Status: Day 1–2 hand-coded baseline is complete and verified end-to-end.
Phase 1 (AI agents), Phase 2 (security), and Phase 3 (deployment scaffolding)
have now been added on top of it, per docs/UbuntuAI_5Day_Sprint_Plan.md.
- POPIA-aware anonymization threshold: municipality zone data now suppresses
any zone with fewer than
POPIA_MIN_ZONE_SIZE(default 5) households instead of exposing an "average" that's really just one or two households' exact readings. Verified live: a 2-household zone was correctly withheld while a 6-household zone showed normally, with suppression counts surfaced to municipality staff (not silently dropped). - PETCO-aligned waste taxonomy: waste classification now uses real South African recycling categories (PET plastic, HDPE plastic, glass, paper/ cardboard, metal, organic) instead of a generic "recyclable" bucket, each with actionable disposal guidance.
- Recycling locator:
GET /households/{id}/nearest-recycling-pointfinds the nearest drop-off point, using OpenRouteService for real driving distance ifORS_API_KEYis set, straight-line distance otherwise. Sample drop-off points only — seebackend/app/services/recycling_locator.pyfor what a real PETCO/municipal locator integration would need. - Mobile responsiveness: added a bottom tab bar for small screens (the previous nav would have overflowed below ~500px).
- Municipal open-data portal scaffold: a generic CKAN client
(
backend/data/ingestion/municipal_portal_loader.py) for the team to register real municipal portals as they're onboarded — genuinely open-ended, no portals are pre-registered.
- Full API: household usage, municipality KPIs, municipality zones (GeoJSON), and recommendation generation — all tested end-to-end against a real DB.
- Full frontend: Home, Household Dashboard (usage charts + recommendations), Municipality Dashboard (live map), Recommendations, Settings — all wired to the API.
- Prediction Agent: real linear-regression forecast with R²-based confidence
(
backend/app/agents/prediction_agent.py), replacing the Day 1-2 weighted-average stub. - Recommendation Agent: LLM-generated recommendation text via OpenAI/Azure OpenAI,
with automatic fallback to the rule-based template if no API key is set or the
call fails (
backend/app/agents/recommendation_agent.py) — the demo never breaks because of a missing key or rate limit. - Computer Vision Agent + real upload pipeline:
POST /waste/classifyaccepts a real photo upload (JPEG/PNG/WEBP, 8MB max), classifies it (YOLOv11 wrapper, falls back to a keyword classifier until the team trains/sources a model), stores the result, and feeds the household's most recent real classification into its waste recommendation — no more hardcoded demo item. Frontend has a working upload widget on the Household Dashboard. Verified end-to-end with a real image upload. - Research Agent: now runs on an actual schedule (in-process APScheduler,
configurable via
RESEARCH_REFRESH_INTERVAL_HOURS), not just on-demand, and logs every run's status/row-count/error toingestion_runsso failures are visible in the DB, not just server logs (backend/app/agents/research_agent.py,backend/app/scheduler.py). Added a 4th real source: OpenAQ (air quality), and gave Eskom an optional live-API path (EskomSePush) alongside its sample fallback. Open-Meteo remains the only source that's live by default with no key. - Knowledge Agent: real pgvector-backed retrieval — recommendations now cite
actual Eskom/NERSA/weather evidence instead of only "your last N readings"
(
backend/app/agents/knowledge_agent.py). Verified end-to-end against a real Postgres+pgvector instance: 118 chunks embedded and retrieved correctly. - LangGraph orchestration: recommendation generation now runs through a real
StateGraph(Knowledge -> Prediction -> Recommendation nodes) instead of plain sequential function calls, with a visible execution trace logged per request (backend/app/agents/orchestration.py). Verified live end-to-end. - Auth + RBAC: JWT-based register/login, applied to every data endpoint. Household users can only access their own household (auto-claimed on first login for the seeded demo data); municipality users can only access aggregated municipality endpoints. Verified live: 8/8 access-control test cases pass (no-token 401s, cross-user 403s, cross-role 403s, correct 200s).
- Audit logging middleware: logs method/path/status/timing, not request bodies
(POPIA-aware) —
backend/app/middleware/audit_log.py. - Deployment: Dockerfiles for both services, a full-stack
docker-compose.full.yml, and a GitHub Actions workflow that tests then deploys to Azure App Service.
- Recommendation Agent needs a real
OPENAI_API_KEY(or Azure endpoint) inbackend/.envto generate LLM text — without one it silently uses the rule-based fallback, which still demos fine. - CV Agent has no trained model yet —
WASTE_MODEL_PATHis unset, so it falls back to a keyword classifier applied to the uploaded filename. The upload pipeline (auth, storage, ownership checks, recommendation integration) is real and image- based; only the actual vision model is still a placeholder. - Browser Agent (live-site verification via browser-use + Playwright) is not
built yet — see the note at the bottom of
backend/app/agents/research_agent.py. - NERSA tariffs are still sample data — no stable public API exists, tariffs are published as PDFs/tables. Treat as a manual quarterly update for now.
- Eskom and OpenAQ use real live APIs if you set
ESKOM_API_KEY/OPENAQ_API_KEYin.env— without keys, both fall back to sample data. - In this sandboxed test environment,
api.open-meteo.comisn't reachable (network egress restrictions), so Open-Meteo always falls back to whatever CSV is already on disk here. It's a genuine live API call in a normal environment — test it in yours to confirm. - Found and fixed a real config bug while testing this phase:
pydantic-settingswas rejecting any.envvariable not explicitly declared as a Settings field (e.g. addingRESEARCH_AUTO_REFRESH=trueto.envwould crash the app on boot). Fixed inbackend/app/config.py. - Without a real
OPENAI_API_KEY, the Knowledge Agent still runs (storage + retrieval both work), but uses a deterministic non-semantic fallback embedding instead of a real one — so retrieval quality will be arbitrary rather than meaning-based until a key is set. docker-compose.ymlanddocker-compose.full.ymlnow build Postgres frombackend/Dockerfile.postgres(pgvector included) instead of the plain image — first build will take a few minutes longer since it compiles the extension.
UbuntuAI/
├── docs/ Sprint plan + API contract (finalized)
├── frontend/ React + TS + Vite + Tailwind + shadcn/ui + MapLibre
│ └── Dockerfile Production build → nginx
├── backend/ FastAPI + PostgreSQL (PostGIS, pgvector-ready)
│ ├── app/agents/ Phase 1 AI agents (prediction, recommendation, CV, research)
│ ├── app/auth/ Phase 2 JWT auth + RBAC
│ ├── app/middleware/ Phase 2 audit logging
│ └── Dockerfile Production build
├── docker-compose.full.yml Full local stack (frontend + backend + Postgres)
└── .github/workflows/deploy.yml CI: test + build → CD: Azure App Service
# Backend
cd backend
python -m venv venv && source venv/bin/activate
pip install -r requirements.txt
cp .env.example .env # add OPENAI_API_KEY if you want live LLM recommendations
docker compose up -d # starts Postgres
uvicorn app.main:app --reload --port 8000
# Frontend (separate terminal)
cd frontend
npm install
cp .env.example .env
npm run devcp backend/.env.example backend/.env # fill in real values
docker compose -f docker-compose.full.yml up --build
# frontend: http://localhost:5173 backend: http://localhost:8000/docs- Create two Azure App Service instances (Linux, container-based) — one for
backend, one forfrontend— plus an Azure Database for PostgreSQL (flexible server, with PostGIS enabled). - In GitHub → Settings → Secrets, add:
AZURE_BACKEND_APP_NAME,AZURE_BACKEND_PUBLISH_PROFILE,AZURE_FRONTEND_APP_NAME,AZURE_FRONTEND_PUBLISH_PROFILE(download publish profiles from the Azure portal). - Set backend
DATABASE_URL,SECRET_KEY, andOPENAI_API_KEYas Azure App Service Application Settings (never commit real secrets to.env). - Push to
main—.github/workflows/deploy.ymlruns tests, builds both services, and deploys automatically.
Full hour-by-hour sprint breakdown: docs/UbuntuAI_5Day_Sprint_Plan.md
Finalized API shapes: docs/api-contract.md