Problem
Traditional campus store systems create friction during peak academic hours: long queues during breaks, manual order handling, inventory mismanagement, and zero real-time visibility into orders and stock. Students and faculty waste valuable time in lines while store staff struggle with demand spikes during lunch breaks and exam periods.
The client needed a modern digital ordering platform built for a campus environment: real-time order management, seamless digital payments, efficient inventory handling, and multi-role access for customers and store administrators.
Constraints
- Android, iOS, and Web from a single codebase
- Real-time order synchronization across all connected devices
- Seamless digital payments for Indian payment systems (UPI, wallets, cards)
- Reliable performance during peak campus rush hours
- Offline resilience for unstable campus WiFi
- Multi-role support for students, faculty, and store staff
- Scalable inventory management with stock protection mechanisms
Approach
Built MRCAS Café as a complete digital campus store ecosystem using Flutter with Clean Architecture and Provider-based state management. The platform integrates Firebase real-time services, Razorpay payments, and a role-based management system to streamline ordering, inventory, and campus dining operations.
| Decision | Reason | Trade-off |
|---|---|---|
| Flutter cross-platform | Single codebase for Android, iOS & Web | Extra web responsiveness work |
| Firebase ecosystem | Real-time sync with minimal backend overhead | Vendor dependency |
| Atomic Firestore transactions | Prevent race conditions during concurrent ordering | Transaction handling complexity |
| Razorpay integration | Broad Indian payment support incl. UPI & wallets | Complex payment state handling |
| Optimistic UI updates | Instant feedback during ordering | Requires rollback handling on failure |
Hard problems
Real-time order sync during campus rush hours
Lunch breaks caused sudden spikes in concurrent orders, multiple users ordering the same item simultaneously created synchronization issues and inventory inconsistencies.
Solved with atomic Firestore transactions: every order validates and updates stock inside a transaction block so simultaneous requests can never oversell. Added a business-level stock-buffering strategy, only active sellable inventory is exposed while 10-15 hidden backup units are held internally, preventing sudden stock exhaustion during rush periods. Optimistic UI updates plus Firestore snapshot listeners and local caching keep the experience smooth under heavy load.
Race conditions in concurrent ordering
Two users could grab the last unit of an item at nearly the same time, risking duplicate deductions or negative inventory. Every deduction now runs in a transaction that reads the latest stock, verifies availability at transaction time, deducts only on success, and automatically retries on concurrent modification, strong consistency even at peak concurrency.
Multi-method payments across platforms
Built a complete Razorpay payment service with secure transaction handling, multi-platform checkout, comprehensive payment state management, retry flows, transaction logging, and fallback handling for interrupted payments, with separate paths for mobile SDK and web checkout behind one consistent UX.
Architecture
- Frontend - Flutter 3.8+ · Material 3 · Clean Architecture with modular features · Provider state
- Backend - Firestore real-time DB · Firebase Auth (Google Sign-In) · Firebase Storage · Cloud Functions
- Payments - Razorpay with multi-method support
- Services - OrderService, InventoryService, PaymentService, AuthService, MenuService
Outcome
- Live on the Play Store, serving a real campus daily
- Atomic transactions + stock reservation eliminated overselling entirely
- Lazy loading, optimistic UI, image caching & indexed queries keep it fast at high concurrency
What I learned
Real-time systems demand careful concurrency handling; atomic transactions are non-negotiable for inventory under load; optimistic UI dramatically improves perceived performance; and business-level strategies, like backup inventory buffering, matter as much as technical solutions.
