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.