# bhuvan0611/smartdoc-framework architecture

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

- Interactive diagram: https://gitdiagram.com/bhuvan0611/smartdoc-framework
- Repository: https://github.com/bhuvan0611/smartdoc-framework

## Overview

SmartDoc generates NatSpec documentation for Solidity contracts through static extraction, multi-agent analysis, LLM synthesis, validation, and source injection. The CLI entry point explicitly calls artifact extraction, orchestration, and injection; the README documents the broader agent and validation stages. The graph includes the documented extraction and evaluation capabilities, but several internal connections rely on README descriptions because their implementation files were not sampled.

Main entry points: [`extractor/artifact_extractor.py`](https://github.com/bhuvan0611/smartdoc-framework/blob/main/extractor/artifact_extractor.py) (Artifact Extractor), [`agents/orchestrator.py`](https://github.com/bhuvan0611/smartdoc-framework/blob/main/agents/orchestrator.py) (Agent Orchestrator), [`main_pipeline.py`](https://github.com/bhuvan0611/smartdoc-framework/blob/main/main_pipeline.py) (Pipeline Entry), [`synthesis/comment_synthesis_agent.py`](https://github.com/bhuvan0611/smartdoc-framework/blob/main/synthesis/comment_synthesis_agent.py) (Comment Synthesis)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_pipeline["Pipeline"]
  node_entry["Pipeline Entry<br/>[main_pipeline.py]"]
  node_injector["Code Injector<br/>[code_injector.py]"]
end

subgraph group_analysis["Contract Analysis"]
  node_extractor["Artifact Extractor"]
  node_ast["AST Extraction<br/>[ast_extractor.py]"]
  node_cfg["CFG Extraction<br/>[cfg_extractor.py]"]
  node_callgraph["Call Graph Extraction"]
  node_bytecode["Bytecode Extraction"]
  node_opcode["Opcode Extraction"]
  node_orchestrator["Agent Orchestrator<br/>[orchestrator.py]"]
  node_structural["Structural Agent"]
  node_semantic["Semantic Agent<br/>[semantic_agent.py]"]
  node_gas["Gas Agent<br/>[gas_agent.py]"]
  node_security["Security Agent<br/>[security_agent.py]"]
end

subgraph group_generation["Comment Generation"]
  node_synthesis["Comment Synthesis"]
  node_prompt["Prompt Builder<br/>[prompt_builder.py]"]
  node_models["Documentation Models<br/>[data_models.py]"]
end

subgraph group_quality["Validation and Evaluation"]
  node_validator["NatSpec Validator<br/>[validator.py]"]
  node_hallucination["Hallucination Detector"]
  node_evaluation["S³ Evaluation<br/>[s3_evaluator.py]"]
end

node_developer(("Contract Developer"))
node_solidity["Solidity Source"]
node_ollama["Ollama LLM"]
node_annotated["Annotated Solidity"]

node_developer -->|"runs"| node_entry
node_entry -->|"reads"| node_solidity
node_entry -->|"calls"| node_extractor
node_extractor -->|"extracts"| node_ast
node_extractor -->|"extracts"| node_cfg
node_extractor -->|"extracts"| node_callgraph
node_extractor -->|"extracts"| node_bytecode
node_extractor -.->|"extracts"| node_opcode
node_entry -->|"calls"| node_orchestrator
node_orchestrator -->|"dispatches"| node_structural
node_orchestrator -->|"dispatches"| node_semantic
node_orchestrator -->|"dispatches"| node_gas
node_orchestrator -->|"dispatches"| node_security
node_orchestrator -->|"synthesizes"| node_synthesis
node_synthesis -->|"builds prompt"| node_prompt
node_synthesis -->|"uses models"| node_models
node_synthesis -->|"requests completion"| node_ollama
node_synthesis -->|"validates"| node_validator
node_validator -->|"checks claims"| node_hallucination
node_entry -->|"calls"| node_injector
node_injector -->|"consumes results"| node_models
node_injector -->|"produces"| node_annotated
node_annotated -->|"scores quality"| node_evaluation

click node_entry "https://github.com/bhuvan0611/smartdoc-framework/blob/main/main_pipeline.py"
click node_extractor "https://github.com/bhuvan0611/smartdoc-framework/blob/main/extractor/artifact_extractor.py"
click node_ast "https://github.com/bhuvan0611/smartdoc-framework/blob/main/extractor/ast_extractor.py"
click node_cfg "https://github.com/bhuvan0611/smartdoc-framework/blob/main/extractor/cfg_extractor.py"
click node_callgraph "https://github.com/bhuvan0611/smartdoc-framework/blob/main/extractor/callgraph_extractor.py"
click node_bytecode "https://github.com/bhuvan0611/smartdoc-framework/blob/main/extractor/bytecode_extractor.py"
click node_opcode "https://github.com/bhuvan0611/smartdoc-framework/blob/main/extractor/opcode_extractor.py"
click node_orchestrator "https://github.com/bhuvan0611/smartdoc-framework/blob/main/agents/orchestrator.py"
click node_structural "https://github.com/bhuvan0611/smartdoc-framework/blob/main/agents/structural_agent.py"
click node_semantic "https://github.com/bhuvan0611/smartdoc-framework/blob/main/agents/semantic_agent.py"
click node_gas "https://github.com/bhuvan0611/smartdoc-framework/blob/main/agents/gas_agent.py"
click node_security "https://github.com/bhuvan0611/smartdoc-framework/blob/main/agents/security_agent.py"
click node_synthesis "https://github.com/bhuvan0611/smartdoc-framework/blob/main/synthesis/comment_synthesis_agent.py"
click node_prompt "https://github.com/bhuvan0611/smartdoc-framework/blob/main/utils/prompt_builder.py"
click node_models "https://github.com/bhuvan0611/smartdoc-framework/blob/main/utils/data_models.py"
click node_validator "https://github.com/bhuvan0611/smartdoc-framework/blob/main/validation/validator.py"
click node_hallucination "https://github.com/bhuvan0611/smartdoc-framework/blob/main/validation/hallucination_detector.py"
click node_injector "https://github.com/bhuvan0611/smartdoc-framework/blob/main/injection/code_injector.py"
click node_evaluation "https://github.com/bhuvan0611/smartdoc-framework/blob/main/tools/s3_evaluator.py"

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_entry,node_injector toneBlue
class node_extractor,node_ast,node_cfg,node_callgraph,node_bytecode,node_opcode,node_orchestrator,node_structural,node_semantic,node_gas,node_security toneAmber
class node_synthesis,node_prompt,node_models toneMint
class node_validator,node_hallucination,node_evaluation toneRose
class node_developer,node_solidity,node_ollama,node_annotated toneIndigo
```

## Components

### Pipeline

- [Pipeline Entry](https://github.com/bhuvan0611/smartdoc-framework/blob/main/main_pipeline.py): `main_pipeline.py`
- [Code Injector](https://github.com/bhuvan0611/smartdoc-framework/blob/main/injection/code_injector.py): `injection/code_injector.py`

### Contract Analysis

- [Artifact Extractor](https://github.com/bhuvan0611/smartdoc-framework/blob/main/extractor/artifact_extractor.py): `extractor/artifact_extractor.py`
- [AST Extraction](https://github.com/bhuvan0611/smartdoc-framework/blob/main/extractor/ast_extractor.py): `extractor/ast_extractor.py`
- [CFG Extraction](https://github.com/bhuvan0611/smartdoc-framework/blob/main/extractor/cfg_extractor.py): `extractor/cfg_extractor.py`
- [Call Graph Extraction](https://github.com/bhuvan0611/smartdoc-framework/blob/main/extractor/callgraph_extractor.py): `extractor/callgraph_extractor.py`
- [Bytecode Extraction](https://github.com/bhuvan0611/smartdoc-framework/blob/main/extractor/bytecode_extractor.py): `extractor/bytecode_extractor.py`
- [Opcode Extraction](https://github.com/bhuvan0611/smartdoc-framework/blob/main/extractor/opcode_extractor.py): `extractor/opcode_extractor.py`
- [Agent Orchestrator](https://github.com/bhuvan0611/smartdoc-framework/blob/main/agents/orchestrator.py): `agents/orchestrator.py`
- [Structural Agent](https://github.com/bhuvan0611/smartdoc-framework/blob/main/agents/structural_agent.py): `agents/structural_agent.py`
- [Semantic Agent](https://github.com/bhuvan0611/smartdoc-framework/blob/main/agents/semantic_agent.py): `agents/semantic_agent.py`
- [Gas Agent](https://github.com/bhuvan0611/smartdoc-framework/blob/main/agents/gas_agent.py): `agents/gas_agent.py`
- [Security Agent](https://github.com/bhuvan0611/smartdoc-framework/blob/main/agents/security_agent.py): `agents/security_agent.py`

### Comment Generation

- [Comment Synthesis](https://github.com/bhuvan0611/smartdoc-framework/blob/main/synthesis/comment_synthesis_agent.py): `synthesis/comment_synthesis_agent.py`
- [Prompt Builder](https://github.com/bhuvan0611/smartdoc-framework/blob/main/utils/prompt_builder.py): `utils/prompt_builder.py`
- [Documentation Models](https://github.com/bhuvan0611/smartdoc-framework/blob/main/utils/data_models.py): `utils/data_models.py`

### Validation and Evaluation

- [NatSpec Validator](https://github.com/bhuvan0611/smartdoc-framework/blob/main/validation/validator.py): `validation/validator.py`
- [Hallucination Detector](https://github.com/bhuvan0611/smartdoc-framework/blob/main/validation/hallucination_detector.py): `validation/hallucination_detector.py`
- [S³ Evaluation](https://github.com/bhuvan0611/smartdoc-framework/blob/main/tools/s3_evaluator.py): `tools/s3_evaluator.py`

### Other components

- **Contract Developer**
- **Solidity Source**
- **Ollama LLM**
- **Annotated Solidity**

## Connections

- Contract Developer → Pipeline Entry: runs (evidence: `README.md`)
- Pipeline Entry → Solidity Source: reads (evidence: `main_pipeline.py`)
- Pipeline Entry → Artifact Extractor: calls (evidence: `main_pipeline.py`)
- Artifact Extractor → AST Extraction: extracts (evidence: `README.md`)
- Artifact Extractor → CFG Extraction: extracts (evidence: `README.md`)
- Artifact Extractor → Call Graph Extraction: extracts (evidence: `README.md`)
- Artifact Extractor → Bytecode Extraction: extracts (evidence: `README.md`)
- Artifact Extractor → Opcode Extraction: extracts
- Pipeline Entry → Agent Orchestrator: calls (evidence: `main_pipeline.py`)
- Agent Orchestrator → Structural Agent: dispatches (evidence: `README.md`)
- Agent Orchestrator → Semantic Agent: dispatches (evidence: `README.md`)
- Agent Orchestrator → Gas Agent: dispatches (evidence: `README.md`)
- Agent Orchestrator → Security Agent: dispatches (evidence: `README.md`)
- Agent Orchestrator → Comment Synthesis: synthesizes (evidence: `README.md`)
- Comment Synthesis → Prompt Builder: builds prompt (evidence: `synthesis/comment_synthesis_agent.py`)
- Comment Synthesis → Documentation Models: uses models (evidence: `synthesis/comment_synthesis_agent.py`)
- Comment Synthesis → Ollama LLM: requests completion (evidence: `README.md`)
- Comment Synthesis → NatSpec Validator: validates (evidence: `README.md`)
- NatSpec Validator → Hallucination Detector: checks claims (evidence: `README.md`)
- Pipeline Entry → Code Injector: calls (evidence: `main_pipeline.py`)
- Code Injector → Documentation Models: consumes results (evidence: `injection/code_injector.py`)
- Code Injector → Annotated Solidity: produces (evidence: `README.md`)
- Annotated Solidity → S³ Evaluation: scores quality (evidence: `README.md`)
