Inspiration

African informal markets move fast but operate manually. Merchants on FairPrice.ng spend hours on tasks that should be instant — checking inventory, releasing escrow, chasing payouts, notifying buyers. We built ZEMA360 to automate all of it with AI agents backed by a database infrastructure that can scale with the business.

What it does

FairPrice.ng is a live escrow marketplace for Nigeria. ZEMA360 is the autonomous commerce OS built on top of it:

  • Ziva AI — natural language shopping assistant (Alibaba Qwen). Ask "I need an iPhone around ₦1m" and Ziva searches the live catalog, returns product cards with real prices, and starts negotiations
  • Ops Squad — multi-agent pipeline (Inventory → Fulfillment → Finance → Comms) that processes orders end-to-end: checks stock, updates tracking, releases escrow, triggers Paystack payouts, sends WhatsApp updates
  • Human-in-the-loop — large payouts and refunds pause for WhatsApp merchant approval before executing
  • Live dashboard at fairprice.ng/zema360/live — every agent decision logged to AWS DynamoDB, visible in real time with 5-second polling

How we built it

AWS DynamoDB is the core persistence layer for ZEMA360 agent logs. Every agent decision — tool call, approval request, payout trigger — writes to the zema360-agent-logs table (partition key: agent, sort key: ts). The table is auto-created on cold start via ensureTable() and uses PAY_PER_REQUEST billing. The live dashboard reads the last 30 events via a ScanCommand sorted by timestamp descending.

Vercel hosts the entire Next.js 15 App Router frontend. The ZEMA360 events API route (/api/zema360/events) runs as a Vercel Serverless Function with force-dynamic to bypass caching for real-time reads.

Full stack:

  • Frontend: Next.js 15 + Tailwind CSS + Framer Motion on Vercel
  • Database: AWS DynamoDB (agent logs) + Neon Postgres (orders, products, escrow, users)
  • AI: Alibaba Qwen qwen3-max via DashScope — multi-round tool-calling, automatic Gemini fallback
  • Payments: Paystack escrow + payout transfers
  • Comms: WhatsApp Business API
  • Analytics: Novus.ai — 37 track events across the full user journey

Challenges we ran into

  • DynamoDB schema design: Agent logs come in two shapes (ZemaEvent vs AgentLogEntry). Normalising both in the GET handler without a secondary index required careful field mapping
  • Real-time without WebSockets: Achieved near-real-time by polling /api/zema360/events every 5 seconds with AnimatePresence for smooth entry animations — no infrastructure overhead
  • Qwen3 thinking mode: qwen3-max routes output to reasoning_content instead of content for certain queries, causing silent JSON extraction failures. enable_thinking: false fixed it
  • Production safety: DynamoDB replaced only the Firebase log layer — Neon Postgres (core commerce data) was never touched

Accomplishments that we're proud of

  • DynamoDB table live in production (us-east-1), write+read confirmed, zero downtime migration from Firebase
  • The same Next.js API route serves both DynamoDB (primary) and Firebase (fallback) with automatic provider detection
  • Real-time agent dashboard with AnimatePresence running on a live marketplace with real Nigerian merchants and real orders
  • PAY_PER_REQUEST billing — costs literally $0 until traffic arrives, then scales automatically

What we learned

DynamoDB's single-table design shines for append-only event logs. PAY_PER_REQUEST billing with auto-created tables (ensureTable() on cold start) is the fastest path from zero to production. The hardest part wasn't the database — it was normalising two different event shapes from legacy Firebase and new DynamoDB writes without breaking the dashboard.

What's next

  • Move from ScanCommand to a GSI on ts for efficient time-range queries at scale
  • Aurora DSQL for the core commerce tables (orders, escrow) to get distributed SQL at DynamoDB scale
  • Alibaba Function Compute deployment for the Python orchestrator — full Alibaba + AWS + Vercel multi-cloud stack
  • Public enterprise API: POST /api/zema360/process-order with API key auth for other African marketplaces

Built With

  • alibaba-qwen
  • aws-dynamodb
  • framer-motion
  • neon-postgres
  • next.js
  • novus.ai
  • paystack
  • prisma
  • tailwind-css
  • typescript
  • vercel
  • whatsapp-business-api
Share this project:

Updates