Logo Lanfrica

Xensfromtheeast/SasaAPI

Domain:

digital infrastructure

Record type:

software
Creator:
Xen
Host:
Africa's API Reseller # MpesaAI — AI API Proxy for Kenya OpenRouter AI models, billed via M-Pesa. Drop-in OpenAI-compatible API for Kenyan developers. ## Architecture ``` Internet → Nginx (SSL) → Next.js dashboard (port 3000) → FastAPI gateway (port 8000) ├── PostgreSQL (immutable ledger) ├── Redis (rate limiting, hold cache, job queue) └── Arq worker (billing finalization, hold reaper) ``` ## Prerequisites - VPS running Ubuntu 22.04+ (1 vCPU / 1 GB RAM minimum, 2 GB recommended) - Docker + Docker Compose v2 installed - A domain name with DNS A record pointing to the VPS - Accounts on: - Safaricom Developer Portal — Daraja API credentials - OpenRouter — AI API key - GitHub OAuth App and/or Google OAuth credentials (for NextAuth) --- ## Setup ### 1. Clone and configure ```bash git clone mpesa-ai-proxy cd mpesa-ai-proxy cp .env.example .env ``` Edit `.env` and fill in every value: | Variable | Description | |---|---| | `POSTGRES_USER` / `POSTGRES_PASSWORD` / `POSTGRES_DB` | Database credentials | | `DATABASE_URL` | Must match the above (format: `postgresql+asyncpg://user:pass@db:5432/dbname`) | | `REDIS_URL` | `redis://redis:6379/0` (no change needed unless you modify the service name) | | `OPENROUTER_API_KEY` | Your OpenRouter API key (`sk-or-...`) | | `DARAJA_CONSUMER_KEY` / `DARAJA_CONSUMER_SECRET` | From Safaricom Developer Portal | | `DARAJA_SHORTCODE` | Your M-Pesa PayBill or Till number | | `DARAJA_PASSKEY` | From Safaricom Developer Portal | | `DARAJA_CALLBACK_URL` | Must be publicly accessible: `yourdomain.com` | | `DARAJA_ENV` | `sandbox` for testing, `production` for live | | `KESUSD_RATE` | Current KES/USD exchange rate (e.g. `130.0`) | | `SECRET_KEY` | 32 random bytes hex: `openssl rand -hex 32` | | `NEXTAUTH_URL` | Your domain: `yourdomain.com` | | `NEXTAUTH_SECRET` | 32 random bytes base64: `openssl rand -base64 32` | | `GITHUB_CLIENT_ID` / `GITHUB_CLIENT_SECRET` | From GitHub OAuth App settings | | `GOOGLE_CLIENT_ID …

Languages