# dxrie/binspy architecture

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

- Interactive diagram: https://gitdiagram.com/dxrie/binspy
- Repository: https://github.com/dxrie/binspy

## Overview

BinSpy is a terminal ELF inspection tool. The user supplies a binary; the entry point loads and validates it, then launches the TUI, which discovers functions, disassembles selected code, checks mitigations, and displays contextual vulnerability findings. The graph separates ELF analysis, vulnerability analysis, and presentation. The standalone display module is included, but no call to it is shown. Relationships involving unsampled implementation details are omitted; README statements support documented capabilities, while source excerpts support the shown calls.

Main entry points: [`src/tui.c`](https://github.com/dxrie/binspy/blob/main/src/tui.c) (Interactive TUI), [`src/main.c`](https://github.com/dxrie/binspy/blob/main/src/main.c) (Program entry), [`src/elf_parser.c`](https://github.com/dxrie/binspy/blob/main/src/elf_parser.c) (ELF loading and validation), [`src/vuln_analyzer.c`](https://github.com/dxrie/binspy/blob/main/src/vuln_analyzer.c) (Vulnerability analysis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Entry workflow"]
  node_main["Program entry<br/>[main.c]"]
end

subgraph group_elf["ELF analysis"]
  node_elf_parse["ELF loading and validation<br/>[elf_parser.c]"]
  node_function_discovery["Function discovery<br/>[elf_parser.c]"]
  node_mitigations["Mitigation checks<br/>[elf_parser.c]"]
end

subgraph group_security["Security analysis"]
  node_vuln["Vulnerability analysis<br/>[vuln_analyzer.c]"]
end

subgraph group_ui["Presentation"]
  node_tui["Interactive TUI<br/>[tui.c]"]
  node_disassembly["Assembly rendering<br/>[tui.c]"]
  node_display["Terminal display helpers<br/>[display.c]"]
end

node_user(("Analyst"))
node_binary["ELF file"]
node_capstone["Capstone disassembler"]
node_ncurses["Ncurses terminal UI"]

node_user -->|"starts with"| node_main
node_binary -->|"loads"| node_elf_parse
node_main -->|"initializes and validates"| node_elf_parse
node_main -->|"launches"| node_tui
node_tui -->|"finds functions"| node_function_discovery
node_tui -->|"checks protections"| node_mitigations
node_tui -->|"renders selected code"| node_disassembly
node_disassembly -->|"disassembles bytes"| node_capstone
node_tui -->|"analyzes instructions"| node_vuln
node_tui -->|"draws interface"| node_ncurses

click node_main "https://github.com/dxrie/binspy/blob/main/src/main.c"
click node_elf_parse "https://github.com/dxrie/binspy/blob/main/src/elf_parser.c"
click node_function_discovery "https://github.com/dxrie/binspy/blob/main/src/elf_parser.c"
click node_mitigations "https://github.com/dxrie/binspy/blob/main/src/elf_parser.c"
click node_vuln "https://github.com/dxrie/binspy/blob/main/src/vuln_analyzer.c"
click node_tui "https://github.com/dxrie/binspy/blob/main/src/tui.c"
click node_disassembly "https://github.com/dxrie/binspy/blob/main/src/tui.c"
click node_display "https://github.com/dxrie/binspy/blob/main/src/display.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_ncurses toneBlue
class node_elf_parse,node_function_discovery,node_mitigations toneAmber
class node_vuln toneMint
class node_tui,node_disassembly,node_display toneRose
class node_user,node_binary,node_capstone toneIndigo
```

## Components

### Entry workflow

- [Program entry](https://github.com/dxrie/binspy/blob/main/src/main.c): `src/main.c`

### ELF analysis

- [ELF loading and validation](https://github.com/dxrie/binspy/blob/main/src/elf_parser.c): `src/elf_parser.c`
- [Function discovery](https://github.com/dxrie/binspy/blob/main/src/elf_parser.c): `src/elf_parser.c`
- [Mitigation checks](https://github.com/dxrie/binspy/blob/main/src/elf_parser.c): `src/elf_parser.c`

### Security analysis

- [Vulnerability analysis](https://github.com/dxrie/binspy/blob/main/src/vuln_analyzer.c): `src/vuln_analyzer.c`

### Presentation

- [Interactive TUI](https://github.com/dxrie/binspy/blob/main/src/tui.c): `src/tui.c`
- [Assembly rendering](https://github.com/dxrie/binspy/blob/main/src/tui.c): `src/tui.c`
- [Terminal display helpers](https://github.com/dxrie/binspy/blob/main/src/display.c): `src/display.c`

### Other components

- **Analyst**
- **ELF file**
- **Capstone disassembler**
- **Ncurses terminal UI**

## Connections

- Analyst → Program entry: starts with (evidence: `src/main.c`)
- ELF file → ELF loading and validation: loads (evidence: `src/elf_parser.c`)
- Program entry → ELF loading and validation: initializes and validates (evidence: `src/main.c`)
- Program entry → Interactive TUI: launches (evidence: `src/main.c`)
- Interactive TUI → Function discovery: finds functions (evidence: `src/tui.c`)
- Interactive TUI → Mitigation checks: checks protections (evidence: `src/tui.c`)
- Interactive TUI → Assembly rendering: renders selected code (evidence: `src/tui.c`)
- Assembly rendering → Capstone disassembler: disassembles bytes (evidence: `src/tui.c`)
- Interactive TUI → Vulnerability analysis: analyzes instructions (evidence: `src/tui.c`)
- Interactive TUI → Ncurses terminal UI: draws interface (evidence: `src/tui.c`)
