Skip to main content

Database Schema

RiDDiX - Matrix Synapse Panel uses PostgreSQL with Prisma ORM. All table and column names use snake_case mapping.

Entity Relationship Diagram

┌──────────────┐     ┌──────────────────┐     ┌──────────────────┐
│ AdminUser │ │ ManagedServer │ │ BrandingProfile │
│──────────────│ │──────────────────│ │──────────────────│
│ id │ │ id │◄────│ id │
│ email │ │ name │ │ name │
│ password │ │ slug (unique) │ │ isActive │
│ name │ │ serverName │ │ isDraft │
│ role │ │ internalUrl │ │ version │
└──────────────┘ │ publicUrl │ │ (theme fields) │
│ status │ │ (content fields) │
│ enabled │ │ (link fields) │
│ isDefault │ └────────┬─────────┘
│ adminTokenEnc │ │
│ adminTokenIv │ ┌────────┴─────────┐
│ adminTokenTag │ │ BrandingAsset │
│ brandingProfileId│────►│──────────────────│
│ (diag fields) │ │ id │
│ (config fields) │ │ profileId │
└───────┬──────────┘ │ purpose │
│ │ filename │
┌──────────────┼────────────┐ │ storagePath │
│ │ │ │ mimeType, size │
▼ ▼ ▼ └──────────────────┘
┌────────────┐ ┌────────────┐ ┌──────────────────────┐
│ TokenMeta │ │ AuditLog │ │InstalledIntegration │
│────────────│ │────────────│ │──────────────────────│
│ id │ │ id │ │ id │
│ serverId │ │ serverId? │ │ serverId │
│ token │ │ action │ │ catalogId │
│ label │ │ actor │ │ name, type │
│ note │ │ target │ │ deploymentMode │
│ createdBy │ │ detail │ │ status, enabled │
└────────────┘ │ ip │ │ configJson │
└────────────┘ │ (docker fields) │
│ (health fields) │
│ (appservice fields) │
└───────┬──────────────┘

┌────────────┼────────────┐
▼ ▼
┌──────────────────┐ ┌──────────────────┐
│IntegrationSecret │ │IntegrationConfig │
│──────────────────│ │──────────────────│
│ id │ │ id │
│ integrationId │ │ integrationId │
│ key │ │ version │
│ encryptedValue │ │ configJson │
│ iv, tag │ │ appliedAt │
│ rotatedAt │ │ createdBy │
└──────────────────┘ └──────────────────┘

┌──────────────────┐
│ BotDefinition │◄── ManagedServer.bots
│──────────────────│
│ id │
│ serverId │
│ templateId │
│ displayName │
│ localpart │
│ matrixUserId │
│ status, enabled │
│ configJson │
│ accessTokenEnc │
│ accessTokenIv │
│ accessTokenTag │
└───────┬──────────┘

┌────────┼──────────┐
▼ ▼
┌──────────────────┐ ┌──────────────────┐
│BotRoomAssignment │ │ BotFeatureFlag │
│──────────────────│ │──────────────────│
│ id │ │ id │
│ botId │ │ botId │
│ roomId │ │ featureKey │
│ roomAlias │ │ enabled │
│ configJson │ │ configJson │
│ active │ │ scope │
│ joinedAt │ │ scopeId │
└──────────────────┘ └──────────────────┘

Models

AdminUser

Stores admin dashboard credentials. Passwords are bcrypt-hashed.

ColumnTypeDescription
idcuidPrimary key
emailstringUnique login email
passwordstringbcrypt hash
namestring?Display name
rolestringDefault: global_admin

ManagedServer

Represents a Matrix Synapse homeserver managed by the portal.

ColumnTypeDescription
idcuidPrimary key
namestringDisplay name
slugstringUnique URL-safe identifier
server_namestringMatrix server name (e.g., example.com)
internal_urlstringSynapse URL reachable from portal
public_urlstringPublic Synapse URL
statusstringdraft, active, disabled, error
enabledbooleanWhether the server is active
is_defaultbooleanWhether this is the fallback server
admin_token_enctext?AES-256-GCM encrypted admin token
admin_token_ivstring?Encryption initialization vector
admin_token_tagstring?Encryption authentication tag
capability_modestring?managed or guided
last_diag_atdatetime?Last diagnostics run
last_diag_okboolean?Whether last diagnostics passed
diag_jsontext?Full diagnostics result
public_domainstring?Custom domain for registration
route_prefixstring?URL path prefix
registration_modestring?Registration mode config
managed_modestring?Managed mode config
branding_profile_idstring?FK to BrandingProfile

Indexes: server_name, slug, status

Relations: TokenMeta[], AuditLog[], InstalledIntegration[], BotDefinition[], BrandingProfile?

TokenMeta

Local metadata for Synapse registration tokens.

ColumnTypeDescription
idcuidPrimary key
server_idstringFK to ManagedServer
tokenstringToken value (matches Synapse)
labelstring?Display label
notestring?Internal note
created_bystring?Admin who created it

Unique: (server_id, token)

AuditLog

Audit trail for all actions.

ColumnTypeDescription
idcuidPrimary key
server_idstring?FK to ManagedServer (null for global actions)
actionstringAction type (e.g., token.created)
actorstring?Who performed the action
targetstring?What was affected
detailstring?Additional context (sanitized)
ipstring?Client IP address

Indexes: server_id, action, created_at

BrandingProfile

Branding configuration for the registration page.

Contains ~25 theme/content/link fields. See Branding System for details.

Relations: BrandingAsset[], ManagedServer[]

InstalledIntegration

An installed bridge or service.

ColumnTypeDescription
idcuidPrimary key
server_idstringFK to ManagedServer
catalog_idstringReference to catalog entry
namestringDisplay name
typestringbridge, bot, synapse_module, external_service
deployment_modestringmanaged or guided
statusstringLifecycle status
enabledbooleanWhether active
config_jsontext?Current configuration
container_namestring?Docker container name
appservice_idstring?Appservice registration ID

Relations: IntegrationSecret[], IntegrationConfig[]

BotDefinition

A bot created from a template.

ColumnTypeDescription
idcuidPrimary key
server_idstringFK to ManagedServer
template_idstringReference to bot template
display_namestringBot display name
localpartstring?Matrix localpart
matrix_user_idstring?Full Matrix user ID
access_token_enctext?Encrypted access token
access_token_ivstring?IV
access_token_tagstring?Auth tag

Unique: (server_id, localpart)

Relations: BotRoomAssignment[], BotFeatureFlag[]

Migrations

Migrations are stored in prisma/migrations/ and run automatically on container startup via docker-entrypoint.sh:

MigrationDescription
20240101000000_initInitial schema (AdminUser, TokenMeta, AuditLog)
20240102000000_brandingBrandingProfile, BrandingAsset
20240103000000_integrationsIntegration and bot tables
20240104000000_multi_serverManagedServer, serverId columns