# ckoshka/langwitch-deno architecture

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

- Interactive diagram: https://gitdiagram.com/ckoshka/langwitch-deno
- Repository: https://github.com/ckoshka/langwitch-deno

## Overview

##### Core Architecture Layer
- "langwitch-core" at the center, containing:
- Control Flow Module (handling graduation, feedback, refresh)
- Core Memory System
- Implementation Parameters

##### Plugin System Layer
- Plugins in a circular pattern around the core, including:
- Backend Plugins (Mixed, Pure TypeScript, Rust)
- State Transformers
- Preprocessing Plugins
- Rendering Plugins
- Translation Plugins
- Vocabulary Estimation

##### Effects System Layer
- "langwitch-shared-types" as a separate layer showing:
- Filter Effects
- Query Effects
- State Effects

##### External Services Layer
- External APIs and services:
- TTS Services
- Translation APIs
- Phonemization Services

##### Data Flow Layer
- Flow of:
- Sentence Data
- User Input
- Learning Statistics
- Configuration

Specific Design Elements:

##### Component Relationships
- Plugin dependencies with thin lines

##### Abstraction Levels
- Level 1: Core System
- Level 2: Plugin Architecture
- Level 3: Effects System
- Level 4: External Services

##### Important Notes
- Notes about the polymorphic effect system
- Free monad architecture
- Configuration system's flexibility

Special Considerations:

##### Declarative plugin architecture
- How plugins can be substituted
- Configuration points
- Demonstrate the effect system's flow

##### Performance Aspects
- Notes about the fast boot time
- Parallel processing capabilities
- Where optimization occurs

##### Data Processing
- How the system handles large datasets
- Where sentence processing occurs
- Caching and optimization points

Remember to:
- Keep the core architecture clear and central
- Plugin system's extensibility
- Demonstrate the effect system's role
- Performance-critical paths
- Configuration points
- Data flow directions

## Diagram (Mermaid)

```mermaid
graph TB
    %% Core Architecture Layer
    subgraph Core
        CoreArch{{"langwitch-core"}}
        ControlFlow["Control Flow Module"]
        Memory["Core Memory System"]
        ImplParams["Implementation Parameters"]
        
        CoreArch --> ControlFlow
        CoreArch --> Memory
        CoreArch --> ImplParams
    end
    
    %% Plugin System Layer
    subgraph Plugins
        Backend["Backend Plugins"]
        StateTransform["State Transformers"]
        Preprocess["Preprocessing Plugins"]
        Render["Rendering Plugins"]
        Translate["Translation Plugins"]
        VocabEst["Vocabulary Estimation"]
    end
    
    %% Effects System Layer
    subgraph Effects
        FilterEff["Filter Effects"]
        QueryEff["Query Effects"]
        StateEff["State Effects"]
    end
    
    %% External Services Layer
    subgraph External
        TTS["TTS Services"]
        TransAPI["Translation APIs"]
        Phoneme["Phonemization Services"]
    end
    
    %% Relationships
    CoreArch -.-> Backend
    CoreArch -.-> StateTransform
    CoreArch -.-> Preprocess
    CoreArch -.-> Render
    CoreArch -.-> Translate
    CoreArch -.-> VocabEst
    
    Backend <--> FilterEff
    Backend <--> QueryEff
    Backend <--> StateEff
    
    Translate --> TransAPI
    Render --> TTS
    Preprocess --> Phoneme
    
    %% Click Events
    click ControlFlow "https://github.com/ckoshka/langwitch-deno/tree/master/langwitch-core/core/internal/control_flow/"
    click Memory "https://github.com/ckoshka/langwitch-deno/blob/master/langwitch-core/core/internal/core/memory.ts"
    click ImplParams "https://github.com/ckoshka/langwitch-deno/blob/master/langwitch-core/core/internal/impl_params.ts"
    click Backend "https://github.com/ckoshka/langwitch-deno/tree/master/plugins/backends/"
    click StateTransform "https://github.com/ckoshka/langwitch-deno/tree/master/plugins/state-transformers/"
    click Preprocess "https://github.com/ckoshka/langwitch-deno/tree/master/plugins/preprocessing/"
    click Render "https://github.com/ckoshka/langwitch-deno/tree/master/plugins/rendering-plugins/"
    click Translate "https://github.com/ckoshka/langwitch-deno/tree/master/plugins/translator/"
    click VocabEst "https://github.com/ckoshka/langwitch-deno/tree/master/plugins/vocabulary-estimation/"
    click FilterEff "https://github.com/ckoshka/langwitch-deno/blob/master/langwitch-shared-types/effects/filter_effect.ts"
    click QueryEff "https://github.com/ckoshka/langwitch-deno/blob/master/langwitch-shared-types/effects/query_effects.ts"
    click StateEff "https://github.com/ckoshka/langwitch-deno/blob/master/langwitch-shared-types/effects/state_effects.ts"
    click TTS "https://github.com/ckoshka/langwitch-deno/blob/master/plugins/external-apis/clients/tts.ts"
    click TransAPI "https://github.com/ckoshka/langwitch-deno/tree/master/plugins/external-apis/clients/"
    click Phoneme "https://github.com/ckoshka/langwitch-deno/blob/master/plugins/external-apis/clients/phonemize.ts"
    
    %% Styling
    classDef core fill:#2b4b6b,stroke:#1a2d40,color:#fff
    classDef plugin fill:#2d5a27,stroke:#1a361a,color:#fff
    classDef effect fill:#4a235a,stroke:#2e163a,color:#fff
    classDef external fill:#566573,stroke:#2c3e50,color:#fff
    
    class CoreArch,ControlFlow,Memory,ImplParams core
    class Backend,StateTransform,Preprocess,Render,Translate,VocabEst plugin
    class FilterEff,QueryEff,StateEff effect
    class TTS,TransAPI,Phoneme external
    
    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Plugins]:::plugin
        L3[Effects]:::effect
        L4[External Services]:::external
    end
```
