Nandi backend API — Gin (Go). Handles auth, organizations, voice signaling, conversations, routing, and real-time events.
# Nandi API
Go API for Nandi, a multi-tenant customer engagement platform (Africa-first).
Module: `
github.com`
This repository is a modular monolith. The Next.js frontend is a separate product and talks to this API only over HTTP JSON (`/api/v1/...`) and WebSockets.
## What is implemented
The API is past the project skeleton. Auth, domain models, providers, inbox, campaigns, analytics, realtime, and optional AI are in this repo.
- Multi-tenant auth: register (creates tenant + owner), login, refresh, logout, JWT access tokens, hashed API keys
- Roles: `owner`, `admin`, `agent`
- Tenant-scoped domain: tenants, users, contacts, conversations, messages, campaigns, settings, provider logs
- ChannelProvider routing with Africa's Talking (SMS), Evolution (WhatsApp), and a local stub failover
- Inbound webhooks plus a `POST /api/v1/dev/inbound` simulator
- WebSocket hub with Redis Pub/Sub fan-out (`conversation_created`, `new_message`, presence, campaign updates)
- Optional Groq / OpenAI-compatible sentiment and conversation summary (AI failure never blocks persistence)
- Analytics overview, agent presence, and tenant settings
- Swagger UI and a Postman collection
## Stack
- Go 1.22+
- Gin
- GORM + PostgreSQL 16
- Redis 7 (Pub/Sub, presence)
- Viper + `.env`
- zerolog
- JWT (access + refresh) and hashed API keys
- ChannelProvider (Africa's Talking, Evolution, stub failover)
- Groq / OpenAI-compatible sentiment + summary
- swaggo/swag
## Layout
```
cmd/api/ process entrypoint
internal/config environment-based config
internal/database Postgres + Redis + AutoMigrate
internal/middleware request ID, logging, recovery, auth, CORS, limits
internal/handlers HTTP handlers (no business logic)
internal/services business logic
internal/repositories
internal/models tenant-scoped domain models
internal/providers ChannelProvider + Africa's Talking + Evolution + stub
internal/realtime WebSocket hub + Redis Pub/Sub
internal/ai …