Logo Lanfrica

paulakelo/kenya-admin-boundaries-api

Domaine:

geospatial

Type de record:

software
Créateur:
pau
Hôte:
Kenya administrative and electoral boundaries geospatial API (Golang/PostgreSQL). # Kenya Admin Boundaries API A production-grade geospatial REST API mapping Kenya's administrative and electoral boundaries down to the constituency level. This project provides high-performance spatial queries, caching, and a clean JSON interface, built with a focus on Clean Architecture and scalable deployment. ## Tech Stack * **Backend:** Golang 1.25 (Clean Architecture) * **Web Framework:** Gin * **Database:** PostgreSQL 15 with PostGIS 3.3 * **Cache:** Redis 7 * **Database Interactions:** `sqlc` for type-safe SQL, `golang-migrate` for schema definitions * **Infrastructure:** Docker & Docker Compose ## Repository Structure The Go REST API is designed using strict separation of concerns: * `cmd/api/main.go` - The entry point and dependency injection wiring. * `internal/domain` - Core business models (e.g., County, SubCounty, Constituency). * `internal/repository/postgres` - `sqlc`-generated database interactions. * `internal/service` - Business logic and caching interfaces. * `internal/handler` - HTTP delivery, request binding, and JSON responses. * `migrations/` - Raw SQL definitions for the PostGIS tables. ## Getting Started ### Prerequisites * Docker & Docker Compose ### Quick Start 1. **Start the infrastructure:** ```bash docker compose up -d ``` This spins up the Go API (Port 18080), PostgreSQL/PostGIS (Port 5432), and Redis (Port 6379), using the overrides specified in `docker-compose.override.yml`. 2. **Access the API:** * Base URL: `127.0.0.1` * Routes: `127.0.0.1` * Health check: `127.0.0.1` ## Comprehensive API Documentation ### 1. Counties **`GET /api/v1/counties`** - **Description:** Returns a GeoJSON FeatureCollection of all 47 Kenyan counties with their polygons and metadata. **`GET /api/v1/counties/:slug`** - **Description:** Get a specific county boundary as a single GeoJSON Feature. - **Parameters:** - `slug` (string): The county code (e.g., `KE047` for Nairobi). **` …