# sumitvekariya/sol2seq architecture

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

- Interactive diagram: https://gitdiagram.com/sumitvekariya/sol2seq
- Repository: https://github.com/sumitvekariya/sol2seq

## Overview

##### Main Components
- Library Core: Represented by src/lib.rs, this package exposes functions like generate_diagram_from_file and generate_diagram_from_sources.
- AST Parsing & Processing: Handled mostly in src/ast.rs and src/types.rs, where Solidity AST JSON and/or Solidity sources are parsed into internal representations.
- Utility Components: Found in src/utils.rs to assist with common operations required by multiple modules.
- Examples, Samples & Tests: The “examples” and “samples” directories illustrate usage scenarios and outputs (like example_diagram.md and combined_ast.json), while the “tests” directory contains unit tests ensuring correctness.

##### Component Relationships and Data Flow
- The CLI layer accepts user inputs (file paths, options) and invokes library functions.
- Input files (Solidity source or AST JSON) are read by the CLI or library, triggering the AST parsing flow.
- AST parsing converts the raw Solidity representations into structured internal types.
- The output is delivered either as a file (via an output file path) or to stdout.
- The library’s API is modular, so external projects can integrate these functions directly as a Rust dependency.

##### Incorporate Technologies & Frameworks
- Rust (Cargo.toml indicates use of Cargo for build and dependency management)
- Any Rust libraries used for error handling (e.g., anyhow) or possibly serde (for JSON parsing of AST) – while not explicitly shown, these are common in such tools.
- CLI argument parsing libraries (if applicable) to process commands and options.

##### Elements
- CLI Interface (src/main.rs)
- Core Library (src/lib.rs)
- AST Parser (src/ast.rs and src/types.rs)
- Utility Methods (src/utils.rs)
- Example and Test Artifacts (examples/, samples, tests/)

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Input Layer"
        CLI["CLI Interface\n(Handles commands 'source' & 'ast')"]:::input
    end

    subgraph "Processing Layer"
        LIB["Library Core\n(Exposes generate_diagram_from_file & generate_diagram_from_sources)"]:::processing
        subgraph "AST Parsing Module"
            AST["AST Parser\n(src/ast.rs)"]:::processing
            TYPES["Types Definitions\n(src/types.rs)"]:::processing
        end
        DIAG["Diagram Generator Module\n(Generates Mermaid diagram)"]:::processing
        UTILS["Utility Components\n(Assists common operations)"]:::processing
    end

    subgraph "Output Layer"
        OUTPUT["Output Renderer\n(Mermaid Diagram as file or stdout)"]:::output
    end

    subgraph "Artifacts"
        EX["Examples"]:::artifact
        SM["Samples"]:::artifact
        TEST["Tests"]:::artifact
    end

    %% Data Flow Connections
    CLI -->|"InvokeAPI"| LIB
    LIB -->|"ParseSolidity"| AST
    AST -->|"UtilizeTypes"| TYPES
    AST -->|"GenerateDiagram"| DIAG
    TYPES -->|"SupportParsing"| DIAG
    DIAG -->|"RenderDiagram"| OUTPUT

    %% Utility Dependencies (dashed lines)
    UTILS -.-> LIB
    UTILS -.-> AST
    UTILS -.-> DIAG

    %% Click Events
    click CLI "https://github.com/sumitvekariya/sol2seq/blob/main/src/main.rs"
    click LIB "https://github.com/sumitvekariya/sol2seq/blob/main/src/lib.rs"
    click AST "https://github.com/sumitvekariya/sol2seq/blob/main/src/ast.rs"
    click TYPES "https://github.com/sumitvekariya/sol2seq/blob/main/src/types.rs"
    click DIAG "https://github.com/sumitvekariya/sol2seq/blob/main/src/diagram.rs"
    click UTILS "https://github.com/sumitvekariya/sol2seq/blob/main/src/utils.rs"
    click EX "https://github.com/sumitvekariya/sol2seq/tree/main/examples/"
    click SM "https://github.com/sumitvekariya/sol2seq/tree/main/samples/"
    click TEST "https://github.com/sumitvekariya/sol2seq/tree/main/tests/"

    %% Styles
    classDef input fill:#e0f7fa,stroke:#006064,stroke-width:2px;
    classDef processing fill:#fff9c4,stroke:#f57f17,stroke-width:2px;
    classDef output fill:#dcedc8,stroke:#558b2f,stroke-width:2px;
    classDef artifact fill:#f8bbd0,stroke:#ad1457,stroke-width:2px;
```
