# withhaibun/haibun architecture

> Architecture diagram of the GitHub repository withhaibun/haibun, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/withhaibun/haibun
- Repository: https://github.com/withhaibun/haibun

## Overview

##### Main Components

a) Three-Layer Architecture:
- BDD Layer (Feature Specifications)
- Domain Layer (Abstract Representations)
- Implementation Layer (Concrete Testers)

b) Core Module Components:
- CLI Module (Entry point)
- Core Engine
- Context Management
- Multiple Domain Modules
- Storage Systems
- Output Handlers

**[Feature Specifications Layer]**
- ↓
**[Domain Abstraction Layer]**
- ↓
**[Implementation Layer]**

##### Component Relationships

a) Core Components:
**[CLI Module] → [Core Engine] → [Context Manager]**
- ↓
- [Builder → Resolver → Executor]

b) Domain Implementations:
**[Domain Modules]**
- Webpage Domain
- Storage Domain
- HTTP Domain
- Express Server
- Playwright Integration

##### Specific Implementation Details

Key architectural components:
- Feature Parser (parse-md module)
- Storage Implementations (storage-fs, storage-mem)
- Web Testing (web-playwright, web-http)
- Output Handlers (out-review, out-xunit)

##### Data Flow Indicators

How data flows through the system:
**[Feature Files] → [Parser] → [Builder] → [Resolver] → [Executor] → [Output Handlers]**

##### Important Architectural Notes

- Modular nature with clear boundaries between components
- Extension points for new domains and implementations
- Configuration flow from CLI to execution
- Logging and monitoring paths

##### Key Relationships to Highlight

- How domains interact with the core engine
- Storage abstraction implementation
- Test execution flow
- Output generation paths

This architecture should emphasize Haibun's focus on reusability, environment abstraction, and specification-driven development while showing how the various modules work together to provide a complete testing solution.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph "BDD Layer"
        FS[Feature Specifications]
        FP["Feature Parser"]:::parser
    end

    subgraph "Domain Layer"
        DI["Domain Interfaces"]:::domain
        CM["Context Manager"]:::core
        CE["Core Engine"]:::core
        
        subgraph "Core Pipeline"
            B["Builder"]:::core
            R["Resolver"]:::core
            E["Executor"]:::core
        end
        
        CL["Core Logger"]:::util
        CLI["CLI Module"]:::core
    end

    subgraph "Implementation Layer"
        subgraph "Domain Modules"
            WD["Webpage Domain"]:::domain
            SD["Storage Domain"]:::domain
        end

        subgraph "Web Testing"
            PW["Playwright Integration"]:::impl
            HT["HTTP Testing"]:::impl
            ES["Express Server"]:::impl
        end

        subgraph "Storage Implementations"
            FSS["File System Storage"]:::impl
            MS["Memory Storage"]:::impl
        end

        subgraph "Output Handlers"
            RO["Review Output"]:::output
            XO["XUnit Output"]:::output
        end
    end

    FS --> FP
    FP --> CE
    CLI --> CE
    CE --> CM
    CE --> B
    B --> R
    R --> E
    E --> RO
    E --> XO
    CM --> DI
    DI --> WD
    DI --> SD
    WD --> PW
    WD --> HT
    HT --> ES
    SD --> FSS
    SD --> MS
    CL --> CE

    %% Click events for component mapping
    click CLI "https://github.com/withhaibun/haibun/tree/main/modules/cli"
    click CE "https://github.com/withhaibun/haibun/tree/main/modules/core"
    click CM "https://github.com/withhaibun/haibun/tree/main/modules/context"
    click B "https://github.com/withhaibun/haibun/tree/main/modules/core/src/phases"
    click R "https://github.com/withhaibun/haibun/tree/main/modules/core/src/phases"
    click E "https://github.com/withhaibun/haibun/tree/main/modules/core/src/phases"
    click FP "https://github.com/withhaibun/haibun/tree/main/modules/parse-md"
    click WD "https://github.com/withhaibun/haibun/tree/main/modules/domain-webpage"
    click SD "https://github.com/withhaibun/haibun/tree/main/modules/domain-storage"
    click PW "https://github.com/withhaibun/haibun/tree/main/modules/web-playwright"
    click HT "https://github.com/withhaibun/haibun/tree/main/modules/web-http"
    click ES "https://github.com/withhaibun/haibun/tree/main/modules/web-server-express"
    click RO "https://github.com/withhaibun/haibun/tree/main/modules/out-review"
    click XO "https://github.com/withhaibun/haibun/tree/main/modules/out-xunit"
    click FSS "https://github.com/withhaibun/haibun/tree/main/modules/storage-fs"
    click MS "https://github.com/withhaibun/haibun/tree/main/modules/storage-mem"
    click CL "https://github.com/withhaibun/haibun/blob/main/modules/core/src/lib/Logger.ts"
    click DI "https://github.com/withhaibun/haibun/tree/main/modules/core/src/lib/interfaces"

    %% Styling
    classDef core fill:#a8d1f0
    classDef domain fill:#90EE90
    classDef impl fill:#FFE5B4
    classDef output fill:#DDA0DD
    classDef util fill:#D3D3D3
    classDef parser fill:#FFB6C1

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Domain Components"]:::domain
        L3["Implementations"]:::impl
        L4["Output Handlers"]:::output
        L5["Utilities"]:::util
        L6["Parsers"]:::parser
    end
```
