# dlvhdr/gh-dash architecture

> Architecture diagram of the GitHub repository dlvhdr/gh-dash, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dlvhdr/gh-dash
- Repository: https://github.com/dlvhdr/gh-dash

## Overview

##### Main Components Identification

The system can be broken down into these major components:

a) Core Components:
- Command Line Interface (cmd/)
- Configuration Management (config/)
- Data Layer (data/)
- User Interface (ui/)
- Git Integration (git/)
- Utilities (utils/)

b) External Dependencies:
- GitHub API
- GitHub CLI (gh)
- Terminal Environment

**┌─────────────────────────────────────────────────────────┐**
- Terminal Environment                    │
- ┤
- gh-dash CLI                         │
- ┬───────────────┬────────────┬───────────┤
- Config Layer │   UI Layer    │ Data Layer │   Git     │
- (YAML)       │  (Bubbletea)  │ (API)      │ Integration│
- ┴───────────────┴────────────┴───────────┘

##### Component Details

a) UI Layer (Most Complex):
- Components (ui/components/)
- Common utilities (ui/common/)
- Theme management (ui/theme/)
- Markdown rendering (ui/markdown/)
- Key bindings (ui/keys/)
- Context management (ui/context/)

b) Data Layer:
- Interactions with:
- GitHub Issues API
- GitHub PRs API
- Repository data
- User data

c) Configuration Layer:
- Represent:
- YAML parsing
- Feature flags
- Default configurations
- Theme configurations

##### Interaction Flows

- User input → UI Layer
- UI Layer → Data Layer → GitHub API
- Configuration → All Layers
- Git Integration ↔ Local Repository

##### Clear separation between UI, data, and configuration layers

Remember to highlight the extensibility points, especially around custom keybindings and themes, as these are key features of the application.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Terminal
        CLI["Command Line Interface"]
        GH["GitHub CLI (gh)"]
    end

    subgraph Core["Core Application"]
        CMD["Command Handler"]:::cmd
        
        subgraph ConfigLayer["Configuration Layer"]
            Config["Config Manager"]:::config
            Parser["Config Parser"]:::config
            Features["Feature Flags"]:::config
        end
        
        subgraph UILayer["UI Layer"]
            UI["UI Controller"]:::ui
            
            subgraph Components["UI Components"]
                PR["Pull Requests"]:::component
                Issues["Issues"]:::component
                PRSidebar["PR Sidebar"]:::component
                IssueSidebar["Issue Sidebar"]:::component
                Search["Search"]:::component
                Table["Table"]:::component
            end
            
            subgraph UICore["UI Core"]
                Theme["Theme Manager"]:::ui
                Keys["Key Bindings"]:::ui
                Context["Context Manager"]:::ui
                Markdown["Markdown Renderer"]:::ui
                Common["Common Utilities"]:::ui
            end
        end
        
        subgraph DataLayer["Data Layer"]
            IssueAPI["Issues API"]:::data
            PRAPI["PRs API"]:::data
            RepoData["Repository Data"]:::data
            UserData["User Data"]:::data
        end
        
        Git["Git Integration"]:::git
        Utils["Utilities"]:::utils
    end
    
    subgraph External["External Systems"]
        GitHubAPI["GitHub API"]
        LocalRepo["Local Repository"]
    end

    %% Relationships
    CLI --> CMD
    CMD --> Config
    Config --> UILayer
    Config --> DataLayer
    
    UI --> Components
    UI --> UICore
    
    DataLayer --> GitHubAPI
    Git --> LocalRepo
    
    %% Click Events
    click CMD "https://github.com/dlvhdr/gh-dash/blob/main/cmd/root.go"
    click Config "https://github.com/dlvhdr/gh-dash/tree/main/config/"
    click Parser "https://github.com/dlvhdr/gh-dash/blob/main/config/parser.go"
    click Features "https://github.com/dlvhdr/gh-dash/blob/main/config/feature_flags.go"
    click IssueAPI "https://github.com/dlvhdr/gh-dash/blob/main/data/issueapi.go"
    click PRAPI "https://github.com/dlvhdr/gh-dash/blob/main/data/prapi.go"
    click RepoData "https://github.com/dlvhdr/gh-dash/blob/main/data/repository.go"
    click UserData "https://github.com/dlvhdr/gh-dash/blob/main/data/user.go"
    click UI "https://github.com/dlvhdr/gh-dash/tree/main/ui/"
    click Theme "https://github.com/dlvhdr/gh-dash/blob/main/ui/theme/theme.go"
    click Keys "https://github.com/dlvhdr/gh-dash/tree/main/ui/keys/"
    click Context "https://github.com/dlvhdr/gh-dash/blob/main/ui/context/context.go"
    click Markdown "https://github.com/dlvhdr/gh-dash/blob/main/ui/markdown/markdownRenderer.go"
    click Common "https://github.com/dlvhdr/gh-dash/tree/main/ui/common/"
    click PR "https://github.com/dlvhdr/gh-dash/blob/main/ui/components/pr/pr.go"
    click Issues "https://github.com/dlvhdr/gh-dash/blob/main/ui/components/issue/issue.go"
    click PRSidebar "https://github.com/dlvhdr/gh-dash/blob/main/ui/components/prsidebar/prsidebar.go"
    click IssueSidebar "https://github.com/dlvhdr/gh-dash/blob/main/ui/components/issuesidebar/issuesidebar.go"
    click Search "https://github.com/dlvhdr/gh-dash/blob/main/ui/components/search/search.go"
    click Table "https://github.com/dlvhdr/gh-dash/blob/main/ui/components/table/table.go"
    click Git "https://github.com/dlvhdr/gh-dash/blob/main/git/git.go"
    click Utils "https://github.com/dlvhdr/gh-dash/blob/main/utils/utils.go"

    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px
    classDef cmd fill:#d4d4d4,stroke:#333
    classDef config fill:#ffd700,stroke:#333
    classDef ui fill:#87ceeb,stroke:#333
    classDef component fill:#add8e6,stroke:#333
    classDef data fill:#90ee90,stroke:#333
    classDef git fill:#ff6b6b,stroke:#333
    classDef utils fill:#dda0dd,stroke:#333
    
    %% Legend
    subgraph Legend
        L1["Command"]:::cmd
        L2["Configuration"]:::config
        L3["UI"]:::ui
        L4["Data"]:::data
        L5["Git"]:::git
        L6["Utilities"]:::utils
    end
```
