# leptos-null/headerviewer architecture

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

- Interactive diagram: https://gitdiagram.com/leptos-null/headerviewer
- Repository: https://github.com/leptos-null/headerviewer

## Overview

##### Project type and purpose
- HeaderViewer is a native iOS/macOS SwiftUI application.
- Its purpose is to display Objective-C class and protocol headers at runtime by leveraging the ClassDumpRuntime submodule.

##### File structure
Top-level components:
- .github/workflows – CI/CD release pipeline
- .gitmodules – ClassDumpRuntime submodule declaration
- ClassDumpRuntime – external library for dumping Objective-C runtime types
- HeaderViewer.xcodeproj & workspace – Xcode project and workspace metadata
- HeaderViewer (app target)
– Assets.xcassets (AccentColor, AppIcon)
– Info.plist & entitlements
– SwiftUI view files (ContentView, ListView, RuntimeObjectsView, ImageRuntimeObjectsView, RuntimeObjectDetail, etc.)
– Model types (NamedNode, RuntimeListings, RuntimeObjectType)
- HeaderViewerUITests – UI testing target and screenshot automation
- docs – user-facing screenshots

##### Key insights from README
- RuntimeBrowser-style UI: list, search, navigation between types
- Ability to load & browse system images on demand

a. UI Layer
- Entry point: HeaderViewerApp.swift → ContentView
- & Navigation views: ListView, RuntimeObjectsView, ImageRuntimeObjectsView
- Detail & syntax highlighting: RuntimeObjectDetail, SemanticStringView
b. Business Logic / Data Layer
- RuntimeListings: orchestrates ClassDumpRuntime calls, caches loaded headers
- NamedNode / RuntimeObjectType: model representation of classes, protocols, images
c. External Dependency
- ClassDumpRuntime submodule: C/Objective-C library that inspects the running process and emits header text
d. System / OS
- iOS/iPadOS runtime providing dynamic library loading and Objective-C runtime
e. Testing
- HeaderViewerUITests: automatic screenshot capture and UI validation

##### Relationships and data flow
- UI views call into RuntimeListings to fetch node lists or header text
- RuntimeListings invokes ClassDumpRuntime APIs
- ClassDumpRuntime returns raw header strings → passed back to SemanticStringView for syntax coloring
- User interactions (search, image-browser taps) traverse the view hierarchy and trigger new data fetches
- CI pipeline builds the app and publishes releases via .github/workflows/release.yml

##### Architectural patterns & design principles
- MVVM-style separation: SwiftUI Views observe models exposed by RuntimeListings & NamedNode
- Single source of truth: RuntimeListings holds cache & publishes updates via @Published properties
- Modular external dependency: ClassDumpRuntime isolated as a submodule
- Test automation: UI tests for regression and screenshot documentation

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer"
        direction TB
        HVApp["HeaderViewerApp"]:::ui
        ContentView["ContentView"]:::ui
        ListView["ListView"]:::ui
        RuntimeObjectsView["RuntimeObjectsView"]:::ui
        ImageRuntimeObjectsView["ImageRuntimeObjectsView"]:::ui
        RuntimeObjectDetail["RuntimeObjectDetail"]:::ui
        SemanticStringView["SemanticStringView"]:::ui
        NamedNodeView["NamedNodeView"]:::ui
    end

    %% Business Logic Layer
    subgraph "Business Logic Layer"
        direction TB
        RuntimeListings["RuntimeListings"]:::business
        NamedNode["NamedNode"]:::business
        RuntimeObjectType["RuntimeObjectType"]:::business
    end

    %% External Dependency
    subgraph "External Library"
        direction TB
        ClassDumpRuntime["ClassDumpRuntime"]:::external
    end

    %% OS / Runtime
    subgraph "iOS/iPadOS Runtime"
        direction TB
        ObjCRuntime["Objective-C Runtime & Dynamic Loader"]:::os
    end

    %% Testing
    subgraph "Testing"
        direction TB
        UITests["GatherScreenshots (UI Tests)"]:::tests
    end

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        direction TB
        GitHubActions[".github/workflows/release.yml"]:::ci
    end

    %% Connections
    HVApp -->|launches| ContentView
    ContentView -->|navigates to| ListView
    ContentView -->|navigates to| RuntimeObjectsView
    ContentView -->|navigates to| ImageRuntimeObjectsView
    ListView -->|fetches data| RuntimeListings
    RuntimeObjectsView -->|fetches data| RuntimeListings
    ImageRuntimeObjectsView -->|fetches data| RuntimeListings
    RuntimeListings -->|calls| ClassDumpRuntime
    ClassDumpRuntime -->|returns header strings| RuntimeListings
    RuntimeListings -->|provides nodes| NamedNode
    RuntimeListings -->|provides types| RuntimeObjectType
    NamedNode -->|renders via| NamedNodeView
    NamedNodeView -->|selects| RuntimeObjectDetail
    RuntimeObjectDetail -->|renders text with| SemanticStringView
    ClassDumpRuntime -->|runs on| ObjCRuntime
    UITests -->|tests UI of| ContentView
    GitHubActions -->|builds & releases| HVApp

    %% Click Events
    click HVApp "https://github.com/leptos-null/headerviewer/blob/main/HeaderViewer/HeaderViewerApp.swift"
    click ContentView "https://github.com/leptos-null/headerviewer/blob/main/HeaderViewer/ContentView.swift"
    click ListView "https://github.com/leptos-null/headerviewer/blob/main/HeaderViewer/ListView.swift"
    click RuntimeObjectsView "https://github.com/leptos-null/headerviewer/blob/main/HeaderViewer/RuntimeObjectsView.swift"
    click ImageRuntimeObjectsView "https://github.com/leptos-null/headerviewer/blob/main/HeaderViewer/ImageRuntimeObjectsView.swift"
    click RuntimeObjectDetail "https://github.com/leptos-null/headerviewer/blob/main/HeaderViewer/RuntimeObjectDetail.swift"
    click SemanticStringView "https://github.com/leptos-null/headerviewer/blob/main/HeaderViewer/SemanticStringView.swift"
    click NamedNodeView "https://github.com/leptos-null/headerviewer/blob/main/HeaderViewer/NamedNodeView.swift"
    click NamedNode "https://github.com/leptos-null/headerviewer/blob/main/HeaderViewer/NamedNode.swift"
    click RuntimeObjectType "https://github.com/leptos-null/headerviewer/blob/main/HeaderViewer/RuntimeObjectType.swift"
    click RuntimeListings "https://github.com/leptos-null/headerviewer/blob/main/HeaderViewer/RuntimeListings.swift"
    click GitHubActions "https://github.com/leptos-null/headerviewer/blob/main/.github/workflows/release.yml"
    click UITests "https://github.com/leptos-null/headerviewer/blob/main/HeaderViewerUITests/GatherScreenshots.swift"
    click ClassDumpRuntime "https://github.com/leptos-null/headerviewer/tree/main/ClassDumpRuntime/"
    click Assets "https://github.com/leptos-null/headerviewer/blob/main/HeaderViewer/Assets.xcassets"
    click InfoPlist "https://github.com/leptos-null/headerviewer/blob/main/HeaderViewer/Info.plist"
    click Entitlements "https://github.com/leptos-null/headerviewer/blob/main/HeaderViewer/HeaderViewer.entitlements"

    %% Styles
    classDef ui fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef business fill:#90EE90,stroke:#000,stroke-width:1px
    classDef external fill:#FFA500,stroke:#000,stroke-width:1px
    classDef os fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef tests fill:#E6E6FA,stroke:#000,stroke-width:1px
    classDef ci fill:#F5DEB3,stroke:#000,stroke-width:1px
```
