MATIH Platform is in active MVP development. Documentation reflects current implementation status.
7. Tenant Lifecycle
Connectors

Connector Management

Connectors are the bridge between the MATIH platform and external data sources. The tenant service manages the lifecycle of data source connectors, including credential storage, connectivity testing, schema discovery, and usage monitoring. Each tenant configures their own set of connectors, which are then consumed by the query engine, data pipeline service, and catalog service.


Connector Architecture

Tenant Service                       Data Plane Services
+----------------------------+       +----------------------------+
| Connector Management       |       | Query Engine               |
|   - Create/Update/Delete   | ----> |   - Execute queries        |
|   - Test connectivity      |       |   - Connection pooling     |
|   - Store credentials      |       +----------------------------+
|   - Schema discovery       |       | Pipeline Service           |
+----------------------------+       |   - ETL jobs               |
         |                           |   - Incremental loads      |
         v                           +----------------------------+
  Kubernetes Secrets                 | Catalog Service            |
  (encrypted credentials)           |   - Schema indexing        |
                                     |   - Lineage tracking       |
                                     +----------------------------+

Supported Connector Types

CategoryTypeDescription
RelationalPostgreSQLOpen-source relational database
RelationalMySQLPopular open-source RDBMS
RelationalSQL ServerMicrosoft relational database
RelationalOracleEnterprise relational database
Cloud WarehouseSnowflakeCloud-native data warehouse
Cloud WarehouseBigQueryGoogle Cloud analytics warehouse
Cloud WarehouseRedshiftAWS cloud data warehouse
Cloud WarehouseDatabricks SQLUnified analytics platform
NoSQLMongoDBDocument-oriented database
NoSQLDynamoDBAWS key-value and document store
File StorageS3AWS object storage
File StorageAzure BlobAzure object storage
File StorageGCSGoogle Cloud Storage
StreamingKafkaDistributed event streaming
APIRESTGeneric REST API connector
APIGraphQLGraphQL endpoint connector

Connector Entity

FieldTypeDescription
idUUIDConnector identifier
tenantIdUUIDOwning tenant
nameStringDisplay name
typeConnectorTypeDatabase type (e.g., POSTGRESQL, SNOWFLAKE)
hostStringConnection host or endpoint
portIntegerConnection port
databaseStringDatabase name
schemaStringDefault schema
credentialSecretNameStringKubernetes secret name for credentials
sslEnabledBooleanWhether SSL/TLS is required
sslModeStringSSL mode (verify-full, verify-ca, require)
statusConnectorStatusACTIVE, INACTIVE, ERROR, TESTING
lastTestedAtInstantLast connectivity test timestamp
lastTestResultStringLast test result message
metadataMapAdditional connector-specific properties
createdAtInstantCreation timestamp
updatedAtInstantLast update timestamp

Connector Lifecycle

Create Connector

POST /api/v1/tenants/{tenantId}/connectors
Authorization: Bearer {admin_token}
Content-Type: application/json
{
  "name": "Production Warehouse",
  "type": "SNOWFLAKE",
  "host": "acme.snowflakecomputing.com",
  "port": 443,
  "database": "ANALYTICS",
  "schema": "PUBLIC",
  "credentials": {
    "username": "matih_reader",
    "password": "encrypted_value",
    "warehouse": "COMPUTE_WH",
    "role": "MATIH_READER"
  },
  "sslEnabled": true,
  "metadata": {
    "account": "acme",
    "region": "us-east-1"
  }
}

Processing steps:

  1. Validate connector configuration
  2. Create Kubernetes secret for credentials in the tenant namespace
  3. Test connectivity to the data source
  4. If connectivity succeeds, save connector with ACTIVE status
  5. Trigger schema discovery for catalog indexing

Response (201):

{
  "id": "770e8400-e29b-41d4-a716-446655440000",
  "name": "Production Warehouse",
  "type": "SNOWFLAKE",
  "host": "acme.snowflakecomputing.com",
  "status": "ACTIVE",
  "lastTestedAt": "2026-02-12T10:00:00Z",
  "lastTestResult": "Connection successful",
  "schemasDiscovered": 5,
  "tablesDiscovered": 142
}

Credential Storage

Credentials are never stored in the tenant service database. They are persisted as Kubernetes secrets:

apiVersion: v1
kind: Secret
metadata:
  name: connector-770e8400
  namespace: matih-acme
  labels:
    matih.ai/connector-id: "770e8400-..."
    matih.ai/connector-type: "snowflake"
type: Opaque
data:
  username: <base64>
  password: <base64>
  warehouse: <base64>
  role: <base64>

The SecretEncryptionService ensures that credentials are encrypted at rest using the Kubernetes encryption provider.


Connectivity Testing

Test Endpoint

POST /api/v1/tenants/{tenantId}/connectors/{connectorId}/test
Authorization: Bearer {admin_token}

Response:

{
  "connectorId": "770e8400-...",
  "success": true,
  "latencyMs": 145,
  "serverVersion": "Snowflake 7.34.1",
  "message": "Connection successful",
  "testedAt": "2026-02-12T10:05:00Z"
}

Failed test response:

{
  "connectorId": "770e8400-...",
  "success": false,
  "latencyMs": null,
  "serverVersion": null,
  "message": "Connection refused: verify host and port",
  "errorCode": "CONNECTION_REFUSED",
  "testedAt": "2026-02-12T10:05:00Z"
}

Common Error Codes

Error CodeDescription
CONNECTION_REFUSEDHost unreachable or port closed
AUTHENTICATION_FAILEDInvalid credentials
SSL_HANDSHAKE_FAILEDTLS certificate validation error
DATABASE_NOT_FOUNDSpecified database does not exist
PERMISSION_DENIEDCredentials lack required permissions
TIMEOUTConnection timed out
DNS_RESOLUTION_FAILEDHostname could not be resolved

Schema Discovery

When a connector is created or updated, the service triggers schema discovery to index the available databases, schemas, tables, and columns.

Discovery Flow

Tenant Service               Catalog Service
     |                              |
     |  POST /connectors/{id}/discover
     |  (async)                     |
     |----------------------------->|
     |                              |  Connect to data source
     |                              |  Query information_schema
     |                              |  Index tables and columns
     |                              |  Detect data types
     |                              |  Estimate row counts
     |  Discovery complete          |
     |<-----------------------------|

Discovery Results

GET /api/v1/tenants/{tenantId}/connectors/{connectorId}/schemas
{
  "connectorId": "770e8400-...",
  "schemas": [
    {
      "name": "PUBLIC",
      "tables": [
        {
          "name": "ORDERS",
          "type": "TABLE",
          "columns": 12,
          "estimatedRows": 1500000,
          "sizeBytes": 524288000
        },
        {
          "name": "CUSTOMERS",
          "type": "TABLE",
          "columns": 8,
          "estimatedRows": 50000,
          "sizeBytes": 10485760
        }
      ]
    }
  ],
  "discoveredAt": "2026-02-12T10:01:00Z"
}

Connector Management API

MethodEndpointDescription
GET/api/v1/tenants/{id}/connectorsList all connectors
GET/api/v1/tenants/{id}/connectors/{connectorId}Get connector details
POST/api/v1/tenants/{id}/connectorsCreate connector
PUT/api/v1/tenants/{id}/connectors/{connectorId}Update connector
DELETE/api/v1/tenants/{id}/connectors/{connectorId}Delete connector
POST/api/v1/tenants/{id}/connectors/{connectorId}/testTest connectivity
POST/api/v1/tenants/{id}/connectors/{connectorId}/discoverTrigger schema discovery
GET/api/v1/tenants/{id}/connectors/{connectorId}/schemasGet discovered schemas
PUT/api/v1/tenants/{id}/connectors/{connectorId}/credentialsUpdate credentials

Connector Limits by Tier

TierMax ConnectorsConnector Types
Free2PostgreSQL, MySQL only
Professional10All standard types
EnterpriseUnlimitedAll types including custom

When a tenant exceeds their connector limit, the creation endpoint returns 403 Forbidden with a message indicating the plan limit.


Monitoring and Health Checks

Connectors are periodically tested for health. A scheduled task runs every 15 minutes to verify connectivity:

StatusCondition
ACTIVELast test succeeded
WARNINGLast test succeeded but latency exceeded threshold
ERRORLast test failed
INACTIVEConnector disabled by user

When a connector enters ERROR status, the tenant admin receives a notification with diagnostic details.


Next Steps