MATIH Platform is in active MVP development. Documentation reflects current implementation status.
2. Architecture
Data Stores
PostgreSQL

PostgreSQL

PostgreSQL 16 is the primary relational database for every service in the MATIH Platform. It stores transactional data, metadata, configuration, and audit records. Multi-tenancy is implemented through Hibernate's schema-based multi-tenancy, where each tenant has its own PostgreSQL schema within a shared database.


Role in the Platform

AspectDetails
Version16
DeploymentKubernetes StatefulSet via Helm
Services using itAll 24 services
Multi-tenancySchema-per-tenant (Hibernate SCHEMA strategy)
Connection poolingHikariCP with per-service configuration

Schema-Per-Tenant Model

Each service maintains a single database with multiple schemas:

PostgreSQL Instance
  +-- Database: matih_ai
  |     +-- Schema: system       (platform metadata)
  |     +-- Schema: acme_corp    (Tenant: ACME Corp)
  |     +-- Schema: globex       (Tenant: Globex Inc)
  |     +-- Schema: initech      (Tenant: Initech LLC)
  |
  +-- Database: matih_bi
  |     +-- Schema: system
  |     +-- Schema: acme_corp
  |     +-- Schema: globex
  |
  +-- Database: matih_control_plane
        +-- Schema: public       (shared Control Plane data)

Hibernate Multi-Tenancy

The TenantIdentifierResolver directs Hibernate to the correct schema:

@Component
public class TenantIdentifierResolver
    implements CurrentTenantIdentifierResolver<String> {
 
    @Override
    public String resolveCurrentTenantIdentifier() {
        return TenantContext.getCurrentTenantIdOrDefault("system");
    }
}

Before each query, Hibernate sets the PostgreSQL search path:

SET search_path TO 'acme_corp';
SELECT * FROM dashboards WHERE created_by = 'user-123';

Connection Pool Configuration

ParameterDevelopmentProduction
Maximum pool size1030
Minimum idle25
Connection timeout30s10s
Idle timeout10 minutes5 minutes
Max lifetime30 minutes30 minutes

Connection pool metrics are exposed via Micrometer:

MetricDescription
hikaricp_connections_activeActive connections in the pool
hikaricp_connections_idleIdle connections in the pool
hikaricp_connections_pendingThreads waiting for a connection

Backup and Recovery

StrategyMethod
Per-tenant backuppg_dump with --schema filter
Full database backuppg_dump of entire database
Point-in-time recoveryWAL archiving to MinIO / S3
Tenant migrationExport schema, import to target database

Related Pages