MATIH Platform is in active MVP development. Documentation reflects current implementation status.
2. Architecture
Overview

Multi-Tenancy Architecture Overview

Multi-tenancy in the MATIH Platform is a foundational architectural decision that permeates every layer of the system. This section provides a comprehensive examination of the five isolation strategies, how tenant context propagates through the system, and what guarantees the platform provides.


Isolation Model

The platform uses a hybrid isolation model with five layers:

LayerStrategySection
ApplicationThread-local tenant contextTenant Context Propagation
DatabaseSchema-per-tenantDatabase Isolation
KubernetesNamespace-per-tenantNamespace Isolation
NetworkNetworkPolicy-per-namespaceNetwork Isolation
DataTenant-scoped keys, events, cachesData-Level Isolation

Tenant Context Flow

1. JWT token carries tenant_id claim
2. Kong Gateway extracts tenant_id
3. Backend service sets TenantContextHolder
4. Service layer reads tenant context
5. Repository scopes all queries by tenant
6. Events carry tenant_id as payload and partition key
7. Cache keys include tenant prefix
8. Audit logs tag every entry with tenant

Isolation Guarantees

GuaranteeMechanismVerification
Data isolationSchema-per-tenant in PostgreSQLQueries scoped by Hibernate resolver
Network isolationKubernetes NetworkPoliciesPods cannot reach other tenant namespaces
Resource isolationKubernetes ResourceQuotasCPU/memory limits per namespace
Cache isolationTenant-prefixed Redis keysKey collision impossible
Event isolationTenant ID as Kafka partition keyEvents partitioned by tenant
Auth isolationTenant ID in server-signed JWTClient cannot forge tenant identity

Tenant Tiers

TierCPU QuotaMemory QuotaMax UsersFeatures
Free2 cores4Gi5Basic analytics
Professional8 cores16Gi50Full analytics, AI chat
EnterpriseCustomCustomUnlimitedAll features, custom models

Related Sections