Strict Database-per-Tenant Multi-Tenancy Architecture
Engineering documentation on tenant isolation, dynamic connection resolution, and compliance with national cybersecurity and data governance mandates.
ShamelOS ERP enforces a strict Database-per-Tenant isolation model. Each tenant receives a completely private PostgreSQL database. The central system database handles solely directory routing and credential verification. All business transactions run against isolated tenant databases, guaranteeing zero possibility of relational query leakage and enabling per-tenant independent backup and encryption keys.
Physical & Logical Isolation
Business tables lack tenant_id columns because the entire database is private. Developers cannot accidentally leak data via missing WHERE clauses.
Dynamic Client Pooling
Prisma clients are instantiated and cached on-demand in an LRU connection pool using tenant database credentials resolved per request.
Regulatory NCA & NDMO
Compliant with stringent banking and Saudi government data sovereignty mandates requiring cryptographic isolation.
Request Flow Pipeline
1. Inbound Request: https://acme.shamelos.com/api/v1/sales/invoices
↓ Extract Host header or JWT bearer token payload (tenantId: "t_acme_891")
2. Central Tenant Directory: Resolve PostgreSQL connection URI (vault / encrypted)
↓ Lookup LRU Client Cache (hits existing pool or provisions new client in <5ms)
3. Bind Request Context: AsyncLocalStorage sets active Prisma instance
↓ Execute Business Logic directly on isolated tenant database
4. Response returned: Zero possibility of cross-tenant exposure
Frequently Asked Architecture & Security Questions
What is the fundamental difference between Database-per-Tenant and Shared Database multi-tenancy?
In shared multi-tenant databases, records from all enterprises reside in identical tables distinguished only by a tenant_id column, exposing organizations to data leakage if a single SQL bug or query oversight occurs. ShamelOS dynamically resolves a dedicated, physically isolated PostgreSQL database for every organization, making cross-tenant data bleeding mathematically impossible.
How does ShamelOS efficiently manage multiple database connections without memory exhaustion?
ShamelOS utilizes an adaptive LRU connection pooling layer in NestJS that instantiates and shares tenant-scoped Prisma client instances on-demand based on cryptographically verified JWT tokens, actively evicting idle connections to ensure minimal resource overhead.
Secure Your Business Data with Dedicated DB Isolation
Deploy ShamelOS with dedicated database isolation and bank-grade data security.