Database Concepts
home / developer / concepts / database
Overview¶
Tux uses a robust, async-first PostgreSQL database layer built with SQLModel and SQLAlchemy. The database architecture follows a clean three-layer pattern that separates concerns and enables maintainable, type-safe database operations.
The three layers work together to provide:
- Service Layer: Connection management, session handling, and health monitoring
- Controller Layer: Business logic, query optimization, and specialized operations
- Model Layer: Type-safe data models with automatic serialization and relationships
This architecture supports complex Discord bot operations including moderation, user leveling, custom commands, and configuration management, all while maintaining excellent performance and developer experience.
Navigation¶
Core Concepts¶
- Database Architecture - Three-layer architecture and design principles
- Database Service - Connection management and session handling
- Database Models - SQLModel definitions, relationships, and mixins
- Database Controllers - Controller patterns and specialized operations
- Database Migrations - Schema evolution with Alembic
- Database Testing - Testing strategies and fixtures
- Database Utilities - Context access and helper functions
Related Guides¶
- Database Integration Tutorial - Getting started with database operations
- Database Operations Guide - Common patterns and best practices
- Database CLI Reference - Command-line database management