← All work
Case study · BIOMETRIC IDENTITY

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.

ROLEBackend architect
CLIENTWorld Bank-supported vaccine subsidy programme
STATUSNationwide onboarding
STACKJava 17, Spring Boot 3, MariaDB, AWS S3 & EC2, Python ML services

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

  1. 01
    An 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.
  2. 02
    Two 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.
  3. 03
    Concurrency 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.
  4. 04
    Designing 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.
  5. 05
    A 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.
  6. 06
    Every 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.

~2Mcattle onboarded with a verifiable identity
768dimensions in every muzzle embedding
5stages from photo to digital ID

Skills demonstrated

ML pipeline integrationComputer visionVector similarity searchConcurrency controlAWS (S3, EC2)Partner APIs & SDKsJava ↔ Python services