The Architecture Behind ShopFlow SaaS
2025-02-1810 min read
SaaSPostgreSQLReact
## What is ShopFlow
ShopFlow is a multi-tenant SaaS for managing shops — inventory, sales, customers, and analytics. Think of it as a modern POS system that lives in the browser.
## The Stack
- **Frontend**: React with Vite
- **Backend**: Node.js with Express
- **Database**: PostgreSQL with Prisma ORM
- **Auth**: Custom JWT-based authentication
- **Hosting**: Vercel (frontend) + Railway (backend)
### Multi-Tenancy
The biggest challenge was multi-tenancy. Each shop is a separate tenant with its own data. I used a shared database approach with tenant IDs on every table.
```sql
CREATE TABLE products (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
tenant_id UUID NOT NULL REFERENCES tenants(id),
name TEXT NOT NULL,
price DECIMAL(10,2) NOT NULL
);
```
## Results
The system handles 50+ shops with zero downtime. Each shop gets their own dashboard with real-time analytics.