# byexamples/byexample architecture

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

- Interactive diagram: https://gitdiagram.com/byexamples/byexample
- Repository: https://github.com/byexamples/byexample

## Overview

##### Main Components

a) Core Engine Components:
- Parser System
- Finder System
- Executor System
- Runner System
- Extension System

b) Language Support Modules
- Multiple Language Interpreters
- Language-specific Parsers

c) Input/Output Systems
- Documentation Reader
- Output Differ
- Report Generator

##### Component Relationships

**Top Level:**
**[Documentation Files] → [byexample Core] → [Test Results]**

**Detailed Core Layer:**
**[Finder System] → [Parser System] → [Executor System] → [Runner System]**
- ↑
- [Extension System]
- ↓
- [Language Support Modules]

##### Specific Implementation Details

- Rectangles: Core components (blue)
- Rounded rectangles: Language modules (green)
- Hexagons: Extension points (orange)

##### Key Flows to Highlight

a) Primary Flow:
1. Documentation Input → Finder System
2. Finder → Parser
3. Parser → Executor
4. Executor → Language-specific Runner
5. Runner → Output Comparison
6. Output Comparison → Test Results

b) Extension Flow:
- How the Extension System interfaces with each core component
- Demonstrate language module integration points

##### Important Architectural Elements

- Modular nature of the language support system
- Extension points for adding new languages
- Concurrent execution capabilities
- Configuration and options system

##### Implementation Notes

- The plugin architecture for language support
- The event-driven nature of the execution system
- The separation between finding examples and executing them
- The extension mechanism for adding new features

##### Technical Details

- Support for multiple input formats (Markdown, text files)
- Language interpreter integration points
- Configuration options flow
- Test execution pipeline

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Input
        DocFiles[Documentation Files]:::input
    end

    subgraph "Core Engine"
        CoreEngine["Core Engine"]:::core
        click CoreEngine "https://github.com/byexamples/byexample/blob/master/byexample/byexample.py"
        
        Config["Configuration System"]:::core
        click Config "https://github.com/byexamples/byexample/blob/master/byexample/cfg.py"
        
        Options["Options Handler"]:::core
        click Options "https://github.com/byexamples/byexample/blob/master/byexample/options.py"
        
        Concurrency["Concurrency Handler"]:::core
        click Concurrency "https://github.com/byexamples/byexample/blob/master/byexample/concurrency.py"
    end

    subgraph "Processing Pipeline"
        Finder["Finder System"]:::processor
        click Finder "https://github.com/byexamples/byexample/blob/master/byexample/finder.py"
        
        Parser["Parser System"]:::processor
        click Parser "https://github.com/byexamples/byexample/blob/master/byexample/parser.py"
        
        Example["Example Handler"]:::processor
        click Example "https://github.com/byexamples/byexample/blob/master/byexample/example.py"
        
        Executor["Executor System"]:::processor
        click Executor "https://github.com/byexamples/byexample/blob/master/byexample/executor.py"
        
        Runner["Runner System"]:::processor
        click Runner "https://github.com/byexamples/byexample/blob/master/byexample/runner.py"
    end

    subgraph "Extension Layer"
        ExtSystem["Extension System"]:::extension
        click ExtSystem "https://github.com/byexamples/byexample/blob/master/byexample/extension.py"
    end

    subgraph "Language Support"
        direction TB
        LangModules["Language Modules"]:::lang
        click LangModules "https://github.com/byexamples/byexample/tree/master/byexample/modules/"
        Python["Python"]:::lang
        click Python "https://github.com/byexamples/byexample/blob/master/byexample/modules/python.py"
        Ruby["Ruby"]:::lang
        click Ruby "https://github.com/byexamples/byexample/blob/master/byexample/modules/ruby.py"
        Java["Java"]:::lang
        click Java "https://github.com/byexamples/byexample/blob/master/byexample/modules/java.py"
        JavaScript["JavaScript"]:::lang
        click JavaScript "https://github.com/byexamples/byexample/blob/master/byexample/modules/javascript.py"
        Shell["Shell"]:::lang
        click Shell "https://github.com/byexamples/byexample/blob/master/byexample/modules/shell.py"
        PHP["PHP"]:::lang
        click PHP "https://github.com/byexamples/byexample/blob/master/byexample/modules/php.py"
        Go["Go"]:::lang
        click Go "https://github.com/byexamples/byexample/blob/master/byexample/modules/go.py"
        Rust["Rust"]:::lang
        click Rust "https://github.com/byexamples/byexample/blob/master/byexample/modules/rust.py"
    end

    subgraph "Output Processing"
        Differ["Output Differ"]:::output
        click Differ "https://github.com/byexamples/byexample/blob/master/byexample/differ.py"
        TestResults["Test Results"]:::output
    end

    %% Connections
    DocFiles --> CoreEngine
    CoreEngine --> |Configuration| Config
    CoreEngine --> |Options| Options
    CoreEngine --> |Concurrency| Concurrency
    
    CoreEngine --> Finder
    Finder --> Parser
    Parser --> Example
    Example --> Executor
    Executor --> Runner
    Runner --> Differ
    Differ --> TestResults

    ExtSystem --> Parser
    ExtSystem --> Executor
    ExtSystem --> Runner
    
    LangModules --> Python & Ruby & Java & JavaScript & Shell & PHP & Go & Rust
    LangModules --> Runner

    %% Styles
    classDef core fill:#2374ab,stroke:#2374ab,color:#fff
    classDef processor fill:#048ba8,stroke:#048ba8,color:#fff
    classDef extension fill:#f18f01,stroke:#f18f01,color:#fff
    classDef lang fill:#2a9d8f,stroke:#2a9d8f,color:#fff
    classDef output fill:#6c757d,stroke:#6c757d,color:#fff
    classDef input fill:#99c24d,stroke:#99c24d,color:#fff

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Processors]:::processor
        L3[Extension System]:::extension
        L4[Language Support]:::lang
        L5[Input/Output]:::input
        L6[Results]:::output
    end
```
