# jonsequitur/dotnet-repl architecture

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

- Interactive diagram: https://gitdiagram.com/jonsequitur/dotnet-repl
- Repository: https://github.com/jonsequitur/dotnet-repl

## Overview

##### Main Components

a. Core REPL Engine Layer:
- Input Kernel (InputKernel.cs)
- Command Parser (CommandLineParser.cs)
- REPL Execution Engine (Repl.cs)
- Kernel Builder (KernelBuilder.cs)

b. Language Support Layer:
- C# Kernel
- F# Kernel
- Markdown Kernel

c. Input/Output Processing:
- Line Editor Commands (LineEditorCommands/)
- Document Parser (DocumentParser.cs)
- Document Converter (DocumentConverter.cs)
- Console Output Formatting (SpectreFormatter.cs)

d. Automation & File Handling:
- Notebook Runner (Automation/NotebookRunner.cs)
- File Import/Export capabilities
- Supported file formats (.ipynb, .dib, .cs, .fsx, etc.)

##### Interaction Flows

- User Input → Command Parser → REPL Core
- REPL Core → Language Kernels → Execution
- Execution Results → Output Formatting → Console Display
- File Import → Notebook Runner → REPL Core

##### External Dependencies
- .NET Interactive
- Spectre.Console
- NuGet Package Management

##### Additional Details

Small annotations showing:
- Support for multi-line input
- Magic commands (#! syntax)
- NuGet package integration
- Session state management
- Keyboard shortcut handling

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Core["Core REPL Engine Layer"]
        IK["Input Kernel"]
        CP["Command Parser"]
        RE["REPL Execution Engine"]
        KB["Kernel Builder"]
    end

    subgraph Lang["Language Support Layer"]
        CK["C# Kernel"]
        FK["F# Kernel"]
        MK["Markdown Kernel"]
    end

    subgraph IO["Input/Output Processing"]
        LE["Line Editor Commands"]
        DP["Document Parser"]
        DC["Document Converter"]
        SF["Console Output Formatter"]
        WH["Word Highlighter"]
    end

    subgraph Auto["Automation & File Handling"]
        NR["Notebook Runner"]
        FF["File Formats"]
    end

    subgraph Config["Configuration & Setup"]
        SO["Startup Options"]
        KBind["Key Bindings"]
        KC["Kernel Completion"]
    end

    subgraph Ext["External Dependencies"]
        NI[".NET Interactive"]
        SC["Spectre.Console"]
        NG["NuGet Package Management"]
    end

    subgraph Cmd["Command Implementation"]
        CC["Clear Command"]
        CoC["Completion Command"]
        QC["Quit Command"]
    end

    %% Core connections
    IK <--> CP
    CP <--> RE
    RE <--> KB

    %% Language connections
    KB --> Lang
    Lang --> RE

    %% IO connections
    LE --> RE
    DP --> RE
    DC --> RE
    SF --> RE
    WH --> RE

    %% Automation connections
    NR --> RE
    FF --> NR

    %% Config connections
    SO --> RE
    KBind --> RE
    KC --> RE

    %% Command connections
    Cmd --> LE

    %% External dependency connections
    NI --> RE
    SC --> SF
    NG --> RE

    %% Click events
    click IK "https://github.com/jonsequitur/dotnet-repl/blob/main/src/dotnet-repl/InputKernel.cs"
    click CP "https://github.com/jonsequitur/dotnet-repl/blob/main/src/dotnet-repl/CommandLineParser.cs"
    click RE "https://github.com/jonsequitur/dotnet-repl/blob/main/src/dotnet-repl/Repl.cs"
    click KB "https://github.com/jonsequitur/dotnet-repl/blob/main/src/dotnet-repl/KernelBuilder.cs"
    click MK "https://github.com/jonsequitur/dotnet-repl/blob/main/src/dotnet-repl/MarkdownKernel.cs"
    click LE "https://github.com/jonsequitur/dotnet-repl/tree/main/src/dotnet-repl/LineEditorCommands/"
    click DP "https://github.com/jonsequitur/dotnet-repl/blob/main/src/dotnet-repl/DocumentParser.cs"
    click DC "https://github.com/jonsequitur/dotnet-repl/blob/main/src/dotnet-repl/DocumentConverter.cs"
    click SF "https://github.com/jonsequitur/dotnet-repl/blob/main/src/dotnet-repl/SpectreFormatter.cs"
    click WH "https://github.com/jonsequitur/dotnet-repl/blob/main/src/dotnet-repl/ReplWordHighlighter.cs"
    click NR "https://github.com/jonsequitur/dotnet-repl/blob/main/src/dotnet-repl/Automation/NotebookRunner.cs"
    click SO "https://github.com/jonsequitur/dotnet-repl/blob/main/src/dotnet-repl/StartupOptions.cs"
    click KBind "https://github.com/jonsequitur/dotnet-repl/blob/main/src/dotnet-repl/KeyBindings.cs"
    click KC "https://github.com/jonsequitur/dotnet-repl/blob/main/src/dotnet-repl/KernelCompletion.cs"
    click CC "https://github.com/jonsequitur/dotnet-repl/blob/main/src/dotnet-repl/LineEditorCommands/Clear.cs"
    click CoC "https://github.com/jonsequitur/dotnet-repl/blob/main/src/dotnet-repl/LineEditorCommands/CompletionCommand.cs"
    click QC "https://github.com/jonsequitur/dotnet-repl/blob/main/src/dotnet-repl/LineEditorCommands/Quit.cs"

    classDef core fill:#b3e0ff,stroke:#333,stroke-width:2px
    classDef lang fill:#98fb98,stroke:#333,stroke-width:2px
    classDef io fill:#fff59d,stroke:#333,stroke-width:2px
    classDef auto fill:#ffcc80,stroke:#333,stroke-width:2px
    classDef config fill:#ce93d8,stroke:#333,stroke-width:2px
    classDef ext fill:#bdbdbd,stroke:#333,stroke-width:2px
    classDef cmd fill:#ef9a9a,stroke:#333,stroke-width:2px

    class IK,CP,RE,KB core
    class CK,FK,MK lang
    class LE,DP,DC,SF,WH io
    class NR,FF auto
    class SO,KBind,KC config
    class NI,SC,NG ext
    class CC,CoC,QC cmd
```
