Data Models Overview
This section describes all data models used across the API, including database entities, request DTOs, and response DTOs.
Entity Relationship
┌─────────────┐ ┌──────────────────┐ ┌──────────────┐
│ Workspace │──────▶│ WorkspaceMember │◀──────│ User │
│ │ │ │ │ │
│ - id │ │ - workspaceId │ │ - id │
│ - name │ │ - userId │ │ - email │
│ - ownerId │ │ - role │ │ - name │
└──────┬───────┘ └──────────────────┘ └──────┬───────┘
│ │
│ │
▼ ▼
┌──────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ Document │──────▶│ CommentThread │──────▶│ Comment │
│ │ │ │ │ │
│ - id │ │ - documentId │ │ - threadId │
│ - title │ │ - anchor │ │ - userId │
│ - content │ │ - status │ │ - content │
│ - parentId │ └──────────────────┘ └──────────────────┘
│ - workspaceId│
└──────┬───────┘
│
▼
┌──────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ Attachment │ │ Notification │ │WorkspaceInvitation│
│ │ │ │ │ │
│ - documentId│ │ - recipientId │ │ - workspaceId │
│ - fileName │ │ - type │ │ - email │
│ - storageKey│ │ - status │ │ - token │
└──────────────┘ └──────────────────┘ └──────────────────┘
Core Entities
| Entity | Description | Key Fields |
|---|---|---|
| User | Application user | id, email, name, firebaseUid, status |
| Workspace | Organizational container | id, name, ownerId, slug |
| Document | Wiki document with hierarchical structure | id, title, content (JSONB), parentId, yjsState |
| WorkspaceMember | User membership in workspace | workspaceId, userId, role |
| WorkspaceInvitation | Pending invitation | email, role, token, expiresAt |
| CommentThread | Comment thread on a document | documentId, anchor (JSONB), status |
| Comment | Individual comment | threadId, userId, content |
| Notification | User notification | recipientId, type, status, metadata (JSONB) |
| Attachment | File attachment | documentId, storageKey, fileName |
| UserPreference | User settings | userId, theme, locale |
ID Strategy
All entities use UUID as primary key. Foreign keys are stored as UUID references (no JPA relationship annotations).
Timestamps
All entities extend BaseEntity which provides:
createdAt- Auto-set on creationupdatedAt- Auto-updated on modification