AI-assisted veterinary dispatch call centre — River Poultry / SmartVet Africa
# SmartVet AI Call Centre
AI-assisted veterinary dispatch call centre for River Poultry / SmartVet Africa. Agents handle inbound farmer calls, track symptoms in real time, get instant AI disease diagnosis, and dispatch field vets — with a full escalation chain (L1 Agent → L2 Paravet → L3 Vet → L4 Emergency).
---
## Architecture
```
smartvet-ai-callcenter/
├── frontend/ React 18 + Vite + Tailwind CSS (port 5174)
└── backend/ Node.js + Express + PostgreSQL (port 4600)
```
### Frontend (Vite + React)
- **State**: Zustand (`authStore`, `callStore`)
- **Routing**: React Router v6
- **Realtime**: WebSocket via `useWebSocket` hook
- **Theme**: Dark olive (River Poultry brand), light mode supported
### Backend (Express ESM)
- **Auth**: JWT (8h expiry) + bcryptjs
- **Database**: PostgreSQL via `pg` — 6 sequential migrations
- **Realtime**: `ws` library, keyed per agentId
- **AI Diagnosis**: Local offline engine (`diseaseDiagnosis.js`) — 10 poultry diseases — with pluggable external model via `AI_MODEL_URL`
- **Core API**: Proxies to live Django backend at `smartvet.africa` for farmer/vet data
### Database migrations (run in order)
| File | Purpose |
|------|---------|
| 001_initial_schema.sql | Core tables: agents, calls, dispatch |
| 002_farmers_vets.sql | Farmer/vet/call_symptoms tables + seeds |
| 003_batches_tasks.sql | Farm batches and scheduled tasks |
| 004_enrich_schema.sql | Schema enrichments |
| 005_escalation_inventory.sql | Escalation levels + vet_inventory |
| 006_warehouse_inventory.sql | Central warehouse + stock allocations |
---
## Local Development
### Prerequisites
- Node.js 18+
- PostgreSQL 14+
### Backend
```bash
cd backend
cp .env.example .env # fill in values
npm install
npm run migrate # run all migrations
npm run dev # starts on :4600
```
### Frontend
```bash
cd frontend
cp .env.example .env.local # set VITE_API_BASE_URL if needed
npm install
npm run dev # starts o …