Loading...
Please wait while we fetch your content.
Please wait while we fetch your content.
StoreFlow is a multi-tenant SaaS platform designed for businesses to manage multiple stores, track inventory, process sales/purchases, and handle complex accounting (like partial payments and returns). The project focuses on strict data isolation, real-time synchronization across devices, and handling complex financial ledgers with automated due adjustments.
// Next.js & React
Modern frontend utilizing Server Actions for secure data mutations, alongside a dynamic, SEO-friendly UI.
// Express.js, Prisma & MySQL
Robust backend architecture with type-safe database operations. Prisma’s composite keys were crucial for building the multi-tenant data isolation.
// Socket.IO & RTK Query
Combined WebSockets with client-side caching to ensure real-time inventory and dashboard sync across all active devices.
Initially, custom IDs (e.g., RET_001, SALE_001) were used as global primary keys. This caused database constraint errors when two different stores tried to generate the same ID.
When a customer returned a product, they often had an unpaid balance (Due) on a previous sale. Simply refunding cash resulted in a financial loss, as the customer still owed money.
Fetching stock levels outside a database transaction led to "Race Conditions" (e.g., two users buying the last item simultaneously), risking negative stock and inaccurate movement logs.
Migrated the schema to use @@id([storeId, id]). This ensured strict data isolation, allowing multiple tenants to have identical custom IDs without conflicts.
Engineered a custom algorithm to calculate min(dueAmount, refundAmount). The system now offsets the refund against the old due first, and only refunds the remaining balance in cash, keeping ledgers 100% accurate.
Wrapped all inventory updates inside prisma.$transaction. Implemented atomic updateMany operations with stock: { gte: quantity } constraints. If stock drops mid-transaction, the entire process rolls back safely.
// frontend
Interactive Dashboard with real-time KPIs (Total Sales, Profit, Stock Value).
Time-filtered Charts (Today, 7 Days, 30 Days) using Chart.js.
Point of Sale (POS) with barcode support and dynamic discounts.
Role-based dynamic UI (Owner, Manager, Salesman).
// backend
Multi-tenant data isolation using Prisma composite keys.
Complex financial ledgers and automated due adjustment algorithms.
Real-time WebSocket server (Socket.IO) for cache invalidation.
Secure JWT authentication with rate limiting and Zod validation.