Database Schema
The cluster management system uses a relational database to store all configuration, state, and user information. This document describes the database schema and relationships between tables.
Entity Relationship Diagram
Core Models
Site
The Site model represents a top-level organizational unit, typically corresponding to a physical or logical Proxmox cluster location.
Key Fields:
name: Display name for the siteinternalDomain: Internal DNS domain (e.g.,cluster.internal)dhcpRange: IP range for container assignment (e.g.,192.168.1.100-192.168.1.200)subnetMask: Network subnet maskgateway: Default gateway IPdnsForwarders: Upstream DNS servers (comma-separated)
Relationships:
- Has many Nodes
- Has many ExternalDomains
Node
The Node model represents a Proxmox VE server within a site.
Key Fields:
name: Node name (must match Proxmox hostname)ipv4Address: Node's IP address for DNSapiUrl: Proxmox API endpointapiTokenIdOrUsername: Authentication credential (username or token ID)apiTokenSecretOrPassword: Authentication secretdisableTlsVerification: Skip TLS certificate validation
Relationships:
- Belongs to Site
- Has many Containers
Constraints:
nameis unique across all nodes
Container
The Container model represents an LXC container running on a Proxmox node.
Key Fields:
hostname: Container hostnamename: Display namecontainerId: Proxmox container ID (CTID)macAddress: Unique MAC addressipv4Address: Assigned IP addressstatus: Container state (e.g., 'running', 'stopped')
Relationships:
- Belongs to Node
- Has many Services
Constraints:
- Unique composite index on
(nodeId, containerId) hostname,macAddress, andipv4Addressare globally unique
Service (Base Model)
The Service model uses Single Table Inheritance (STI) to represent different types of services exposed by containers.
Key Fields:
containerId: Container exposing this servicetype: Service type ('http', 'transport', or 'dns')containerPort: Port number inside the container
Relationships:
- Belongs to Container
- Has one HTTPService, TransportService, or DnsService (based on type)
HTTPService
Represents HTTP/HTTPS services with automatic SSL certificate management.
Key Fields:
externalHostname: Subdomain for the service (e.g., 'app' for 'app.example.com')externalDomainId: External domain to use
Relationships:
- Belongs to Service (one-to-one)
- Belongs to ExternalDomain
Constraints:
- Unique composite index on
(externalHostname, externalDomainId)
TransportService
Represents TCP/UDP services exposed via port mapping.
Key Fields:
protocol: 'tcp' or 'udp'externalPort: Public port numberuseTls: Whether to use TLS for TCP connections
Relationships:
- Belongs to Service (one-to-one)
Constraints:
- Unique composite index on
(protocol, externalPort)
Static Methods:
findNextAvailablePort(): Finds the next available external port
DnsService
Represents services registered in DNS (typically SRV records).
Key Fields:
recordType: DNS record type (currently only 'SRV' supported)serviceName: Service name for DNS record
Relationships:
- Belongs to Service (one-to-one)
ExternalDomain
The ExternalDomain model manages public domains for HTTP service exposure.
Key Fields:
domain: Domain name (e.g., 'example.com')acmeEmail: Email for certificate notificationsacmeDirectory: ACME CA endpoint URLcloudflareApiEmail: Cloudflare account emailcloudflareApiKey: Cloudflare API key for DNS challenges
Relationships:
- Belongs to Site
- Has many HTTPServices
User Management Models
User
The User model stores user accounts with LDAP-compatible attributes.
Key Fields:
uidNumber: Unique user ID (starting at 2000)username: Login usernamecn: Common name (full name)sn: Surname (last name)givenName: First namemail: Email addresssshPublicKey: SSH public key for container accessuserPassword: Hashed password (argon2)status: Account status ('pending', 'active', 'suspended')
Relationships:
- Belongs to many Groups (through UserGroups)
Security:
- Passwords are hashed with argon2 before storage
- Only 'active' users can authenticate
- First registered user is automatically added to 'sysadmins' group
Static Methods:
getNextUid(): Returns next available UID starting at 2000
Instance Methods:
validatePassword(password): Verifies password against hash
Group
The Group model represents user groups with LDAP-compatible attributes.
Key Fields:
gidNumber: Unique group IDcn: Group name (common name)isAdministrator: Whether group members have admin privileges
Relationships:
- Has many Users (through UserGroups)
Default Groups:
ldapusers(gid: 2000): Standard container accesssysadmins(gid: 2001): Full cluster administration
UserGroup
The UserGroup model is a join table for the many-to-many User-Group relationship.
Key Fields:
uidNumber: Foreign key to UsersgidNumber: Foreign key to Groups
Constraints:
- Composite primary key on
(uidNumber, gidNumber)
Job Management Models
Job
The Job model tracks asynchronous operations.
Key Fields:
name: Job descriptionassociatedResource: Reference to related resourcestatus: Job state ('pending', 'running', 'success', 'failure', 'cancelled')
Relationships:
- Has many JobStatuses
JobStatus
The JobStatus model stores job execution history and progress messages.
Key Fields:
jobId: Foreign key to Jobsmessage: Status update message
Relationships:
- Belongs to Job
Session Management
SessionSecret
The SessionSecret model stores express-session secrets.
Key Fields:
secret: 32-64 character secret string
Constraints:
secretis unique
Database Abstraction
The schema is implemented using Sequelize ORM, providing:
- Database Portability: Supports SQLite (default), PostgreSQL, and MySQL
- Migrations: Schema versioning and updates via
sequelize-cli - Validation: Field-level validation rules
- Hooks: Automatic password hashing, UID/GID assignment
- Associations: Declarative relationship definitions
Key Design Patterns
Single Table Inheritance (STI)
The Service model uses STI to handle different service types:
- Base
Servicestable withtypediscriminator - Child tables (
HTTPServices,TransportServices,DnsServices) extend via one-to-one relationships - Allows polymorphic service handling while maintaining type-specific fields
LDAP Schema Compatibility
User and Group models follow LDAP naming conventions:
uidNumber/gidNumberfor numeric IDscn(common name) for namessn(surname),givenNamefor user names- Enables seamless integration with LDAP authentication
Hierarchical Organization
Resources are organized hierarchically:
Site → Nodes → Containers → Services
This mirrors the physical infrastructure topology and simplifies queries.
Next Steps
- System Architecture: Understand how the database integrates with other components
- Development Workflow: Learn how to create migrations
- Core Technologies: Sequelize ORM documentation