Web + USSD platform for verifying drug batch authenticity in Kenya. Lets pharmacists and buyers check batch numbers against a verified registry, report suspected counterfeits, and view confirmed alerts — designed for accessibility on both smartphones and feature phones via SMS/USSD (Africa's Talking).
# Halisi Backend API
Halisi is a counterfeit drug verification backend built in Go. It provides a robust, standalone HTTP service for public verification via web or USSD, alongside a complete administrative suite for monitoring reports, investigating suspicious batches, and broadcasting public health alerts.
## Architecture Overview
The API strictly adheres to a domain-driven architectural pattern (handler -> service ->
epository -> model), ensuring business logic is fully decoupled from HTTP transport concerns and raw SQL queries. We use chi for fast, idiomatic routing, pgxpool for high-performance PostgreSQL connection pooling without the overhead of an ORM, and golang-jwt/jwt/v5 for secure administrative authentication. All state-changing admin operations (like confirming a counterfeit batch and emitting an alert) are executed within atomic database transactions to guarantee an untampered audit trail.
## Prerequisites
- Docker and Docker Compose
- Go 1.22+ (if running locally without Docker)
## Setup and Running
1. **Environment Configuration**
Copy the example environment file and customize it if needed:
`ash
cp .env.example .env
`
2. **Start the Infrastructure**
Spin up the PostgreSQL database and the API using Docker Compose:
`ash
docker compose up -d
`
The API runs with ir for hot-reloading. You can access the API at
localhost.
3. **Run Migrations**
The schema migrations are available in the /migrations folder. If you are using golang-migrate:
`ash
migrate -path migrations -database "postgres://postgres:postgres@localhost:5432/halisi?sslmode=disable" up
`
4. **Seed the Database**
To experience the full capability of the API (including admin dashboards and the USSD flow), run the seed script to populate demo data:
`ash
go run cmd/seed/main.go
`
*Note: This script requires a valid DATABASE_URL in your .env file.*
## Environment Variables
| Variable | Description |
|---|---|
| DATABASE_URL | PostgreSQL connection string (e.g., postgres …