Skip to main content

Database Abstraction

Modulo’s database layer is built on SQLAlchemy 2.0 with multi-backend support (PostgreSQL, SQLite, MariaDB, MySQL). See Architecture for the high-level system design and the PRD §6.1 and §6.2 for the full specification.

Key components:

  • Declarative model systemBase(DeclarativeBase), TimestampMixin, OrgScoped
  • Multi-backend repository layer – RLS-backed (Postgres) or explicit tenant filtering (SQLite/MariaDB/MySQL)
  • Row-level security – Postgres RLS policies + generic ORM filter injection
  • Alembic migrations – 59+ incremental migration scripts
  • CRUD service layer – 40+ function-based entity-specific modules
  • Cursor-based pagination – keyset pagination with base64-coded cursors
  • Testcontainers integration – real Postgres 16 in test suites