# wsoft-ws/losetta architecture

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

- Interactive diagram: https://gitdiagram.com/wsoft-ws/losetta
- Repository: https://github.com/wsoft-ws/losetta

## Overview

##### Project Type and Purpose
- Losetta is a scripting engine that conforms to the SAIM implementation of AliceScript. It allows developers to both embed and execute scripts in a CLR environment.
- The README outlines important features such as syntax inspired by multiple languages (C#, JavaScript, Python) and the ability to invoke its functionality from CLI tools (as seen in the “alice” project) or directly from C# via its API.

##### Analysis of the File Structure and Key Components
- Top-Level Organization:
- Losetta: Contains the core language engine, including script parsing, function execution, object models, exception handling, and package management.
- Losetta.Runtime: Offers a rich API implementation providing I/O, diagnostic, interoperability, and threading support (with many Alice.* modules). This acts as the runtime backbone for executing and managing scripts.
- Losetta.Bench: Likely contains benchmark or performance testing tools to gauge engine performance.
- Losetta.Test: Houses unit tests which confirm correct behavior of the scripting engine.
- alice: This directory contains the CLI version of the scripting tool, including a command-line interface (shell), help resources, and related property files.
- Additional folders such as Binding, Functions, Interop, Parsing, PreProcessing, and Packaging within the Losetta directory detail a modular breakdown:
- Binding – Handles conversion or “binding” between CLR functions and the scripting environment.
- Functions – Contains the implementation of built-in functions and function creators that the script can execute.
- Parsing – Implements the parser to interpret AliceScript code.
- PreProcessing – Deals with preprocessor directives for customizing syntax.
- Packaging – Manages the packaging/unpacking of script modules.

- Every component is clearly labeled.
- Be very detailed—capture every major folder or component from the file tree. Avoid oversimplification: listing the numerous subcomponents (like each Alice.* file in Losetta.Runtime) helps convey the level of modularity and the responsibilities spread across the system.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interfaces Layer
    subgraph "User Interfaces"
        CLI["CLI (alice)"]:::ui
        API["C# API Caller"]:::ui
    end

    %% Scripting Engine Core Layer
    subgraph "Scripting Engine Core"
        Engine["Scripting Engine Core"]:::engine
        Parser["Parser (Parsing)"]:::module
        PreProc["PreProcessor (PreProcessing)"]:::module
        Func["Functions (Functions)"]:::module
        Bind["Binding (Binding)"]:::module
        ObjEx["Objects/Exception Handling"]:::module
        Pack["Packaging (Packaging)"]:::module
    end

    %% Runtime Support Layer
    subgraph "Runtime Support"
        Runtime["Losetta.Runtime"]:::runtime
    end

    %% Benchmarking & Testing Layer
    subgraph "Benchmarking & Testing"
        Bench["Benchmarking Tools (Losetta.Bench)"]:::bench
        Test["Testing Framework (Losetta.Test)"]:::bench
    end

    %% Connections between layers
    CLI -->|"sendsCommands"| Engine
    API -->|"invokesAPI"| Engine
    Engine -->|"invokes"| Parser
    Engine -->|"invokes"| PreProc
    Engine -->|"invokes"| Func
    Engine -->|"invokes"| Bind
    Engine -->|"invokes"| ObjEx
    Engine -->|"invokes"| Pack
    Engine -->|"delegatesTasks"| Runtime
    Engine -->|"qualityCheck"| Bench
    Engine -->|"qualityCheck"| Test

    %% Click Events
    click Engine "https://github.com/wsoft-ws/losetta/tree/master/Losetta"
    click Parser "https://github.com/wsoft-ws/losetta/tree/master/Losetta/Parsing"
    click PreProc "https://github.com/wsoft-ws/losetta/tree/master/Losetta/PreProcessing"
    click Func "https://github.com/wsoft-ws/losetta/tree/master/Losetta/Functions"
    click Bind "https://github.com/wsoft-ws/losetta/tree/master/Losetta/Binding"
    click ObjEx "https://github.com/wsoft-ws/losetta/tree/master/Losetta/Objects"
    click Pack "https://github.com/wsoft-ws/losetta/tree/master/Losetta/Packaging"
    click Runtime "https://github.com/wsoft-ws/losetta/blob/master/Losetta.Runtime"
    click Bench "https://github.com/wsoft-ws/losetta/blob/master/Losetta.Bench"
    click Test "https://github.com/wsoft-ws/losetta/blob/master/Losetta.Test"
    click CLI "https://github.com/wsoft-ws/losetta/tree/master/alice"

    %% Styles
    classDef ui fill:#f9e79f,stroke:#d35400,stroke-width:2px;
    classDef engine fill:#aed6f1,stroke:#2874a6,stroke-width:2px;
    classDef module fill:#d6eaf8,stroke:#2e86c1,stroke-width:2px;
    classDef runtime fill:#abebc6,stroke:#28b463,stroke-width:2px;
    classDef bench fill:#fcf3cf,stroke:#f1c40f,stroke-width:2px;
```
