Data Models Overview

DocuPulse uses SQLAlchemy ORM with PostgreSQL to manage a comprehensive set of data models that support multi-tenant document management, user collaboration, and system administration. The database schema is designed for scalability, security, and efficient querying with proper relationships and constraints.

Core Models
User Management
  • User: Core user accounts with roles
  • PasswordResetToken: Secure password recovery
  • PasswordSetupToken: Initial account setup
  • ManagementAPIKey: API authentication
Workspace & Collaboration
  • Room: Document workspaces
  • RoomMemberPermission: Granular access control
  • Conversation: Real-time messaging
  • Message: Individual chat messages
  • MessageAttachment: File attachments
File Management
  • RoomFile: Files and folders in rooms
  • UserStarredFile: User favorites system
  • TrashedFile: Deleted file management
System & Administration
  • SiteSettings: Company configuration
  • DocuPulseSettings: System limits
  • KeyValueSettings: Dynamic configuration
  • Event: Audit logging system
  • Notif: Notification system
  • EmailTemplate: Email templates
  • Mail: Email tracking
  • Instance: Multi-tenant management
Model Details
User Model

Core user account with authentication, roles, and profile information.

Primary Fields
  • id - Primary key
  • username - Unique username
  • email - Unique email address
  • password_hash - Encrypted password
  • is_admin - Administrator role
  • is_manager - Manager role
Profile Fields
  • last_name - User's last name
  • phone - Contact phone
  • company - Company name
  • position - Job position
  • profile_picture - Avatar image
  • preferred_view - UI preference
Room Model

Document workspace with member management and file organization.

Core Fields
  • id - Primary key
  • name - Room name
  • description - Room description
  • created_at - Creation timestamp
  • created_by - Creator user ID
Relationships
  • creator - Room creator (User)
  • members - Room members (User)
  • member_permissions - Member permissions
  • files - Room files (RoomFile)
RoomFile Model

Files and folders stored within rooms with metadata and access tracking.

File Information
  • id - Primary key
  • name - File/folder name
  • path - File path
  • type - 'file' or 'folder'
  • size - File size in bytes
  • modified - Last modified timestamp
Access Control
  • room_id - Parent room
  • uploaded_by - Uploader user ID
  • uploaded_at - Upload timestamp
  • deleted - Deletion status
  • deleted_by - Deleter user ID
  • deleted_at - Deletion timestamp
Conversation Model

Real-time messaging conversations with member management.

Conversation Details
  • id - Primary key
  • name - Conversation name
  • description - Conversation description
  • created_at - Creation timestamp
  • created_by - Creator user ID
Relationships
  • creator - Conversation creator
  • members - Conversation members
  • messages - Conversation messages
Settings Models
SiteSettings
  • primary_color - Brand primary color
  • secondary_color - Brand secondary color
  • company_name - Company name
  • company_logo - Logo filename
  • company_website - Company website
  • company_email - Contact email
DocuPulseSettings
  • max_rooms - Maximum rooms per instance
  • max_conversations - Max conversations
  • max_storage - Storage limit in bytes
  • updated_at - Last update timestamp
Database Relationships
User Relationships

Users can create rooms, upload files, send messages, and participate in conversations with proper permission controls

File Hierarchy

Files are organized in rooms with folder structures, starring capabilities, and trash management for deleted items

Permission System

Granular permissions control access to rooms, files, and conversations with role-based and user-specific settings

Audit Trail

Comprehensive event logging tracks all user actions, file operations, and system changes for security and compliance

Quick Reference
Model Categories
User Management 4 Models
File Management 3 Models
Communication 3 Models
System Settings 8 Models
Key Features
Multi-tenant
Role-based access
Audit logging
File versioning
Database Schema
Database Type
PostgreSQL
Primary database
ORM Framework
SQLAlchemy
Object-relational mapping
Migration Tool
Alembic
Schema versioning
Model Best Practices
  • Use proper foreign key constraints
  • Implement cascade delete where appropriate
  • Add indexes for frequently queried fields
  • Use JSON fields for flexible data storage
  • Include audit timestamps on all models
  • Implement soft deletes for data recovery