Skip to content

Database Architecture

Status: Implemented

Overview

The Nivron database architecture provides the persistent foundation for the SaaS platform.

It is designed around business domains, multi-tenant evolution and controlled schema versioning. Database changes are introduced exclusively through Alembic migrations, ensuring reproducible deployments and a complete history of structural evolution.

The database layer is shared by platform services while preserving clear ownership boundaries between domains.


Design Principles

Principle Description
Domain-Oriented Schemas Schemas represent business domains instead of application modules.
Version-Controlled Evolution All structural changes are introduced through Alembic migrations.
UUID v7 Public identifiers use UUID v7 for ordering and uniqueness.
Forward Compatibility Migrations are designed to support incremental platform growth.
Explicit Ownership Each business domain owns its own data model.

Current Schemas

Schema Purpose Status
core Platform metadata and shared business entities. Implemented
identity Organizations, users and identity foundations. Implemented

Future domains will introduce additional schemas without modifying existing ownership boundaries.


Migration History

Version Description Status
0001 Platform schemas Implemented
0002 Platform metadata Implemented
0003 Organizations Implemented
0004 Users Implemented

Published migrations are immutable and form the authoritative history of the platform database.


Current Entity Relationships

erDiagram
    ORGANIZATIONS ||--o{ USERS : owns

    ORGANIZATIONS {
        uuid uuid
        string slug
        string name
        string status
    }

    USERS {
        uuid uuid
        string username
        string status
    }

The current implementation establishes the identity foundation. Additional entities will be introduced by future modules while preserving existing relationships.


Database Lifecycle

Database changes follow a controlled lifecycle:

  1. Model definition.
  2. Alembic migration generation.
  3. Migration review.
  4. Version control.
  5. Deployment.
  6. Runtime validation.

This process guarantees consistent schema evolution across all environments.


Architectural Principles

The database is organized around business domains rather than application features.

This approach:

  • isolates responsibilities;
  • reduces coupling;
  • simplifies future expansion;
  • enables independent module evolution;
  • preserves long-term maintainability.

Applications access the database through shared platform services instead of embedding persistence conventions independently.