Full-stack livestock management platform built to replace Excel-based farm operations in Pakistan, with per-animal cost allocation across feed, health, and salary, profit/loss calculation at sale, FIFO stock control, and role-based access for farm staff.
Role
A sheep farmer in Pakistan was running a full livestock operation out of spreadsheets. Animals, pens, stock, health records, feed applications, and finances were all managed in Excel, and the system was breaking under its own weight. The core problem was not just inconvenience: without accurate per-animal cost tracking, the client had no reliable way to know what a sheep had cost by the time it was sold. Feed expenses, veterinary treatments, vaccinations, deworming, and proportional salary costs were never attributed to individual animals, so margins were consistently worse than they should have been.
A secondary consequence of the spreadsheet model was mortality. With no structured health history per animal, early warning signs went untracked. There was no visibility into which animals had received treatment, which were due for vaccination, or which were showing declining body condition scores. Animals were dying from conditions that structured data would have flagged earlier.
The brief was to replace the entire Excel operation with a purpose-built web platform: a livestock management system that tracked every animal through its full lifecycle, allocated costs automatically, calculated profit and loss at the point of sale, and gave the client the financial visibility to make decisions on real numbers. Cenciss designed and built the system from scratch, handling UI/UX, full-stack development, backend architecture, and deployment.
Per-animal cost allocation was the defining technical challenge of the system. Every time a feed recipe was applied to a pen, every health treatment, vaccination, deworming event, and every payroll cycle had to distribute its associated cost across the relevant animals automatically. This could not be a manual entry step. The allocation logic had to trigger at the point of record creation — a FeedApplication updating each animal's totalFeedCost, a Treatment updating totalHealthCost, a VaccineApplication updating totalVaccinationCost — so that the running cost on any animal reflected reality at any point in time without the operator doing arithmetic.
Profit and loss calculation at sale required that the total cost figure be reliable before it was surfaced to the operator. Purchase price plus all allocated running costs had to produce a cost basis the client could compare directly against the proposed selling price, so selling decisions could be made with full margin visibility rather than on instinct. The system also needed to present this calculation as a cost preview before the sale was confirmed, not just as a historical record afterward.
Mortality tracking required that a dead animal be handled correctly across the financial model, not just flagged as inactive. The full cost accumulated against that animal had to be recorded as a capital loss, attributed to the correct partners in the capital breakdown, and preserved with a death date and cause for retrospective analysis. The goal was not just accounting accuracy but building the historical health dataset that would let the client identify patterns and reduce future deaths.
FIFO stock management added inventory complexity across feed stock, medications, and farm assets. Stock deductions from feed recipe applications had to follow first-in-first-out rules, with low-stock alerts triggering before critical shortages occurred. Inaccurate stock accounting would cascade directly into inaccurate cost allocation, undermining the financial accuracy the entire system was built around.
Role-based access across four user types — Admin, Manager, Employee, and Viewer — had to be enforced server-side on every sensitive operation. Capital records, liability management, salary data, animal sales, and partner financials could not be accessible to all staff. JWT authentication with role-based middleware on API endpoints was non-negotiable, not a UI-level concern.
The backend was built on Node.js and Express.js with MongoDB and Mongoose, with a RESTful API architecture structured around the domain model of the farm operation. Mongoose models covered Animals, Pens, Stock, Employees, Capital, Liabilities, Treatments, Vaccinations, Dewormings, FeedRecipes, FeedApplications, VaccineRecipes, VaccineApplications, and their related audit entities. Pre- and post-save hooks on health and feed models handled automatic cost allocation to animal records at the point of creation, keeping the running cost figures accurate without requiring additional API calls or manual reconciliation.
Virtual fields on the Animal model computed cost, totalPrice, totalPricePerKg, and profitLoss on demand from the stored cost components, giving the sell flow and analytics layer a consistent source of truth for margin calculations. The Capital model implemented addTransaction, addLoss, and recordAnimalSale methods with partner breakdown logic for Partner 1, Partner 2, and Retained Earnings, giving the client a full financial picture with transaction history that updated automatically on animal purchases, sales, and deaths.
FIFO stock deduction was implemented at the feed application layer, consuming stock batches in order of entry and flagging low-stock conditions before supply ran out. Joi validated all inbound requests, Express Rate Limit controlled abuse, Winston handled structured application logging, and an audit trail logged all consequential actions for traceability and compliance review.
The React.js frontend was built with Tailwind CSS and a shared component library — Card, Table, Input, Select, Button, Badge, Modal, PageHeader, Spinner — delivering a consistent, responsive interface across all modules. The dashboard surfaced capital overview, animal and pen counts, stock status, employee summary, and asset totals with quick-action shortcuts. The Sell Animal flow presented a cost preview with purchase price, total allocated costs broken down by category, proposed selling price, and projected profit before the transaction was confirmed. Bulk animal import and bulk sale used XLSX-based Excel and CSV upload with template files, reducing the data entry burden for the client's existing records. Cloudinary handled animal images and invoice attachments via Multer for file ingestion.
The client moved from a spreadsheet operation with no cost visibility to a livestock management system where every animal carries an accurate, automatically maintained cost record from purchase through to sale or death. Selling decisions are now made against real margin data, and the improvement in pricing discipline translated directly into better returns on each animal sold.
Mortality dropped following the introduction of structured health tracking. With treatment histories, vaccination schedules, deworming records, body condition scores, and weight data centralized per animal, the client can see which animals need attention before a condition becomes critical. The audit trail on health events also gives retrospective visibility into patterns that previously went unnoticed.
Capital management with partner-level breakdowns replaced an informal accounting model with a structured financial record that both partners could review independently. Every purchase, sale, and death updates the capital position automatically, with full transaction history accessible at any time without manual reconciliation.
The four-role access model gave farm staff appropriate levels of visibility without exposing sensitive financial data to employees who did not need it. Bulk upload workflows reduced the data entry effort required to bring existing records into the system at onboarding and to process animal movements and sales efficiently at scale.
Tech Stack
Interested in a project like this?
Let's discuss your goals and map out the right solution.
Get in touchProject Details
Custom ecommerce platform built from scratch for a USA-based wholesale clothing brand. First online presence, global inventory booking, and a 15% increase in sales.
Full-stack hiring marketplace built for a Canadian client, featuring mandatory video resumes that let employers assess candidate personality and communication skills before the first interview.
Full redesign and rebuild for a Canadian accounting firm specializing in trucking taxation. New online forms, custom admin panel, persuasive copy, and a 30% increase in website traffic.