AUTOMATE REALITY LABS
Back to All ArticlesCase Study

Building DairyStream Cloud: Architecture Decisions for a Multi-Tenant SaaS Platform

A deep technical case study on how we designed DairyStream Cloud — from multi-tenant data isolation and real-time quality testing to automated dispatch logistics.

Swapnil Patil · Founder & Principal ArchitectAugust 20, 202612 min read

DairyStream Cloud started with a simple observation: India's dairy supply chain — the largest in the world — still runs on paper registers, manual phone calls, and disconnected WhatsApp groups. Procurement managers track thousands of daily milk collections across dozens of chilling centers using handwritten ledgers. Quality testing results (FAT, SNF, CLR) are recorded manually, dispatch logistics are coordinated through phone calls, and farmer payments are reconciled in spreadsheets.

We set out to build a unified cloud platform that digitizes the entire procurement-to-payment workflow — not as a generic ERP bolt-on, but as a purpose-built system designed around the specific operational rhythms of dairy cooperatives in Maharashtra.

Multi-Tenant Architecture: Isolating Without Fragmenting

DairyStream serves multiple dairy cooperatives, each with their own collection centers, farmers, pricing models, and quality thresholds. We chose a shared-database, schema-isolated multi-tenant architecture using PostgreSQL's Row-Level Security (RLS) policies. Every query is automatically scoped to the authenticated tenant — no data leakage is architecturally possible, not just prevented by application logic.

This approach gives us the deployment simplicity of a single codebase while maintaining the data isolation guarantees that enterprise dairy cooperatives require. Each tenant can configure their own FAT/SNF pricing matrices, collection schedules, and farmer payment cycles without affecting other tenants.

Real-Time Quality Testing Integration

Milk quality testing happens at the point of collection — every liter is tested for fat content (FAT), solid-not-fat (SNF), and CLR readings using electronic milk analyzers. DairyStream integrates directly with these analyzers via serial/USB protocols, automatically capturing test results and linking them to the specific farmer, collection center, and batch.

This eliminates manual transcription errors that historically caused payment disputes between cooperatives and farmers. The system flags anomalous readings in real-time, enabling immediate re-testing rather than discovering discrepancies days later during reconciliation.

Automated Dispatch & Route Optimization

Once milk is collected and tested, it needs to move to processing plants within strict cold-chain timelines. DairyStream's dispatch module aggregates collection volumes across centers, calculates optimal tanker routing based on capacity and distance, and generates digital dispatch notes with real-time GPS tracking.

The system has processed over 50,000 collection entries and continues to scale across cooperatives in Maharashtra. Every architectural decision — from RLS-based tenancy to real-time analyzer integration — was driven by first-principles analysis of how dairy operations actually work on the ground.

Topics
SaaS architecturemulti-tenant systemsdairy industrycloud platformscase study

Written By

Swapnil Patil

Founder & Principal Architect · AutomateRealityLabs

Building software systems and intelligent automation for businesses across Maharashtra, India.