HomeCase studiesAR Livestock Morphometric Measurement & Herd Management...

Case study · Chicago, United States

AR Livestock Morphometric Measurement & Herd Management System

Agricultural technology — livestock and herd management

Weighing livestock on mechanical chute scales stresses animals, slows handling crews, and is impossible out on open pasture. We built a native Swift iOS application powered by ARKit alongside a Laravel, MySQL, and Google Cloud backend secured with Laravel Passport OAuth and connected via Alamofire. Ranchers capture non-contact body dimensions—heart girth, hip height, and frame length—to estimate live weight and sync longitudinal growth, health, and pedigree records across distributed herds.

Industry
Agricultural technology — livestock and herd management
Solution
A native Swift iOS augmented reality measurement and herd capture app synchronized via Alamofire and OAuth2 to a Laravel and MySQL platform hosted on Google Cloud.
Platforms
iOS · Web & API
Stack
Laravel · PHP · MySQL · Swift · Google Cloud · Passport
Location
Chicago, United States · delivered remotely
Role
Engineering, with the team behind for mobile and QA

Delivered remotely for a business based in Chicago, United States. Names withheld by agreement.

Project Overview

Tracking body condition, growth velocity, and frame development is central to profitable livestock stewardship. Yet gathering reliable weights on working ranches traditionally meant herding cattle down alleys onto mechanical load-cell scales—a process that induces handling stress, risks injury, and offers no practical way to check animals dispersed across remote summer pastures.

We engineered a non-contact augmented reality measurement and herd intelligence platform anchored by a native Swift iOS client and a Laravel API running on Google Cloud. Using ARKit spatial tracking, producers capture key anatomical dimensions visually from a safe working distance, translate them into breed-adjusted weight estimates, and synchronize longitudinal herd records over Alamofire and Laravel Passport OAuth2 into a centralized MySQL repository.

Field & Data Bottlenecks

Ranching software operates under unforgiving physical constraints:

  • Invasive manual weighing: Moving heavy animals solely to verify feed-conversion gains wastes crew hours and triggers transient weight shrink from handling stress.
  • Unstructured paper & ear-tag logs: Vaccination dates, sire lineages, and visual condition scores frequently live in pocket notebooks or disconnected chute-side spreadsheets that never merge cleanly.
  • Harsh optical & network environments: Outdoor sunlight, moving animals, and zero LTE coverage miles from the ranch headquarters quickly break brittle camera utilities and synchronous web forms.
  • Multi-party herd access: Owner-operators, feedlot nutritionists, and consulting veterinarians need controlled slices of the same animal history without sharing raw database exports.

Architectural Strategy

We divided responsibilities cleanly between high-precision edge geometry in Swift and authoritative herd state in Laravel. Attempting live AR computation through cross-platform JavaScript bridges introduces frame jitter and awkward memory pressure; writing the mobile app natively in Swift gave us direct command over ARKit world tracking, LiDAR depth confidence maps, and Metal overlays.

On the server side, Laravel paired with Passport OAuth2 and MySQL on Google Cloud enforces tenant isolation across ranches while maintaining a strict separation between raw measured millimeters and derived weight estimates. Storing pure anatomical dimensions ensures that as nutritionists refine breed-specific weight coefficients over time, historical records remain mathematically comparable.

Core Capabilities

  • ARKit Non-Contact Morphometrics: Guided camera reticles help handlers mark heart girth, body length, hip height, and rump width with distance-quality warnings if camera angles skew.
  • Offline Chute & Pasture Capture: Ear-tag entries, RFID/EID paired IDs, AR measurements, and treatment doses save immediately on device and sync opportunistically in the background.
  • Longitudinal Animal Profiles: MySQL links every individual animal across pasture moves, medical treatments, calving events, and weight-gain curves.
  • Breed-Calibrated Weight Modeling: Configurable formulas translate raw frame geometry into live weight estimates tailored to cattle classes and age brackets.
  • Role-Scoped Team Sharing: Ranchers grant temporary or persistent OAuth-protected access to veterinarians and buyers from the Laravel web portal.

Technical Architecture

During an AR capture session, the Swift client initializes an ARKit world-tracking configuration, continuously evaluating ambient light and feature-point density. Once the operator places measurement anchors, the app records millimeter vectors, camera intrinsics, and a reference frame, queuing the payload locally. When connectivity is available, Alamofire refreshes OAuth2 tokens via Laravel Passport if needed, submits structured JSON to Laravel endpoints on Google Cloud, and uploads verification imagery directly to Google Cloud Storage via signed URLs.

Flow: Swift ARKit Session (LiDAR / Depth Raycast) → Local Capture Queue → Alamofire HTTP Client (OAuth2 Interceptor) → Laravel Passport API on Google Cloud → MySQL Herd Ledger & Google Cloud Storage

Keeping heavy image transfers off PHP worker threads via direct-to-bucket signed URLs prevents photo bursts from starving API endpoints when crews return to barn Wi-Fi after a full day in the field.

Technology Stack

Category Technology detail
iOS Application Swift native app leveraging ARKit depth and spatial raycasting
iOS Networking Alamofire with custom OAuth request adapter and retry interceptor
Backend Framework Laravel (PHP 8.x REST API and herd administration portal)
API Authentication Laravel Passport providing OAuth2 authorization and refresh tokens
Relational Database MySQL storing animal IDs, morphometrics, treatments, and lineages
Cloud Infrastructure Google Cloud (managed compute, object storage, and load balancing)
Media Storage Google Cloud Storage buckets with signed upload/download URLs
Background Jobs Laravel Queues for cohort weight projections and export generation

Engineering Trade-offs & Solutions

Engineering Challenge Solution & Trade-off
Maintaining measurement accuracy when cattle shift mid-capture Locked depth snapshots onto a frozen frame buffer with tilt and distance guardrails; trades one extra operator tap to freeze motion for far tighter spatial repeatability.
Cross-platform code reuse versus native AR sensor fidelity Committed to native Swift on iOS rather than cross-platform wrappers, prioritizing deterministic ARKit/LiDAR performance over sharing UI code with Android.
OAuth token expiry during multi-hour offline pasture work Built an Alamofire RequestInterceptor using Passport refresh tokens with serialized refresh locking so queued background uploads renew sessions cleanly without prompting the user.
Querying multi-generation pedigree and weight histories at scale Normalized animal identity, movement, and measurement tables in MySQL with composite ranch-and-tag indexes, avoiding sluggish EAV schemas during cohort reporting.

Security & Reliability

Herd genetics, veterinary histories, and inventory counts represent sensitive commercial ranch assets. Laravel Passport enforces OAuth2 flows with fine-grained scopes separating read-only veterinary inspection, field measurement submission, and administrative ranch billing. All API transport runs exclusively over TLS terminating at Google Cloud load balancers.

To protect field work against unexpected app termination or expired tokens, Alamofire serializes pending measurement batches safely and retries transient 5xx or timeout responses with jittered backoff. Idempotency identifiers on measurement payloads guarantee that flaky rural handoffs never double-count a weighing event.

Performance & Scale

ARKit pipelines consume substantial GPU and battery resources if left active across menus. The Swift client suspends camera and depth tracking immediately when operators navigate away from the measurement viewfinder and downsamples verification thumbnails before queuing uploads.

On Google Cloud, Laravel serves stateless API instances behind autoscaling load balancers while read-heavy cohort analytics and CSV/PDF herd exports execute on background queue workers against indexed MySQL tables. Signed Cloud Storage URLs offload binary bandwidth entirely from application containers.

Operational Outcomes

Integrating augmented reality capture directly into herd record-keeping removed friction between physical animal handling and digital management:

  • Lower handling stress: Producers check growth trajectories and readiness weights without repeatedly running timid or pregnant stock across mechanical scales.
  • Cleaner chute-to-office continuity: Measurements, ear-tag updates, and health treatments enter a single MySQL system of record automatically once devices regain signal.
  • Verifiable measurement auditability: Storing raw AR geometry alongside reference frames lets managers review outlier measurements rather than guessing at transcription typos.
  • Seamless multi-ranch collaboration: Veterinarians and herd managers work from shared, permission-scoped animal histories instead of reconciling emailed spreadsheets.

01 — Questions

asked about this kind of project

How does an iOS app measure livestock accurately when animals shift position?

The Swift capture pipeline uses ARKit spatial tracking paired with LiDAR depth when available, sampling anchor rays only during frames that pass motion-stability thresholds. Operators place anatomical landmarks rapidly over a stabilized preview frame while the app validates camera-to-animal distance and viewing angle.

Why build the mobile client natively in Swift instead of using a cross-platform wrapper?

Low-latency ARKit session control, LiDAR point-cloud access, and reliable frame-buffer processing under bright outdoor glare require direct Metal and ARKit APIs. Native Swift avoids bridge overhead during real-time camera tracking and preserves battery life during long working-pen sessions.

How does Alamofire handle intermittent connectivity out on grazing pastures?

Measurements, ear-tag scans, and treatment notes persist locally first and enter a prioritized sync queue. Alamofire request interceptors detect offline errors, handle OAuth token refresh transparently via Laravel Passport upon reconnection, and upload pending records without duplicating animal events.

How are livestock measurements converted into weight estimates?

Morphometric dimensions such as heart girth and body length feed breed-calibrated allometric formulas maintained on the Laravel backend and cached on device. Separating raw millimeter measurements from weight coefficients lets agronomists refine breed equations without invalidating historical capture geometry.

How does Laravel Passport secure access across multiple ranches and external veterinarians?

Passport issues OAuth2 access tokens scoped to ranch tenant IDs and role capabilities. Visiting veterinarians can receive time-bounded credentials limited to health logs and measurement reads without gaining access to herd sales or financial records.

What role does Google Cloud play in handling field imagery and backups?

Reference frames captured during AR measurements upload directly to Google Cloud Storage via short-lived signed URLs issued by Laravel, keeping heavy binary payloads off PHP application servers while providing durable regional replication.

03 — Similar project?

describe what is different about yours

Build yours.

Tell me what exists, what you need and the deadline. Fixed price for a defined scope, or $55/day (8–9 hours work) with a written plan first.

Solitaire Corporate Park, Makarba, Ahmedabad, Gujarat 380015, India · IST (UTC+5:30) · --:-- IST · Mon–Fri 09:00–18:00 IST · US & EU overlap daily

No newsletter, no CRM. Just a reply.