Building Customer Flow — A Multi-Tenant Cloud ERP
How we architected Customer Flow as a multi-tenant ERP for import/export, manufacturing, and enterprise operations with Next.js, FastAPI, PostgreSQL, and Redis.

Ahsan Bilal
Principal Software Engineer
On this page
Import and export teams often split one job across email, Excel, and shared folders. When customs, a bank, or an auditor asks for a complete shipment record, nobody has one file. Customer Flow solves that with a private workspace per company on a shared platform.
The core problem
Documents live in inboxes, costs sit in spreadsheets, and PDFs sit in drives. The same pain hits manufacturers, NGOs, and logistics teams who need approvals and audit history — not scattered files.
Customer Flow runs one import from purchase through shipping papers, customs, duty, and warehouse receipt, with true landed cost on the same file. Export runs go from contract through export forms, packing, shipping, and payment close-out.
Architecture decisions
Each company is a tenant. Data is scoped by organization_id so companies never see each other's records. Platform admins can create tenants, manage users, and support customers safely.
The stack:
- Next.js + TypeScript for screens and server rendering
- Python FastAPI for the API layer with OpenAPI docs
- PostgreSQL for transactional data
- Redis + Celery for background jobs and caching
- Docker + GitHub Actions deploying to DigitalOcean
Country rules for Pakistan, UAE, and other markets plug in as replaceable packs — so compliance logic stays modular instead of hard-coded.
What every action logs
Every important action — document upload, approval, PDF generation, secure link share — is logged in a permanent audit trail. That is not a nice-to-have for trade finance; it is the product.
Lessons learned
Multi-tenant ERP is less about CRUD and more about boundaries: tenant isolation, role permissions per company, optional 2FA, and auditability by default. Start with the compliance story, then build features around it.
If you are building SaaS for regulated industries, design the audit trail first. Everything else attaches to it.
See it in production
The product behind this article
Keep reading
All articles →FastAPI + Celery — Background Jobs for Cloud ERP
Using Redis and Celery with FastAPI to run PDF generation, email notifications, and heavy imports without blocking API responses in Customer Flow.
Translation API at Scale — 100k+ Keys Without Redeploys
Designing a translation hub with Laravel, PostgreSQL, Redis, and a public JSON export API so mobile and web apps fetch language bundles without shipping new builds.
Stripe Checkout in a Microservices Suite — The GSM Pattern
How GSM delivers a focused Next.js payment UI with Stripe Elements, Redis caching, and the Accounts API as the billing source of truth.