%%{init: {'theme': 'base', 'themeVariables': { 'primaryColor': '#e8f4fd', 'primaryTextColor': '#1a1a1a', 'primaryBorderColor': '#4a90d9', 'lineColor': '#4a90d9', 'secondaryColor': '#f0f7e6', 'tertiaryColor': '#fff5e6'}}}%%
flowchart TB
    subgraph FileLayer["File Layer"]
        RFC[("RFC")]
    end

    subgraph FileData["Per-File Data"]
        FD["FD"]
    end

    subgraph Extracted["Extracted (ReactiveMerge)"]
        DECLS["D"]
        ANNOT["A"]
        VREFS["VR"]
        TREFS["TR"]
        CFI["CFI"]
    end

    subgraph TypeDeps["ReactiveTypeDeps"]
        DBP["DBP"]
        ATR["ATR"]
    end

    subgraph ExcDeps["ReactiveExceptionRefs"]
        EXCREF["ER"]
        EXCDECL["ED"]
        RESOLVED["RR"]
    end

    subgraph DeclRefs["ReactiveDeclRefs"]
        DR["DR"]
    end

    subgraph Liveness["ReactiveLiveness"]
        ROOTS["roots"]
        EDGES["edges"]
        FP["fixpoint"]
        LIVE["LIVE"]
    end

    RFC -->|"process"| FD
    FD -->|"flatMap"| DECLS
    FD -->|"flatMap"| ANNOT
    FD -->|"flatMap"| VREFS
    FD -->|"flatMap"| TREFS
    FD -->|"flatMap"| CFI

    DECLS -->|"flatMap"| DBP
    DBP -->|"union+flatMap"| ATR

    CFI -->|"flatMap"| EXCREF
    DECLS -->|"flatMap"| EXCDECL
    EXCREF -->|"join"| RESOLVED
    EXCDECL -->|"join"| RESOLVED

    DECLS --> DR
    VREFS --> DR
    TREFS --> DR
    ATR --> DR
    RESOLVED --> DR

    DECLS --> ROOTS
    ANNOT --> ROOTS

    DR -->|"flatMap"| EDGES
    ROOTS --> FP
    EDGES --> FP
    FP -->|"fixpoint"| LIVE

    classDef fileLayer fill:#e8f4fd,stroke:#4a90d9,stroke-width:2px
    classDef extracted fill:#f0f7e6,stroke:#6b8e23,stroke-width:2px
    classDef typeDeps fill:#fff5e6,stroke:#d4a574,stroke-width:2px
    classDef excDeps fill:#f5e6ff,stroke:#9966cc,stroke-width:2px
    classDef declRefs fill:#e6f0ff,stroke:#4a74d9,stroke-width:2px
    classDef liveness fill:#ffe6e6,stroke:#cc6666,stroke-width:2px
    classDef output fill:#e6ffe6,stroke:#2e8b2e,stroke-width:2px

    class RFC,FD fileLayer
    class DECLS,ANNOT,VREFS,TREFS,CFI extracted
    class DBP,ATR typeDeps
    class EXCREF,EXCDECL,RESOLVED excDeps
    class DR declRefs
    class ROOTS,EDGES,FP liveness
    class LIVE output
