Bablu Kumar Singh
Back to Projects

ROI Spectrum

Node.jsExpress.jsPostgreSQLMongoDBReact.jsStripeRedis
ROI Spectrum

The Problem

SEO agencies and website owners lacked an integrated, multi-tenant solution to track ROI, audit logs, service tracking, and automated subscription billing transparently.

Architecture & Topology

Multi-tenant database schema architecture using Node.js/Express backend, React.js frontend, and hybrid storage using PostgreSQL for relational billing data and MongoDB for audit logs.

Request Workflow Map:
Tenant -> API Gateway -> Dynamic Tenant Selector -> Tenant DB (PostgreSQL / MongoDB) Stripe -> Webhook Handler -> Redis Queue -> Billing Aggregator

Engineering Challenges

Ensuring absolute tenant isolation and transaction safety during payment processing, along with handling real-time webhook retries and subscription life cycles.

Applied Solutions

Implemented schema-level tenant filtering alongside a resilient Redis event bus to parse incoming Stripe webhooks asynchronously. Built custom middleware to dynamically set DB contexts based on tenant headers.

Results & Benchmarks

Successfully deployed and launched the platform at roispectrum.com, handling hundreds of active tenants, reducing query response times by 30% through composite indexing, and fully automating subscription operations.

API Routing Specifications

MethodPathObjective
POST/api/v1/tenantsCreate new tenant workspace
POST/api/v1/billing/checkoutGenerate Stripe session
GET/api/v1/reports/roiRetrieve aggregated metrics

Performance Tuning

Optimized query execution paths through multi-column indexing on tenant_id + created_at. Added Redis caching for read-heavy tenant settings, improving API response times from 150ms to 40ms.

Lessons Learned

Decoupling the billing pipeline from the core API workflow using an event queue prevents database lockups during traffic spikes.

SaaS Multi-Tenant Database ERD

Analyze schemas, keys, and foreign relational bindings

Tenants
Collection
id
UUID
name
VARCHAR(100)
subdomain
VARCHAR(50)
stripe_customer_id
VARCHAR(100)
created_at
TIMESTAMP
Users
Collection
id
UUID
tenant_id
UUID
email
VARCHAR(255)
password_hash
VARCHAR(255)
role_mask
INTEGER
created_at
TIMESTAMP
Subscriptions
Collection
id
UUID
tenant_id
UUID
stripe_sub_id
VARCHAR(100)
status
VARCHAR(50)
plan_tier
VARCHAR(50)
expires_at
TIMESTAMP

Tenants Schema

Stores company workspaces & domains
Relational Bounds
Parent workspace node (Has many Users and Subscriptions)
Primary Indexes
  • id:Primary unique identifier
  • subdomain:Subdomain routing identifier
Hover over tenant_id fields to highlight relationships.