graph TB
    subgraph "API & Web Interface Layer"
        API["<b>API Endpoints</b><br/>/api/demo/classify<br/>/api/demo/boundary-check<br/>/api/demo/pressure-check<br/>/api/admin/* • /api/auth/*"]
        WEB["<b>Web Interface</b><br/>Interactive Demos<br/>Admin Dashboard<br/>Documentation<br/>Blog System"]
    end

    subgraph "Tractatus Governance Layer"
        BE["<b>BoundaryEnforcer</b><br/>Blocks values decisions<br/>• Privacy decisions<br/>• Ethical trade-offs<br/>• User agency violations"]
        IPC["<b>InstructionPersistenceClassifier</b><br/>Classifies & stores instructions<br/>• Quadrant (STR/OPS/TAC/SYS)<br/>• Persistence (HIGH/MED/LOW)<br/>• Temporal scope"]
        CRV["<b>CrossReferenceValidator</b><br/>Prevents pattern bias override<br/>• Checks instruction history<br/>• Detects conflicts (27027)<br/>• Blocks contradictions"]
        CPM["<b>ContextPressureMonitor</b><br/>Detects degraded conditions<br/>• Token budget tracking<br/>• Error accumulation<br/>• Checkpoint reporting"]
        MV["<b>MetacognitiveVerifier</b><br/>Self-checks complex operations<br/>• >3 files or >5 steps<br/>• Architecture changes<br/>• Confidence scoring"]
        PDO["<b>PluralisticDeliberationOrchestrator</b><br/>Facilitates values deliberation<br/>• Multi-stakeholder engagement<br/>• Moral framework mapping<br/>• Precedent documentation"]
    end

    subgraph "MongoDB Persistence Layer"
        GR["<b>governance_rules</b><br/>• rule_id (STR-001...)<br/>• quadrant<br/>• persistence level<br/>• enforced_by<br/>• violation_action<br/>• active status"]
        AL["<b>audit_logs</b><br/>• timestamp<br/>• service (which enforcer)<br/>• action (BLOCK/WARN)<br/>• instruction<br/>• rule_violated<br/>• session_id"]
        SS["<b>session_state</b><br/>• session_id<br/>• token_count<br/>• message_count<br/>• pressure_level<br/>• last_checkpoint<br/>• framework_active"]
        IH["<b>instruction_history</b><br/>• instruction_id<br/>• content<br/>• classification<br/>• persistence<br/>• created_at<br/>• active status"]
    end

    subgraph "Claude Code Runtime Environment"
        CC["<b>Base LLM Environment</b><br/>Session Management • Tool Access<br/>File System Operations<br/>.claude/instruction-history.json<br/>.claude/session-state.json<br/>.claude/token-checkpoints.json<br/><i>Context Window (200k tokens)</i>"]
    end

    %% Data Flow
    API --> BE
    API --> IPC
    WEB --> CRV
    WEB --> CPM

    BE --> GR
    BE --> PDO
    IPC --> AL
    CRV --> IH
    CPM --> SS
    MV --> AL
    PDO --> AL

    GR --> CC
    AL --> CC
    SS --> CC
    IH --> CC

    %% Styling
    classDef api fill:#f3e8ff,stroke:#a855f7,stroke-width:2px
    classDef governance fill:#f0fdf4,stroke:#10b981,stroke-width:2px
    classDef persistence fill:#fef9c3,stroke:#eab308,stroke-width:2px
    classDef runtime fill:#dbeafe,stroke:#3b82f6,stroke-width:2px

    class API,WEB api
    class BE,IPC,CRV,CPM,MV,PDO governance
    class GR,AL,SS,IH persistence
    class CC runtime
