WakiliPlus — Bridging the Justice Gap with AI & M-Pesa Escrow

Inspiration

In Kenya and across East Africa, navigating the legal ecosystem is often an uphill battle. Everyday citizens and MSMEs face significant hurdles:

  • The Discovery Barrier: Finding verified advocates tailored to specific practice areas across all 47 counties is opaque and relies mostly on unverified word-of-mouth.
  • The Trust & Pricing Deficit: Opaque fee structures cause friction between clients who fear overpaying and advocates who worry about non-payment for their consultation hours.
  • Legal Literacy Gap: The majority of citizens cannot afford preliminary legal advice to understand whether their grievance is actionable under Kenyan law. We asked ourselves: What if accessing legal consultation in Nairobi was as seamless, transparent, and trustworthy as making an M-Pesa transaction or calling an Uber? WakiliPlus was born to bridge this gap — uniting verified legal practitioners, localized AI assistance, and secure M-Pesa escrow into a single unified platform. --- ### What It Does WakiliPlus is an end-to-end digital legal ecosystem designed for clients, legal professionals (Advocates & Legal Consultants), and Law Firms:
  • AI Legal Intelligence (Kenyan Legal Context): Powered by Groq and Google Gemini, the AI assistant guides users through contract reviews, summarizes tenancy agreements, and routes them to the right legal specialization based on statutory Kenyan law.
  • Smart Marketplace & Advocate Discovery: Clients can search and filter vetted advocates by practice area, location (e.g., Nairobi, Mombasa, Kisumu), pricing, and verified Law Society of Kenya (LSK) credentials.
  • Built-in M-Pesa Escrow & Wallet: Eliminates payment mistrust using automated Safaricom Daraja STK Push integration. Funds are held securely in escrow until milestones or consultation sessions are completed: $$F_{\text{advocate}} = P_{\text{consultation}} \times (1 - \text{Platform Fee}) + E_{\text{escrow_release}}$$
  • Confidential Virtual Case Rooms: End-to-end encrypted collaboration workspaces featuring real-time messaging, scheduled video consultations, and anti-virus scanned document vaults.
  • Gamified Community Q&A ("Daily Verdict"): Promotes public legal literacy through daily interactive trivia and a community forum where verified lawyers earn reputation badges for answered queries. --- ### How We Built It We built WakiliPlus with a high-availability, asynchronous, and security-first architecture:
  • Backend: Built on Django 6.0 with Python 3.12+, orchestrated via Daphne (ASGI) to power real-time WebSockets for messaging and case rooms.
  • Database & State: PostgreSQL with transactional connection pooling and Redis for distributed pub/sub caching.
  • FinTech & Payments: Integrated Safaricom M-Pesa Daraja API (STK Push, C2B, and B2C automated settlement).
  • AI Stack: Multi-provider inference orchestration (Groq LLaMA-3 & Gemini) with custom prompt safety guards for Kenyan legal jurisprudence.
  • Security & Hygiene: Automated ClamAV scanning, PDF sanitization, and strict CSRF/CORS origin isolation.

- Networking & Live Demo: Tunneled via Cloudflare Tunnels (cloudflared) for zero-trust edge delivery and secure webhook ingress.

Challenges We Ran Into

  • Real-Time Asynchronous State in Django: Balancing ASGI WebSockets for real-time case rooms alongside Django's relational database transactions required strict isolation of consumer channels and atomic DB commits to avoid race conditions.
  • M-Pesa Webhook Ingress in Development: Safaricom Daraja requires publicly reachable HTTPS endpoints for transaction callbacks. We engineered a resilient Cloudflare tunnel bridge to securely stream callback packets directly to local development environments.
  • Legal Document Security & Malware Sanitization: Since users upload sensitive contracts and identity verification documents, ensuring immediate in-memory validation without slowing down the user experience required an asynchronous scanning pipeline. --- ###Accomplishments That We're Proud Of
  • Fully Working End-to-End User Flow: From asking an initial legal question, chatting with the AI advisor, booking an advocate, to settling an escrow consultation via M-Pesa.
  • Localized Experience: Tailored explicitly to Kenyan counties, practice areas, and statutory frameworks.

- Enterprise-Grade Clean Architecture: Production-ready codebase featuring modular Django apps, automated health checks, and canonical database seeding for instant demo testing.

What We Learned

  • How to design human-in-the-loop AI systems that provide accurate preliminary legal insights while strictly adhering to professional liability boundaries.
  • The importance of automated escrow mechanics in building two-sided marketplace trust in emerging markets.

- Best practices in tuning ASGI Daphne servers and Cloudflare edge proxies for low-latency real-time collaboration.

What's Next for WakiliPlus

  • USSD & WhatsApp AI Assistant: Bringing legal guidance to millions of Kenyans without regular internet or smartphone access.
  • e-Citizen & Judiciary API Linkage: Direct integration with Kenyan court filing and business registration registries.

- Multilingual Legal Models: Expanding AI translation and assistance into Swahili and local vernacular languages.

Judge Demo Accounts

| Role | Username | Password |

| Advocate (Verified) | canonical_advocate_mwangi | WakiliPlus123! | | Client | canonical_client_amina | WakiliPlus123! | | Firm Admin | canonical_firm_admin | WakiliPlus123! |

Built With

Share this project:

Updates