# shawnzhong/depsurf architecture

> Architecture diagram of the GitHub repository shawnzhong/depsurf, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shawnzhong/depsurf
- Repository: https://github.com/shawnzhong/depsurf

## Overview

##### Project type and purpose
- DepSurf is a research‐oriented data‐analysis tool (not a web service or a multi­-tiered product). It consists of a core Python library plus Jupyter notebooks that drive a data‐processing pipeline to analyze eBPF–kernel dependency mismatches.
- The README confirms its purpose: ingest Linux kernel images and eBPF programs, compute dependency “surfaces,” diff across versions, and produce tables/plots for a EuroSys paper.

##### File structure
- Top level:
- `depsurf/` – the core library, subdivided into:
– `btf/`: type info processing
– `diff/`: computing dependency‐surface differences
– `funcs/`: extracting function metadata
– `linux/`: loading & analyzing kernel images
– other modules: `dep.py`, `prep.py`, `report.py`, `issues.py`
- `data/` – data artifacts:
– `dataset/`: precomputed kernel dependency sets
– `software/`: sample eBPF programs
– `website/`: static site content
- `utils/` – helper routines for notebooks (plotting, LaTeX, paths)
- Jupyter notebooks (`00_*.ipynb`…`52_summary.ipynb`) that sequentially:
1. Install dependencies
2. Download kernels
3. Build dataset
4. Compute diffs & stats
5. Generate plots/tables
- `archive/` – legacy code & experimental tools (can be shown as a side/optional module)

##### Key insights from README
- The sequence of notebooks defines the pipeline stages.
- The library modules map directly to pipeline functionality: BTF parsing, diff logic, function extraction, kernel‐image handling, reporting.
- External dependencies: Python 3.11+, Jupyter Lab, uv (for environment), Linux kernels (23 GB+), Git submodules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Sources
    subgraph "Data Sources"
        direction TB
        Kernels["Linux Kernel Archives"]:::dataStore
        EBPF["eBPF Program Corpus"]:::dataStore
    end

    %% Pipeline Orchestrator
    subgraph "Pipeline Orchestrator (Jupyter Notebooks)"
        direction TB
        NB00["00_deps.ipynb"]:::notebook
        NB11["11_download.ipynb"]:::notebook
        NB20["20_dataset.ipynb"]:::notebook
        NB30["30_diff.ipynb"]:::notebook
        NB35["35_src.ipynb"]:::notebook
        NB36["36_breakdown.ipynb"]:::notebook
        NB39["39_config.ipynb"]:::notebook
        NB40["40_inline.ipynb"]:::notebook
        NB41["41_transform.ipynb"]:::notebook
        NB42["42_dup.ipynb"]:::notebook
        NB50["50_programs.ipynb"]:::notebook
        NB51["51_plot.ipynb"]:::notebook
        NB52["52_summary.ipynb"]:::notebook
        NB60["60_website.ipynb"]:::notebook
    end

    %% Core Library Modules
    subgraph "Core Library (depsurf/)" 
        direction TB
        Library["depsurf/"]:::library
        BTF["BTF Parser (btf/)"]:::library
        Diff["Diff Engine (diff/)"]:::library
        Funcs["Function Extractor (funcs/)"]:::library
        LinuxLoader["Linux-Image Loader (linux/)"]:::library
        Prep["Dependency Preparer (prep.py)"]:::library
        DepModel["Dependency Model (dep.py)"]:::library
        Report["Report Generator (report.py)"]:::library
        Issues["Issue Definitions (issues.py)"]:::library
        BPFProg["BPF Program Interface (bpf_program.py)"]:::library
        Paths["Path Utilities (paths.py)"]:::library
        Version["Version Handling (version*.py)"]:::library
    end

    %% Utilities and Legacy
    subgraph "Auxiliary Components"
        direction TB
        Utils["utils/"]:::util
        Archive["archive/"]:::legacy
    end

    %% Data Stores
    subgraph "Data Stores"
        direction TB
        Dataset["data/dataset/"]:::dataStore
        Cache["BTF/Dump Cache"]:::dataStore
        Software["data/software/"]:::dataStore
        WebsiteContent["data/website/"]:::dataStore
    end

    %% Outputs
    subgraph "Outputs"
        direction TB
        Plots["Plots & Tables"]:::output
        Site["Generated Website"]:::output
    end

    %% Flow Connections
    Kernels --> NB11
    EBPF --> NB11
    NB11 --> LinuxLoader
    LinuxLoader --> Dataset
    Dataset --> NB20
    NB20 --> Prep
    Prep --> Dataset
    Dataset --> NB30
    NB30 --> Diff
    Diff --> Dataset
    Dataset --> NB35
    NB35 --> Funcs
    NB36 --> BTF
    NB39 --> Diff
    NB40 --> Funcs
    NB41 --> Funcs
    NB42 --> Funcs
    NB50 --> BPFProg
    NB51 --> Report
    NB51 --> Utils
    NB52 --> Report
    NB60 --> Site

    %% Environment Wrapper
    subgraph "Environment"
        direction TB
        JLab["Jupyter Lab / uv env"]
    end
    JLab --> NB00
    JLab --> NB11
    JLab --> NB20
    JLab --> NB30
    JLab --> NB35
    JLab --> NB36
    JLab --> NB39
    JLab --> NB40
    JLab --> NB41
    JLab --> NB42
    JLab --> NB50
    JLab --> NB51
    JLab --> NB52
    JLab --> NB60

    %% Click Events
    click Library "https://github.com/shawnzhong/depsurf/tree/main/depsurf/"
    click BTF "https://github.com/shawnzhong/depsurf/tree/main/depsurf/btf/"
    click Diff "https://github.com/shawnzhong/depsurf/tree/main/depsurf/diff/"
    click Funcs "https://github.com/shawnzhong/depsurf/tree/main/depsurf/funcs/"
    click LinuxLoader "https://github.com/shawnzhong/depsurf/tree/main/depsurf/linux/"
    click Prep "https://github.com/shawnzhong/depsurf/blob/main/depsurf/prep.py"
    click DepModel "https://github.com/shawnzhong/depsurf/blob/main/depsurf/dep.py"
    click Report "https://github.com/shawnzhong/depsurf/blob/main/depsurf/report.py"
    click Issues "https://github.com/shawnzhong/depsurf/blob/main/depsurf/issues.py"
    click BPFProg "https://github.com/shawnzhong/depsurf/blob/main/depsurf/bpf_program.py"
    click Paths "https://github.com/shawnzhong/depsurf/blob/main/depsurf/paths.py"
    click Version "https://github.com/shawnzhong/depsurf/blob/main/depsurf/version.py"
    click Utils "https://github.com/shawnzhong/depsurf/tree/main/utils/"
    click Archive "https://github.com/shawnzhong/depsurf/tree/main/archive/"
    click Dataset "https://github.com/shawnzhong/depsurf/tree/main/data/dataset/"
    click Software "https://github.com/shawnzhong/depsurf/tree/main/data/software/"
    click WebsiteContent "https://github.com/shawnzhong/depsurf/tree/main/data/website/"
    click NB00 "https://github.com/shawnzhong/depsurf/blob/main/00_deps.ipynb"
    click NB11 "https://github.com/shawnzhong/depsurf/blob/main/11_download.ipynb"
    click NB20 "https://github.com/shawnzhong/depsurf/blob/main/20_dataset.ipynb"
    click NB30 "https://github.com/shawnzhong/depsurf/blob/main/30_diff.ipynb"
    click NB35 "https://github.com/shawnzhong/depsurf/blob/main/35_src.ipynb"
    click NB36 "https://github.com/shawnzhong/depsurf/blob/main/36_breakdown.ipynb"
    click NB39 "https://github.com/shawnzhong/depsurf/blob/main/39_config.ipynb"
    click NB40 "https://github.com/shawnzhong/depsurf/blob/main/40_inline.ipynb"
    click NB41 "https://github.com/shawnzhong/depsurf/blob/main/41_transform.ipynb"
    click NB42 "https://github.com/shawnzhong/depsurf/blob/main/42_dup.ipynb"
    click NB50 "https://github.com/shawnzhong/depsurf/blob/main/50_programs.ipynb"
    click NB51 "https://github.com/shawnzhong/depsurf/blob/main/51_plot.ipynb"
    click NB52 "https://github.com/shawnzhong/depsurf/blob/main/52_summary.ipynb"
    click NB60 "https://github.com/shawnzhong/depsurf/blob/main/60_website.ipynb"

    %% Styles
    classDef dataStore fill:#D0E6FF,stroke:#0055AA,color:#003366
    classDef library fill:#E0FFE0,stroke:#008800,color:#004400
    classDef notebook fill:#FFE6B3,stroke:#CC8400,color:#663C00
    classDef output fill:#EBD0FF,stroke:#8000CC,color:#400066
    classDef util fill:#FFF2D9,stroke:#CC8800,color:#663C00
    classDef legacy fill:#F0F0F0,stroke:#888888,color:#666666,stroke-dasharray: 5 5
```
