Replai_PRD_v2.docx

Replai

AI customer support and commerce platform

Product Requirements Document · v2.0

Status Stack WhatsApp AI Phases
PRD Complete React + Flask Africa's Talking Groq Llama 3 10 Total

1. Overview & Purpose

The Problem

Most African businesses run on WhatsApp.

Customers text at 3am. Nobody replies. Sales die.

Replai fixes this — an AI agent that knows your business, handles customers, takes orders, and confirms M-Pesa payments while you sleep.


What It Is

A multi-tenant AI customer support and commerce platform delivered as:


Who It's For

Small Business Owners

Developers


Why It's Different

Not a generic chatbot.

Replai’s agent understands:

And handles real commerce:


Market

Every African business running on WhatsApp:

Millions of businesses still have zero 24/7 support infrastructure.


Built By

Isaac Bakari Juma
Jaribu Tech Solutions


2. Key Decisions Locked

Area Decision
Frontend React + TailwindCSS
Backend Flask + PostgreSQL + SQLAlchemy + Marshmallow
AI Model Groq (Llama 3)
WhatsApp v1 Africa's Talking
WhatsApp v2 Become direct Meta BSP
Payments M-Pesa Daraja + Paystack
Multi-tenancy Full tenant isolation
Inventory (Small Biz) Manual dashboard catalogue
Inventory (Developer) API inventory sync
Authentication JWT + API Keys + bcrypt
Trial System 14-day free Pro trial
Super Admin Separate secured admin portal
Pricing Freemium

3. Users & Their Goals

Small Business Owner

Goals


Developer

Goals


Super Admin (Isaac)

Goals


4. Features & Scope

AI Agent Capabilities

Customer Support

Commerce


Business Onboarding Flow

Sign up
→ Verify email
→ Describe business
→ Add products
→ Connect WhatsApp
→ Trial starts

Developer Onboarding Flow

Sign up
→ Verify email
→ Get API key
→ Sync inventory
→ Set webhooks
→ Trial starts

Business Dashboard

Features


Order & Payment Flow

Customer orders via chat
→ Agent creates order + reference
→ Sends M-Pesa instructions
→ Customer pays
→ Daraja webhook fires
→ Payment matched
→ Customer confirmed
→ Owner notified
→ Order appears in dashboard

Channels (v1)


Out of Scope (v1)


5. Sample Conversation

Boutique Shoe Shop — 3AM

Customer

Habari, mna Nike Air Force 1 size 42 nyeupe?

Replai Agent

Habari! Ndio, Nike AF1 size 42 white iko. Bei KES 8,500. Delivery au pickup?

Customer

Delivery. Niko Kasarani

Replai Agent

Order summary:

Nike AF1 size 42 white — KES 8,500
Delivery Kasarani — KES 200

Total = KES 8,700

Lipa:
Till 247247
Ref: ORD-4821

Confirm hapa baada ya kulipa.

Customer

Nimelipa

Replai Agent

KES 8,700 confirmed!
Order ORD-4821
Delivery Kasarani
Expected leo 2–4pm.

Asante!


6. Database Schema

tenants

Field
id
business_name
type
plan
api_key
whatsapp_number
payment_type
payment_number
agent_context
is_active

products

Field
id
tenant_id
name
description
price
stock_count
is_available
created_at

inventory_sync

Field
id
tenant_id
webhook_url
sync_mode
last_synced_at

orders

Field
id
tenant_id
order_ref
customer_phone
items
total_amount
delivery_location
delivery_fee
payment_status
payment_method
mpesa_transaction_id
order_status
created_at

payments

Field
id
tenant_id
order_id
amount
mpesa_ref
payment_type
confirmed_at

conversations

Field
id
tenant_id
customer_phone
messages
status
last_message_at

users

Field
id
tenant_id
email
password_hash
role

trials

Field
id
tenant_id
started_at
expires_at
status
days_remaining

platform_settings

Field
key
value
updated_at
updated_by

admin_users

Field
id
email
password_hash
role

7. API Routes

Public & Tenant Routes

Method Route Purpose Auth
POST /auth/register Register account Public
POST /auth/login Login Public
GET /dashboard/conversations Tenant conversations JWT
GET /dashboard/orders Tenant orders JWT
GET /dashboard/products Product inventory JWT
POST /dashboard/products Add product JWT
PATCH /dashboard/products/:id Edit product JWT
DELETE /dashboard/products/:id Delete product JWT
POST /dashboard/agent Update AI context JWT
GET /dashboard/trial Trial status JWT
POST /webhooks/whatsapp/:id Incoming WhatsApp AT Signature
POST /webhooks/mpesa/:id Daraja callback Daraja
POST /api/chat Developer chat API API Key
POST /api/inventory/sync Inventory sync API Key
GET /api/orders Fetch orders API Key

Super Admin Routes

Method Route Purpose Auth
POST /admin/login Admin login Public
GET /admin/tenants View tenants Admin JWT
PATCH /admin/tenants/:id Manage tenant Admin JWT
GET /admin/trials View trials Admin JWT
PATCH /admin/trials/:id Modify trial Admin JWT
GET /admin/settings Platform settings Admin JWT
PATCH /admin/settings/:key Update settings Admin JWT
GET /admin/analytics Platform analytics Admin JWT

8. Folder Structure

replai/

├── client/
│   ├── src/pages/
│   ├── src/dashboard/
│   ├── src/developer/
│   └── src/admin/

├── server/
│   ├── models/
│   ├── schemas/
│   ├── routes/
│   ├── services/
│   ├── config.py
│   └── extensions.py

├── widget/
├── migrations/
├── main.py
├── requirements.txt
└── .env

9. Environment Variables

Variable Purpose
DATABASE_URL PostgreSQL DB
JWT_SECRET_KEY Tenant JWT secret
ADMIN_JWT_SECRET Admin JWT secret
GROQ_API_KEY Groq AI
AT_API_KEY Africa's Talking
AT_USERNAME Africa's Talking username
AT_WHATSAPP_NUMBER WhatsApp sender
DARAJA_CONSUMER_KEY Daraja key
DARAJA_CONSUMER_SECRET Daraja secret
DARAJA_SHORTCODE M-Pesa shortcode
PAYSTACK_SECRET_KEY Billing
REPLAI_API_KEY_SECRET API key salt
FRONTEND_URL Tenant frontend
ADMIN_URL Admin frontend

10. Build Phases

Phase Focus
1 Foundation
2 AI Agent Core
3 WhatsApp Integration
4 Orders & Payments
5 Business Dashboard
6 Developer API
7 Web Widget
8 Landing + Onboarding
9 Trial System
10 Super Admin Panel

11. Trial Flow

Why It Matters

Businesses need to experience value before paying.

14-day Pro access:


Trial Timeline

Day Event
Day 0 Trial starts
Day 7 Reminder email
Day 12 Upgrade urgency
Day 14 Downgrade to free tier
Post-expiry Upgrade restores Pro

Super Admin Trial Controls


12. Pricing Roadmap

Free Plan


Pro Plan — KES 2,500/month


API Plan — KES 0.50/message


Trial Policy

Every signup gets:

Controlled dynamically through:
platform_settings

No redeploy required.


Status

Replai PRD v2.0

✅ Approved and ready to build


Next Step

Phase 1 — Foundation


Built by Isaac Bakari Juma
Jaribu Tech Solutions
jumaisaq@gmail.com

Powered by Forestry.md