# fkr-0/cl-fzy architecture

> Architecture diagram of the GitHub repository fkr-0/cl-fzy, 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/fkr-0/cl-fzy
- Repository: https://github.com/fkr-0/cl-fzy

## Overview

##### Main Components

a) Core Components:
- Match Engine (src/match.lisp)
- Choice Management (src/choices.lisp)
- Array Handling (src/arr.lisp)
- TTY Interface (src/tty.lisp, src/tty-interface.lisp)

b) System Integration:
- SBCL Thread Management
- Terminal I/O
- Worker Pool (4 cores mentioned)

**┌─ User Interface Layer ─────────────────┐**
- TTY Interface                          │
- Processing Layer ────────────────────┬┘
- ┌─ Worker Pool ─┐                     │
- Worker 1      │     Choice Manager  │
- Worker 2      │ ←→  (Coordinator)   │
- Worker 3      │                     │
- Worker 4      │                     │
- ┘                      │
- Core Engine Layer ──────────────────┬┘
- Match Engine                         │
- Array Handler                        │
- ┬┘

##### Component Relationships

- Blue: User interface components
- Green: Processing components
- Yellow: Core engine components
- Red: Critical paths and threading boundaries

##### Specific Elements to Highlight

a) Threading Model:
- Worker pool with 4 parallel workers
- SBCL thread management
- Synchronization points

b) Data Flow:
- Input string → Choice Manager
- Choice distribution to workers
- Result aggregation
- Final output to TTY

##### Technical Details

- SBCL dependency for threading
- Array handling for score matrices
- Match algorithm flow
- TTY interaction points

##### Implementation Notes

A side panel with:
- SBCL-specific features
- Threading constraints
- Performance considerations
- Array optimization notes

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph UI["User Interface Layer"]
        TTY["TTY Interface"]:::ui
        CLI["Command Line Interface"]:::ui
    end

    subgraph Processing["Processing Layer"]
        subgraph WP["Worker Pool"]
            W1["Worker 1"]:::worker
            W2["Worker 2"]:::worker
            W3["Worker 3"]:::worker
            W4["Worker 4"]:::worker
        end
        CM["Choice Manager"]:::processing
    end

    subgraph Core["Core Engine Layer"]
        ME["Match Engine"]:::core
        AH["Array Handler"]:::core
        SYS["Main System"]:::core
        PKG["Package Definitions"]:::core
    end

    subgraph Testing["Testing Components"]
        TS["Test Suite"]:::testing
        TD["Test Definitions"]:::testing
    end

    %% Relationships
    TTY --> CM
    CLI --> TTY
    CM --> W1
    CM --> W2
    CM --> W3
    CM --> W4
    W1 --> ME
    W2 --> ME
    W3 --> ME
    W4 --> ME
    ME --> AH
    ME --> SYS
    SYS --> PKG
    TS --> TD

    %% Click Events
    click ME "https://github.com/fkr-0/cl-fzy/blob/main/src/match.lisp"
    click CM "https://github.com/fkr-0/cl-fzy/blob/main/src/choices.lisp"
    click AH "https://github.com/fkr-0/cl-fzy/blob/main/src/arr.lisp"
    click TTY "https://github.com/fkr-0/cl-fzy/blob/main/src/tty.lisp"
    click SYS "https://github.com/fkr-0/cl-fzy/blob/main/src/cl-fzy.lisp"
    click PKG "https://github.com/fkr-0/cl-fzy/blob/main/src/packages.lisp"
    click TS "https://github.com/fkr-0/cl-fzy/tree/main/tests"
    click TD "https://github.com/fkr-0/cl-fzy/blob/main/cl-fzy-tests.asd"
    click CLI "https://github.com/fkr-0/cl-fzy/blob/main/roswell/cl-fzy.ros"

    %% Styles
    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef worker fill:#2ecc71,stroke:#27ae60,color:white
    classDef processing fill:#e74c3c,stroke:#c0392b,color:white
    classDef core fill:#f1c40f,stroke:#f39c12,color:black
    classDef testing fill:#9b59b6,stroke:#8e44ad,color:white

    %% Legend
    subgraph Legend
        L1["UI Components"]:::ui
        L2["Worker Threads"]:::worker
        L3["Processing Components"]:::processing
        L4["Core Components"]:::core
        L5["Testing Components"]:::testing
    end
```
