Data models
These pages list every SQLAlchemy model in backend/app/models/. Concrete models inherit from BaseModel, which provides id, created_at and updated_at. The schema is managed by Alembic (backend/migrations/), and migrations/env.py imports app.models to collect the metadata.
Each model is marked with how it is exposed today:
- API: has REST endpoints under
/api/v1(and the matching MCP tools) and is used by the UI. - Schema only, not exposed yet: the table exists, but no router, service or UI reads or writes it.
| Model | Table | Exposure |
|---|---|---|
| Vault | vaults | API: /vaults |
| Target | targets | API: /vaults/{id}/targets |
| Scan | scans | API: /vaults/{id}/scans, /engines |
| Finding | findings | API: /findings |
| Signature | signatures | API: /signatures |
| ProxyFlow | proxy_flows | API: /vaults/{id}/flows, /vaults/{id}/replay |
| WsSession, WsFrame | ws_sessions, ws_frames | API: /vaults/{id}/flows/{flow_id}/frames (WebSocket sessions) |
| AppSetting | app_settings | Indirect: through /proxy/settings, /proxy/intercept and /proxy/intercept/rules |
| ResearchAsset, AssetObservation, AssetRelation, AssetEvent, AssetSyncState | research_assets, asset_observations, asset_relations, asset_events, asset_sync_states | API: /vaults/{id}/assets (Asset Intelligence) |
| Module | modules | Schema only, not exposed yet |
| Workflow | workflows | Schema only, not exposed yet |
| Note, NoteFolder, NoteRevision, NoteLink | research_notes, note_folders, note_revisions, note_links, note_tags | API: /vaults/{id}/notes (Research notes) |
| VaultFile, FileRevision, FileAttachment | vault_files, file_revisions, file_tags, file_attachments | API: /vaults/{id}/files (Vault files) |
| Comparison | comparisons | API: /vaults/{id}/comparisons (Comparer) |
| AgentToken, Agent, AgentAudit | agent_tokens, agent_token_vaults, agents, agent_audit | API: /connections/... (user only; Agent authentication) |
| Agent Bridge models | agent_conversations, agent_messages, agent_tasks, agent_approvals, agent_events, workspace_contexts | API: /bridge/... (agents with bridge grants and the user; Agent Bridge protocol) |
| SystemConfig | system_configs | Not in the schema: no migration creates the table |
Pages
| Page | Models |
|---|---|
| Vaults, targets, scans and findings | Vault, Target, Scan, Finding, Signature |
| Traffic and settings | ProxyFlow, WsSession, WsFrame, AppSetting |
| Research objects | ResearchAsset, AssetObservation, AssetRelation, AssetEvent, AssetSyncState, Module, Workflow, Note, NoteFolder, NoteRevision, NoteLink, VaultFile, FileRevision |
| Agents and system | AgentToken, Agent, AgentAudit, Agent Bridge models, SystemConfig |
BaseModel
File: base.py · Abstract: yes
| Field | Type | Notes |
|---|---|---|
id | Integer | Primary key, indexed |
created_at | DateTime (tz) | server_default=now() on insert |
updated_at | DateTime (tz) | Set to now() on update; null until the first update |
Relationship map
Vault ──┬── Target ──┬── Scan ──── Finding
│ ├── Finding
│ └── (self: parent / children)
├── ProxyFlow
├── ResearchAsset ──┬── AssetObservation (source by id, no FK)
│ ├── AssetRelation (to asset FK; finding / target by id)
│ └── AssetEvent
├── AssetSyncState
├── Workflow
├── NoteFolder ── (self: parent)
└── Note ──┬── NoteRevision
├── NoteLink (kind + object id, no FK)
└── Tag (note_tags)
Module ──── Scan
Signature ── Finding
Finding ──── (self: duplicate_of_id, FK only)
AppSetting (standalone key/value)
AgentToken ──┬── agent_token_vaults ── Vault
├── Agent
└── AgentAudit (agent, token SET NULL; vault by id)
Vault ──┬── AgentConversation ──┬── AgentMessage (seq per conversation)
│ └── (agent SET NULL)
├── AgentTask ── (conversation, agents SET NULL)
├── AgentApproval ── (task, conversation CASCADE)
└── WorkspaceContextRecord (one per vault)
AgentEvent (vault, conversation, agent by id; ordered log)
SystemConfig (standalone, not migrated)Delete behaviour: deleting a Vault removes its Targets, ProxyFlows, Workflows, Notes and note folders (database CASCADE). Deleting a Vault also removes its assets with their observations, relations, history and sync state, and its Bridge conversations, messages, tasks, approvals and saved context (Bridge events keep plain ids and age out with retention). Deleting a Target removes its Scans and Findings (asset edges to them are dropped at the next sync); notes that reference them keep the reference, which reads as missing. Deleting a Scan keeps its Findings and sets their scan_id to null.