# tomeraberbach/typespec-fast-check architecture

> Architecture diagram of the GitHub repository tomeraberbach/typespec-fast-check, 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/tomeraberbach/typespec-fast-check
- Repository: https://github.com/tomeraberbach/typespec-fast-check

## Overview

##### Component Relationships

Key interactions:
**TypeSpec Input → Normalizer → Type System → Dependency Graph → Converter → Emitter → Generated Output**

##### Important Subsystems to Highlight

Create grouped sections for:
a) Type Processing:
- Numeric handling (`src/numerics.ts`)
- Arbitrary generation (`src/arbitrary.ts`)
- Type conversion (`src/convert.ts`)

b) Testing Infrastructure:
- Test helpers (`src/testing`)
- Snapshot testing system

##### Additional Details

Supporting elements:
- Configuration flow from compiler options
- Integration points with TypeSpec compiler
- Test feedback loop
- Sample generation pipeline

##### Testing and validation mechanisms

Key Considerations:
- Keep the main transformation flow clear and central
- How different types (from test/snapshots) are handled
- Where configuration can affect the pipeline
- Demonstrate the relationship between source types and generated arbitraries

- Component types
- Main file types

Level of Detail:
- Main components should be immediately visible
- Subsystems should be collapsible/expandable
- File references without overwhelming detail
- Major data flow paths clearly

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Input
        TS[TypeSpec Source Files]
        CO[Compiler Options]
        MAIN["Main TypeSpec Definition"]
    end

    subgraph "Processing Layer"
        direction TB
        PN["Parser/Normalizer"]
        TSC["Type System Components"]
        DR["Dependency Resolution"]
        CL["Conversion Logic"]
        ES["Emission System"]
    end

    subgraph "Type Processing"
        direction TB
        NH["Numeric Handling"]
        AG["Arbitrary Generation"]
        TC["Type Conversion"]
    end

    subgraph "Testing Infrastructure"
        direction TB
        TH["Test Helpers"]
        ST["Snapshot Testing"]
        MT["Main Tests"]
    end

    subgraph Output
        GAR["Generated Arbitraries"]
        JSO["JavaScript Output"]
        EX["Example Implementation"]
    end

    %% Main Flow
    TS --> PN
    CO -.-> PN
    MAIN --> PN
    PN --> TSC
    TSC --> DR
    DR --> CL
    CL --> ES
    ES --> GAR
    ES --> JSO

    %% Type Processing Integration
    CL <--> NH
    CL <--> AG
    CL <--> TC

    %% Testing Flow
    TH --> ST
    ST --> MT
    MT -.-> GAR
    
    %% Example Usage
    GAR --> EX

    %% Component Mappings
    click PN "https://github.com/TomerAberbach/typespec-fast-check/blob/main/src/normalize.ts"
    click TSC "https://github.com/TomerAberbach/typespec-fast-check/blob/main/src/components.ts"
    click DR "https://github.com/TomerAberbach/typespec-fast-check/blob/main/src/dependency-graph.ts"
    click CL "https://github.com/TomerAberbach/typespec-fast-check/blob/main/src/convert.ts"
    click ES "https://github.com/TomerAberbach/typespec-fast-check/blob/main/src/emitter.ts"
    click NH "https://github.com/TomerAberbach/typespec-fast-check/blob/main/src/numerics.ts"
    click AG "https://github.com/TomerAberbach/typespec-fast-check/blob/main/src/arbitrary.ts"
    click TC "https://github.com/TomerAberbach/typespec-fast-check/blob/main/src/convert.ts"
    click TH "https://github.com/TomerAberbach/typespec-fast-check/blob/main/src/testing/index.ts"
    click ST "https://github.com/TomerAberbach/typespec-fast-check/tree/main/test/snapshots"
    click MT "https://github.com/TomerAberbach/typespec-fast-check/blob/main/test/index.ts"
    click EX "https://github.com/TomerAberbach/typespec-fast-check/blob/main/examples/openai-arbitraries.js"
    click MAIN "https://github.com/TomerAberbach/typespec-fast-check/blob/main/lib/main.tsp"

    classDef input fill:#a8d1ff,stroke:#333,stroke-width:2px
    classDef process fill:#90EE90,stroke:#333,stroke-width:2px
    classDef output fill:#FFB347,stroke:#333,stroke-width:2px
    classDef testing fill:#E6E6FA,stroke:#333,stroke-width:2px

    class TS,CO,MAIN input
    class PN,TSC,DR,CL,ES,NH,AG,TC process
    class GAR,JSO,EX output
    class TH,ST,MT testing
```
