# hirosystems/clarinet architecture

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

- Interactive diagram: https://gitdiagram.com/hirosystems/clarinet
- Repository: https://github.com/hirosystems/clarinet

## Overview

##### Main System Components

- Clarinet CLI (`clarinet-cli`)
- Clarity REPL (`clarity-repl`)
- SDK Components (`clarinet-sdk`)
- LSP Support (`clarity-lsp`)
- Network Components (`stacks-network`)

- Deployment Manager (`clarinet-deployments`)
- File System Handler (`clarinet-files`)
- Utilities (`clarinet-utils`)
- Event System (`clarity-events`)

##### Architectural Layers

**User Interface Layer:**
- CLI Interface
- VS Code Extension
- Jupyter Kernel Interface

**Core Processing Layer:**
- REPL Engine
- Contract Analysis Tools
- Deployment Manager
- Debug Adapter

**Infrastructure Layer:**
- Network Interfaces (Devnet/Testnet/Mainnet)
- File System
- Event System

##### Integration Points
Interactions with external systems:

a) Development Environment:
- VS Code Integration
- Docker Container System
- Local Development Network

b) Blockchain Networks:
- Stacks Network
- Bitcoin Network
- Hyperchain Support

##### Data Flow Patterns

a) Contract Development Flow:
**Developer Tools → Contract Analysis → Testing → Deployment**

b) Debug Flow:
**VS Code/CLI → Debug Adapter → REPL Engine → Contract Execution**

##### Key Features to Highlight

Create specific sections showing:

a) Testing Infrastructure:
- Test Runner
- Coverage Analysis
- Check Checker System

b) Development Tools:
- Contract Templates
- Project Generation
- Deployment Planning

##### Component Relationships

Clear relationships between:

a) Internal Components:
- CLI → REPL
- REPL → Network
- SDK → Deployment Manager

b) External Systems:
- VS Code Extension → LSP
- Clarinet → Blockchain Networks
- Developer Tools → CI/CD Systems

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef core fill:#2374ab
    classDef interface fill:#45b7d1
    classDef infrastructure fill:#48a14d
    classDef tools fill:#f4a259
    classDef security fill:#e4572e
    classDef storage fill:#17bebb
    
    %% User Interface Layer
    subgraph UI
        CLI[Clarinet CLI]:::interface
        VSC[VS Code Extension]:::interface
        JKI[Jupyter Kernel Interface]:::interface
    end

    %% Core Processing Layer
    subgraph Core
        REPL[Clarity REPL]:::core
        SDK[SDK Components]:::core
        LSP[LSP Support]:::core
        DAP[Debug Adapter]:::core
        DM[Deployment Manager]:::core
    end

    %% Infrastructure Layer
    subgraph Infrastructure
        NET[Network Components]:::infrastructure
        FS[File System Handler]:::infrastructure
        EVT[Event System]:::infrastructure
        UTILS[Utilities]:::infrastructure
    end

    %% Development Tools
    subgraph DevTools
        TPL[Contract Templates]:::tools
        PG[Project Generator]:::tools
        DP[Deployment Planner]:::tools
    end

    %% Security Features
    subgraph Security
        SA[Static Analysis]:::security
        CC[Check Checker]:::security
        CV[Contract Verification]:::security
    end

    %% External Systems
    subgraph Networks
        DN[Devnet]:::infrastructure
        TN[Testnet]:::infrastructure
        MN[Mainnet]:::infrastructure
    end

    %% Relationships
    CLI --> REPL
    CLI --> SDK
    CLI --> DAP
    VSC --> LSP
    JKI --> REPL
    REPL --> NET
    SDK --> DM
    DM --> NET
    LSP --> REPL
    DAP --> REPL
    NET --> DN
    NET --> TN
    NET --> MN
    DM --> FS
    REPL --> EVT
    SDK --> UTILS

    %% Component Click Events
    click CLI "https://github.com/hirosystems/clarinet/tree/main/components/clarinet-cli/"
    click REPL "https://github.com/hirosystems/clarinet/tree/main/components/clarity-repl/"
    click SDK "https://github.com/hirosystems/clarinet/tree/main/components/clarinet-sdk/"
    click LSP "https://github.com/hirosystems/clarinet/tree/main/components/clarity-lsp/"
    click NET "https://github.com/hirosystems/clarinet/tree/main/components/stacks-network/"
    click DM "https://github.com/hirosystems/clarinet/tree/main/components/clarinet-deployments/"
    click FS "https://github.com/hirosystems/clarinet/tree/main/components/clarinet-files/"
    click UTILS "https://github.com/hirosystems/clarinet/tree/main/components/clarinet-utils/"
    click EVT "https://github.com/hirosystems/clarinet/tree/main/components/clarity-events/"
    click VSC "https://github.com/hirosystems/clarinet/tree/main/components/clarity-vscode/"
    click JKI "https://github.com/hirosystems/clarinet/tree/main/components/clarity-jupyter-kernel/"
    click DAP "https://github.com/hirosystems/clarinet/blob/main/components/clarinet-cli/src/frontend/dap.rs"

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Interfaces]:::interface
        L3[Infrastructure]:::infrastructure
        L4[Development Tools]:::tools
        L5[Security Features]:::security
    end
```
