Mifugo360: a digital identity for close to 2 million cattle
Muzzle-print biometrics that let a World Bank-supported vaccine subsidy programme verify every animal.
The problem
A subsidy programme needs to know every vaccinated animal is real and counted once. Ear tags are easy to fake, remove or transfer. A cattle muzzle print, like a fingerprint, is unique, stable for life, and can be photographed with a smartphone.
Identification had to be fast and reliable in the field, scale to close to 2 million cattle across Kenya, and connect to dairy cooperatives, banks and county veterinary offices.
Architecture
A Spring Boot backend orchestrates the biometric pipeline; detection and embedding models run as Python services on AWS. Images live in S3, animal records and embeddings in MariaDB.
What I built
- 01An end-to-end biometric pipelineMuzzles are located on-device or by a YOLO detection service (with a fallback model and cooldown), cropped to a normalised square, converted to a 768-dimension embedding, and matched by cosine similarity. I also built the in-process Java/PyTorch path that serves as a fallback.
- 02Two matching problems, two thresholdsRegistration flags probable duplicates only at high similarity (0.87), so real animals aren't blocked; field re-identification accepts more variation (0.3) for light, angle and mud. Flagged duplicates go to veterinary supervisors through a review workflow.
- 03Concurrency for busy onboarding daysA vet and an assistant can register animals for the same farmer at the same moment from different phones. A per-farmer lock, a database row lock, a separate transaction for ID assignment and deadlock retries with backoff keep IDs unique and registrations complete.
- 04Designing vector search for millions of animalsI designed the move to a dedicated FAISS index service: outbox-based sync so index and database never drift, farmer-, ward- and national-scoped indexes, and a feature-flag rollout from shadow mode to primary with database fallback.
- 05A partner ecosystemAn SDK with long-lived partner tokens for external onboarding organisations, asynchronous sync to a dairy cooperative so milk payments trace back to a verified animal, bank account opening via the core banking system, and resilient Excel imports of field workers.
- 06Every identification is traceableEach lookup records the original and cropped images, match, confidence, GPS location and the field agent who made it, and an AOP aspect logs per-endpoint latency without touching controller code.
Outcome
Close to 2 million cattle onboarded across Kenya, each with a verifiable identity for subsidy disbursement and tracking.
The registry connects to a livestock research body, a dairy partner, a bank and the E-Voucher subsidy platform.