Core Models (models/core.py)
| Model | Purpose |
User | Application users (local and SSO-enabled), role assignments |
Role | RBAC roles with JSON permission lists |
Group | User groups for bulk role assignments |
Permission | Granular permission definitions |
APIToken | Long-lived API tokens for external applications |
AuditLog | Security audit trail |
RevokedToken | JWT token revocation blacklist |
BackgroundTask | Background job tracking and status |
Setting | Application settings key-value store |
RAG Models (models/rag_metadata.py — 20+ models)
| Model | Purpose |
RAGDatabaseProfile | Database storage profiles |
RAGStorageSpace | Storage space definitions |
RAGApplicationBinding | Application-to-collection bindings |
Collection | RAG collection definitions with embedding settings |
Document | Document metadata and processing state |
SyncJob, SyncJobRun | Sync job definitions and execution history |
RAGChunkTemplate | Chunking strategy templates |
RAGGraphExtractionProfile | Graph extraction configuration |
RAGGraphEntity, RAGGraphRelationship | Knowledge graph entities and relationships |
EmbeddingModelRegistry | Embedding model registration |
RAG Cluster Models (models/rag_cluster.py)
| Model | Purpose |
RAGClusterInstance | Cluster node definitions |
ClusterHealthMetric | Per-node CPU, memory, query performance |
DistributedSyncLog | Cross-cluster sync event log |
DocumentConflict | Conflict resolution metadata |
ClusterNetworkPartition | Partition detection and healing strategy |
Other Model Files
| File | Key Models |
environment.py | UnifiedEnvironment, ServiceEnvironment, ModelRegistry |
scheduled_jobs.py | ScheduledJob, JobExecution, JobDeadLetter, JobTemplate |
ml_models.py | MLModel, MLModelVersion, MLModelValidation |
agent_plan.py | AgentPlanSession, AgentPlanEvent |
application.py | Application, ApplicationRole, ApplicationToken |
identity.py | BiometricProfile |
wizard_state.py | WizardState |
coding_agent.py | CodingAgentProjectModel, CodingAgentSessionModel |
personal_assistant.py | PersonalAssistantProfileModel, PersonalAssistantSessionModel |
token_audit.py | TokenAuditLog |
rate_limiting.py | LoginAttempt, UserSession, MFASecret |
middleware.py | RoutingRule, AccessPolicy |
password_reset.py | PasswordResetToken |
workflow.py | WorkflowDefinition, 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.