Core Models (models/core.py)

ModelPurpose
UserApplication users (local and SSO-enabled), role assignments
RoleRBAC roles with JSON permission lists
GroupUser groups for bulk role assignments
PermissionGranular permission definitions
APITokenLong-lived API tokens for external applications
AuditLogSecurity audit trail
RevokedTokenJWT token revocation blacklist
BackgroundTaskBackground job tracking and status
SettingApplication settings key-value store

RAG Models (models/rag_metadata.py — 20+ models)

ModelPurpose
RAGDatabaseProfileDatabase storage profiles
RAGStorageSpaceStorage space definitions
RAGApplicationBindingApplication-to-collection bindings
CollectionRAG collection definitions with embedding settings
DocumentDocument metadata and processing state
SyncJob, SyncJobRunSync job definitions and execution history
RAGChunkTemplateChunking strategy templates
RAGGraphExtractionProfileGraph extraction configuration
RAGGraphEntity, RAGGraphRelationshipKnowledge graph entities and relationships
EmbeddingModelRegistryEmbedding model registration

RAG Cluster Models (models/rag_cluster.py)

ModelPurpose
RAGClusterInstanceCluster node definitions
ClusterHealthMetricPer-node CPU, memory, query performance
DistributedSyncLogCross-cluster sync event log
DocumentConflictConflict resolution metadata
ClusterNetworkPartitionPartition detection and healing strategy

Other Model Files

FileKey Models
environment.pyUnifiedEnvironment, ServiceEnvironment, ModelRegistry
scheduled_jobs.pyScheduledJob, JobExecution, JobDeadLetter, JobTemplate
ml_models.pyMLModel, MLModelVersion, MLModelValidation
agent_plan.pyAgentPlanSession, AgentPlanEvent
application.pyApplication, ApplicationRole, ApplicationToken
identity.pyBiometricProfile
wizard_state.pyWizardState
coding_agent.pyCodingAgentProjectModel, CodingAgentSessionModel
personal_assistant.pyPersonalAssistantProfileModel, PersonalAssistantSessionModel
token_audit.pyTokenAuditLog
rate_limiting.pyLoginAttempt, UserSession, MFASecret
middleware.pyRoutingRule, AccessPolicy
password_reset.pyPasswordResetToken
workflow.pyWorkflowDefinition, WorkflowExecution, WorkflowStepExecution

Auto-Migration

The system uses app/utils/db_auto_migrate.py to automatically detect and add missing tables and columns on startup. This eliminates the need for manual migration files for most schema changes. Alembic is available for complex migrations.