Skip to content

Commit 8d78e65

Browse files
committed
arch(stack): finalize SQL Server 2022 as unique database engine and update decision log
1 parent 4fd20c9 commit 8d78e65

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

architecture/blueprints/stack.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,8 @@
160160
* *Schema-per-tenant*: Becomes hard to scale and migrate when tenant counts exceed 1,000, causing connection pool exhaustion.
161161

162162
### 6.2 Tenant Resolution Mechanism
163-
* **Chosen Tool:** **NestJS Interceptor + PostgreSQL Connection Session Context**
164-
* **Why Chosen:** Resolves the `tenant_id` from JWT claims or `X-Tenant-ID` headers at ingress, and uses a database transaction wrapper to inject the tenant context into the active PostgreSQL session dynamically.
163+
* **Chosen Tool:** **NestJS Interceptor + SQL Server SESSION_CONTEXT**
164+
* **Why Chosen:** Resolves the `tenant_id` from JWT claims or `X-Tenant-ID` headers at ingress, and uses a database interceptor/wrapper to inject the tenant context into the active SQL Server session using `sp_set_session_context`.
165165
* **Alternatives Rejected:**
166166
* *Application-level filtering*: Prone to developer omissions (forgetting a `WHERE tenant_id = x` clause), leading to critical data leak vulnerabilities. RLS prevents this at the database level across all runtimes.
167167

@@ -277,6 +277,12 @@ To avoid cloud-provider lock-in and support offline, on-premise environments, **
277277
* **Rationale:** Eliminates infrastructure fragmentation and ensures unified security enforcement (RLS).
278278
* **Revisit When:** Licensing costs exceed budget or a specific context requires native NoSQL features.
279279

280+
### Decision 3: Single Database Engine Strategy — SQL Server 2022 for all services
281+
* **Decision:** All services, including NestJS satellites (Config, Template, Profile managers), must persist exclusively in SQL Server 2022.
282+
* **Rationale:** Polyglot persistence (PG/Mongo) was rejected to minimize operational overhead in on-premise deployments and unify the Row-Level Security (RLS) implementation.
283+
* **Impact:** All services share a single backup, security, and maintenance strategy. Node.js services must use the `mssql` driver.
284+
* **Revisit When:** Re-evaluate if unstructured data volume requires a specialized NoSQL engine for non-relational workloads.
285+
280286
---
281287

282288
## 14. Open Questions

0 commit comments

Comments
 (0)