Production-grade WhatsApp commerce assistant for small shops — POS, inventory, credit tracking, reports, and AI-assisted commands (Swahili + English).
- API: FastAPI + SQLAlchemy async
- Database: PostgreSQL 16
- Cache / sessions: Redis 7
- Workers: Celery + Beat
- AI fallback: Ollama (local LLM)
- Admin UI: React (Vite) in
dashboard/ - Mobile: Flutter in
mobile/
Full guide: docs/DEPLOYMENT.md
cp .env.production.example .env # edit secrets + Twilio credentials
chmod +x scripts/deploy.sh
./scripts/deploy.sh bot.yourdomain.comPoint Twilio webhook to https://bot.yourdomain.com/webhook.
cp .env.example .env
# Edit WHATSAPP_* and ALLOWED_PHONEScd docker
docker compose up -d postgres redis
docker compose up apipip install -r requirements.txt
alembic upgrade head
python scripts/seed_data.pyuvicorn app.main:app --reload --port 8000Set WHATSAPP_PROVIDER in .env:
| Provider | Best for | Webhook URL |
|---|---|---|
| twilio (default) | Dev sandbox, no Meta Business account | POST /webhook or /webhook/twilio |
| wati | SMB onboarding in East Africa / India | POST /webhook/wati |
| dialog360 | Production via Meta BSP partner | POST /webhook/dialog360 |
| meta | Direct Meta Cloud API (when approved) | GET/POST /webhook |
See docs/WHATSAPP_PROVIDERS.md for step-by-step setup.
Twilio Sandbox (quickest start):
- Create a Twilio account and open WhatsApp Sandbox.
- Set
TWILIO_ACCOUNT_SID,TWILIO_AUTH_TOKEN,TWILIO_WHATSAPP_FROM. - Point sandbox webhook to
https://<ngrok-host>/webhook. - Join sandbox from your phone, then message the bot.
Use ngrok for local dev: ngrok http 8000
cd docker
docker compose --profile ai up ollama -d
docker exec -it <ollama-container> ollama pull llama3.2cd dashboard
npm install
npm run devLogin with seeded owner phone and password changeme (set via seed).
cd mobile
flutter pub get
flutter run| Command | Example |
|---|---|
| Sell | sell 2 soda 1500 |
| Stock | stock add sugar 50 |
| Report | report today |
| Debt | debt john |
| Payment | paid john 5000 |
| Profit | profit today |
| Help | help |
| Method | Path | Description |
|---|---|---|
| GET | /health |
Health check |
| GET/POST | /webhook |
WhatsApp webhook |
| POST | /admin/auth/login |
JWT login |
| GET | /admin/products |
List products |
| GET | /admin/sales |
List sales |
| GET | /admin/reports |
Reports |
| POST | /admin/shops/onboard |
Create shop (SaaS) |
| GET | /metrics |
Prometheus metrics |
app/
api/ # Webhook, admin, billing routes
core/ # Config, security, middleware
database/ # Models + migrations
engines/ # POS, inventory, debt, reports, analytics
parser/ # Command parser + Ollama fallback
services/ # WhatsApp, Redis, sessions, OCR, voice
workers/ # Celery tasks
dashboard/ # React admin UI
mobile/ # Flutter companion app
docker/ # Dockerfile, compose, nginx
scripts/ # seed_data.py, backup.sh
pytest app/tests -v- Use
docker/docker-compose.prod.yml(migrations on startup, no dev reload) - HTTPS via Let's Encrypt — see docs/DEPLOYMENT.md
- Run
scripts/backup.shvia cron for PostgreSQL backups - Set
SENTRY_DSNfor error tracking
- Phase 1: WhatsApp webhook, parser, POS, inventory, reports
- Phase 2: Debt/credit, Ollama AI, Celery workers, analytics, React dashboard
- Phase 3: Multi-tenant onboarding, Stripe billing hooks, Flutter mobile, nginx
- Phase 4: Voice (Whisper), OCR receipts, forecasting, suppliers, loyalty/expenses modules