# fugue-re/fugue-core architecture

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

- Interactive diagram: https://gitdiagram.com/fugue-re/fugue-core
- Repository: https://github.com/fugue-re/fugue-core

## Overview

##### Main Components Organization

a) Core Infrastructure Layer:
- `fugue-core` at the center as it's the fundamental collection of crates
- Following core components around it:
- `fugue-arch` (Architecture definitions)
- `fugue-bv` (Bit vectors)
- `fugue-fp` (Floating point numbers)
- `fugue-bytes` (Endian-aware conversions)

b) Program Analysis Layer:
- `fugue-db` and `fugue-ir` above the core layer
- `fugue-db` for the knowledge database
- `fugue-ir` for intermediate representation and disassembly

c) External Integration Layer:
- Interfaces with third-party tools that can populate the knowledge database

##### Component Relationships

- How binary input flows through the system:
- Binary file → Knowledge Database (`fugue-db`)
- `fugue-db` → Intermediate Representation (`fugue-ir`)
- Core components supporting both layers

b) Dependencies:
- How `fugue-ir` depends on core components for:
- Architecture information (`fugue-arch`)
- Bit manipulation (`fugue-bv`)
- Endian handling (`fugue-bytes`)

##### Detailed Component Breakdown

For each major component, create a sub-section showing internal structure:

a) fugue-ir:
- Disassembly pipeline:
- Parser
- Lifter
- IL (Intermediate Language) components
- Symbol handling
- Translation system

b) fugue-db:
- Database schema structure
- Backend interfaces
- Metadata handling

##### Notes

Annotations for:
- Version compatibility
- Core capabilities
- Extension points
- Performance considerations

Remember to emphasize the modular nature of the framework and how it supports rapid prototyping of new binary analysis tools, as this is a key feature mentioned in the README.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "Core Infrastructure Layer"
        Core["Core Framework"]:::core
        Arch["Architecture Definitions"]:::core
        BV["Bit Vector Operations"]:::core
        FP["Floating Point Handling"]:::core
        Bytes["Endian-aware Conversions"]:::core
    end

    subgraph "Program Analysis Layer"
        DB["Knowledge Database"]:::analysis
        IR["Intermediate Representation"]:::analysis

        subgraph "IR Components"
            Parser["Parser"]:::ir
            Lifter["Lifter"]:::ir
            IL["IL Components"]:::ir
            Symbols["Symbol Handling"]:::ir
            Trans["Translation System"]:::ir
        end

        subgraph "DB Components"
            Schema["Schema Definition"]:::db
            Backend["Backend Interface"]:::db
            Meta["Metadata Handling"]:::db
            BBAnalysis["Basic Block Analysis"]:::db
            FuncAnalysis["Function Analysis"]:::db
            ArchSupport["Architecture Support"]:::db
        end
    end

    subgraph "External Integration Layer"
        ThirdParty["Third-party Tools"]:::external
        Plugins["Custom Analysis Plugins"]:::external
    end

    %% Core Infrastructure Relationships
    Core --> Arch
    Core --> BV
    Core --> FP
    Core --> Bytes

    %% IR Dependencies
    IR --> Core
    IR --> Arch
    IR --> BV
    IR --> Bytes
    Parser --> IR
    Lifter --> IR
    IL --> IR
    Symbols --> IR
    Trans --> IR

    %% DB Dependencies
    DB --> Core
    Schema --> DB
    Backend --> DB
    Meta --> DB
    BBAnalysis --> DB
    FuncAnalysis --> DB
    ArchSupport --> DB

    %% External Integration
    ThirdParty -.-> DB
    Plugins -.-> IR

    %% Click Events
    click Core "https://github.com/fugue-re/fugue-core/tree/crates-io/fugue-core"
    click Arch "https://github.com/fugue-re/fugue-core/tree/crates-io/fugue-arch"
    click BV "https://github.com/fugue-re/fugue-core/tree/crates-io/fugue-bv"
    click FP "https://github.com/fugue-re/fugue-core/tree/crates-io/fugue-fp"
    click Bytes "https://github.com/fugue-re/fugue-core/tree/crates-io/fugue-bytes"
    click Parser "https://github.com/fugue-re/fugue-core/blob/crates-io/fugue-ir/src/deserialise/parse.rs"
    click Lifter "https://github.com/fugue-re/fugue-core/blob/crates-io/fugue-ir/src/disassembly/lift.rs"
    click Symbols "https://github.com/fugue-re/fugue-core/tree/crates-io/fugue-ir/src/disassembly/symbol/"
    click Trans "https://github.com/fugue-re/fugue-core/blob/crates-io/fugue-ir/src/translator.rs"
    click IL "https://github.com/fugue-re/fugue-core/tree/crates-io/fugue-ir/src/il/"
    click Schema "https://github.com/fugue-re/fugue-core/tree/crates-io/fugue-db/schema"
    click Backend "https://github.com/fugue-re/fugue-core/blob/crates-io/fugue-db/src/backend/mod.rs"
    click Meta "https://github.com/fugue-re/fugue-core/blob/crates-io/fugue-db/src/metadata.rs"
    click BBAnalysis "https://github.com/fugue-re/fugue-core/blob/crates-io/fugue-db/src/basic_block.rs"
    click FuncAnalysis "https://github.com/fugue-re/fugue-core/blob/crates-io/fugue-db/src/function.rs"
    click ArchSupport "https://github.com/fugue-re/fugue-core/blob/crates-io/fugue-db/src/architecture.rs"

    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef analysis fill:#4CAF50,stroke:#2E7D32,color:white
    classDef external fill:#FFC107,stroke:#FFA000,color:black
    classDef ir fill:#81C784,stroke:#4CAF50,color:black
    classDef db fill:#90CAF9,stroke:#2196F3,color:black

    %% Legend
    subgraph Legend
        L1["Core Component"]:::core
        L2["Analysis Component"]:::analysis
        L3["External Integration"]:::external
        L4["IR Component"]:::ir
        L5["DB Component"]:::db
    end
```
