Audit Trail ERD Mermaid

Last modified by Robert Schaub on 2025/12/22 13:49

erDiagram
    USERS ||--o{ EDITS : makes
    CLAIMS ||--o{ EDITS : tracks
    EVIDENCE ||--o{ EDITS : tracks
    SOURCES ||--o{ EDITS : tracks
    SCENARIO ||--o{ EDITS : tracks
    USERS {
        uuid id PK
        text name
        text email
    }
    CLAIMS {
        uuid id PK
        text text
    }
    EVIDENCE {
        uuid id PK
        uuid claim_id FK
    }
    SOURCES {
        uuid id PK
        text name
    }
    SCENARIO {
        uuid id PK
        uuid claim_id FK
    }
    EDITS {
        uuid id PK
        text entity_type "claim|evidence|source|scenario|user"
        uuid entity_id "FK to edited entity"
        uuid user_id FK "NULL for AKEL"
        text change_type "create|update|delete|moderate"
        boolean is_automated "true for AKEL edits"
        jsonb changes "before/after values"
        text reason "explanation"
        timestamp created_at
    }

Audit Trail ERD - Shows how all changes are tracked. Every significant change to Claims, Evidence, Sources, or Scenarios creates an Edit record. Edits track who made the change (user_id, NULL for AKEL), what changed (before/after in JSONB), when (created_at), and why (reason). The is_automated flag distinguishes human edits from AKEL updates. This is the "hot" audit trail stored in PostgreSQL. See Data Model for two-tier edit history architecture (hot/cold storage).