DEV Community

Gabriel Mahia
Gabriel Mahia

Posted on

The Loop That Creates Civilization Infrastructure

The Loop That Creates Civilization Infrastructure

There's a precise sentence in a system architecture document for East Africa that stops you:

"Technology alone rarely creates civilization. Civilization creates technology. So: Build with communities, not merely for communities."

That's the constraint that makes everything else in the document worth reading.


Two Architecture Documents, One Stack

The first document is an engineer's schematic: 7 agent types, 4 product modules, a 15-table data model, a 3-month MVP plan. It frames the whole thing as a "reusable coordination system" — not an app, not a chatbot.

The core loop:

Input → Structure → Retrieve → Reason → Verify → Act → Record → Improve
Enter fullscreen mode Exit fullscreen mode

The second document is a sovereignty blueprint. It argues that designing AI infrastructure for the Global South requires rejecting three assumptions:

  • Stable 1Gbps fiber
  • Corporate credit cards billed in USD
  • Uninterrupted access to Western cloud infrastructure

Its answer: Technological non-alignment. A 4-tier decoupled architecture that fails gracefully down to a purely local, offline state without data corruption.

Together they answer the question the 30-server MCP stack didn't fully address: how does this run in production, cheaply, reliably, when OpenAI goes down, when Anthropic applies export controls, when the power goes out in Marsabit?


The Tri-Polar Model Router

The most important technical contribution of the second document is the routing strategy.

One LiteLLM proxy. Three independent geopolitical infrastructure paths:

Western:    Claude Haiku / Gemini Flash      → complex reasoning
Eastern:    DeepSeek / Qwen (SiliconFlow)    → bulk, Swahili, <$0.14/M tokens  
Sovereign:  Llama 3.2 / Qwen (Ollama local)  → offline, sensitive data, free
Enter fullscreen mode Exit fullscreen mode

Switch the entire model stack by changing one environment variable. No OpenAI SDK, no Anthropic SDK, no Google SDK in core application code. If a provider goes dark, recovery requires changing a single string in litellm.yaml.

The budget constraint is hard: < $1.00/M tokens for all production tasks. High-cost frontier models are ring-fenced for rare auditing tasks only.

This is not idealism. It's engineering for a continent where export controls are a realistic risk, where mobile data costs money, and where a failed API call cannot mean a failed health navigation query.


The 7 Agent Types, Mapped

The first document identifies 7 agent types. Each one now maps to specific MCP servers in the stack:

Agent Model Tier MCP Tools
Research Eastern (cheap) habari-mcp · historia-mcp · soko-mcp · county-mcp
Form Eastern fomu-mcp · kra-mcp · diaspora-mcp · familia-mcp
Verification Western (high stakes) sifa-mcp · mkopo-mcp · fomu-mcp
Translation Sovereign (free) tafsiri-mcp
Financial Eastern mpesa-mcp · faida-mcp · kra-mcp · jumuia-mcp
Market Eastern soko-mcp · kilimo-mcp · sifa-mcp
Escalation Human (always HITL) church-mcp · haki-ya-kazi-mcp · afya-mcp

The Escalation Agent is the one that never gets automated. Legal advice, medical advice, land disputes, loan decisions — AI prepares, humans certify. The n8n workflow pauses and pings the operator via WhatsApp before any high-stakes action fires.


What "fomu-mcp" Does

One of the agent types produced a new MCP server: the Form Agent.

"Turns messy user answers into applications, checklists, letters."

pip install fomu-mcp — 6 tools:

  • form_checklist: complete requirements for any Kenya government process
  • form_draft_letter: generates introduction letters, reference letters, complaints, land inquiries
  • form_requirements_check: tells you what you have and what's missing
  • ecitizen_guide: eCitizen portal service directory
  • huduma_centre_guide: Huduma Centre locations by county
  • form_timeline_planner: sequences multiple processes with completion dates

This is the Form Agent made concrete. Every Kenya citizen filing for a business permit, a KRA PIN, an NHIF card, or a Certificate of Good Conduct needs exactly this: a structured checklist, a draft document, and a timeline. Previously this knowledge cost money or time to get.


The Real Moat

Both documents are explicit that the moat is not the model.

It's:

  • Local workflows — n8n DAGs hardcoded for Kenya processes (business permits, land searches, tax filing)
  • Trusted data — 32 MCPs encoding institutional knowledge Anthropic doesn't have
  • Community relationships — embedding in SACCOs, churches, county governments
  • Multilingual context — Swahili, Kikuyu, Luo via tafsiri-mcp
  • Institutional memory — audit_logs storing source, confidence, human_review_status for every output
  • Feedback from real users — the compounding loop that frontier labs cannot build from abroad

The audit_logs table in the database schema enforces this at the infrastructure level. Every AI output stores: source, confidence, date, agent_used, human_review_status, next_action. This prevents hallucination from becoming policy.


The Invariant That Matters Most

Both documents share one invariant that isn't technical:

"Build with communities, not merely for communities."

The catholicparishsteward app, the jumuia-mcp SACCO tools, the church-mcp religious institution layer — these aren't feature additions. They're the answer to the question: who maintains this after you deploy it?

Communities with existing institutional trust networks do. You build the infrastructure. They run it.


Stack:

sii-stack: github.com/gabrielmahia/sii-stack — Docker Compose: n8n + LiteLLM + Ollama + 32 MCPs

fomu-mcp: pip install fomu-mcp

Nairobi Stack: gabrielmahia.github.io/nairobi-stack

Top comments (0)