# grzegorzmazur/yacas architecture

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

- Interactive diagram: https://gitdiagram.com/grzegorzmazur/yacas
- Repository: https://github.com/grzegorzmazur/yacas

## Overview

##### Main Components
- Core Computation Engine:
- The core is implemented in modules such as the “libyacas” (cyacas/libyacas) that contains the basic data types, the symbolic manipulation functions, the infix parser, and other core routines.
- Multi-precision support is provided by “libyacas_mp.”
- The “yacas” and “yacas-kernel” directories likely include the main engine code for command-line processing, function evaluation, and rule-based symbolic computations.
- Interpreter & Parser:
- Components like the “infixparser”, “lispparser”, and associated evaluation modules appear in the source directories.
- These components translate user input (via command-line or scripts) into operations for the core engine.
- User Interfaces:
- Yacas supports a GUI front end visible in “yacas-gui” which integrates with the core engine.
- The command-line interface is part of the “yacas” component (as seen by files dealing with various command-line handling).
- There is a “jyacas” module providing Java binding and potentially additional interoperability.
- “xeus-yacas” likely provides integration with interactive computing environments, such as Jupyter.
- Scripting and Built-in Functions:
- The “scripts” directory provides numerous example scripts and domain-specific files (.ys and corresponding definitions) that show how the CAS language can be extended.
- Documentation, Tests, and Packaging:
- The “docs” directory contains detailed reference manuals, tutorials, and developer guides.
- The “tests” directory contains a suite of automated tests verifying core functionality.
- Packaging subdirectories (deb, rpm, flatpak, etc.) indicate how the software is built and deployed across platforms.

##### Relationships and Interactions
- The User Interfaces (GUI, command-line, Java, Jupyter integration) serve as the front ends. They capture user requests and pass them to the interpreter.
- The Interpreter processes user commands using the parser(s) to convert text input into a symbolic representation.
- The Core Engine (libyacas and its related modules) then performs symbolic evaluation, applying user-defined as well as built-in mathematical rules.
- For advanced numerical work, the multi-precision module augments the core’s capabilities.
- Scripting components allow for complex computations and are directly interpreted by the engine.
- Testing, packaging, and documentation components are auxiliary but critical for validation and distribution.

##### Architectural Patterns and Principles
- Modularity: The project is clearly divided into smaller submodules (e.g., different libraries for core and multi-precision arithmetic, separate UI implementations) that encapsulate specific responsibilities.
- Separation of Concerns: The computational engine, interpreter, and UI layers are clearly separated. This makes the system easier to extend (e.g., by adding a new front end) and maintain.
- Extensibility: The presence of script-based user functions and a well-documented API indicate that the architecture facilitates user modifications and extensions.

##### Relevant Technologies and Frameworks
- Core language is C++ (with extensive use of CMake for building).
- Java-based interface is provided in the “jyacas” component.
- GUI likely uses Qt (as indicated by CMakeLists and qrc files) and further JavaScript libraries (e.g., CodeMirror, MathJax) for interacting with web-based or hybrid components.
- Testing and continuous integration tools are referenced (like Appveyor, Codecov, and Codacy).

##### Elements
- Clear labels for each major component:
- "User Interfaces": Command Line, GUI (yacas-gui), Java Binding (jyacas), Jupyter Integration (xeus-yacas)
- "Interpreter/Parser": Infix Parser, Lisp Parser modules
- "Core Engine": libyacas, yacas, yacas-kernel
- "Multi-Precision Module": libyacas_mp
- "Scripting & Function Libraries": scripts directory modules, which also serve as examples and functional enhancements
- "Testing & Packaging": tests, packaging directories, and docs
- From UI layers to the Interpreter
- From Interpreter to Core Engine
- Feedback flow or error reporting back to UI layers
- Annotations for dependency/integration:
- Demonstrate how the GUI interacts with the kernel (possibly via a server or a direct library call).
- Integration points for external libraries (e.g., third_party vis, MathJax for visualization).
- For instance, use rectangles for core modules, ellipses for interfaces, and clouds for external or third-party dependencies.
- Build and deployment pipelines:
- An additional “Build/Packaging” component (CMake, scripts, test suites) that prepares the software for different platforms.

##### Additional Advice
- Both logical interactions (e.g., modular dependency) and physical/textual interactions (e.g., CMake build process).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Interfaces"
        UI_CLI["Command Line Interface (yacas)"]:::interface
        UI_GUI["Graphical User Interface (yacas-gui)"]:::interface
        UI_JAVA["Java Binding (jyacas)"]:::interface
        UI_JUPYTER["Jupyter Integration (xeus-yacas)"]:::interface
    end

    subgraph "Interpreter & Parser"
        INTER_INFIX["Infix Parser"]:::interpreter
        INTER_LISP["Lisp Parser"]:::interpreter
    end

    subgraph "Core Engine"
        CORE["Core Computation Engine (libyacas)"]:::engine
        KERNEL["Kernel/Backend (yacas-kernel)"]:::engine
        MULTI["Multi-Precision Module (libyacas_mp)"]:::engine
    end

    subgraph "Extensions"
        SCRIPT["Scripting & Built-in Functions"]:::aux
    end

    subgraph "Support & Deployment"
        DOC["Documentation"]:::aux
        TEST["Testing Suite"]:::aux
        PACK["Packaging/Deployment"]:::aux
    end

    %% Connections from User Interfaces to Interpreter & Parser
    UI_CLI -->|"input"| INTER_INFIX
    UI_GUI -->|"input"| INTER_INFIX
    UI_JAVA -->|"input"| INTER_INFIX
    UI_JUPYTER -->|"input"| INTER_INFIX

    %% Connections from Interpreter to Core Engine
    INTER_INFIX -->|"parse"| CORE
    INTER_LISP -->|"parse"| CORE

    %% Interactions within Core Engine
    CORE -->|"delegate"| KERNEL
    CORE -->|"precision"| MULTI

    %% Scripting feeding directly into Core Engine
    SCRIPT -->|"script"| CORE

    %% Core Engine sending result back to CLI (for example)
    CORE -.->|"result"| UI_CLI

    %% Links to Support and Deployment components (dotted for non-runtime relations)
    CORE -.->|"docs"| DOC
    CORE -.->|"tests"| TEST
    CORE -.->|"package"| PACK

    %% Click Events
    click CORE "https://github.com/grzegorzmazur/yacas/tree/master/cyacas/libyacas"
    click MULTI "https://github.com/grzegorzmazur/yacas/tree/master/cyacas/libyacas_mp"
    click UI_CLI "https://github.com/grzegorzmazur/yacas/tree/master/cyacas/yacas"
    click KERNEL "https://github.com/grzegorzmazur/yacas/tree/master/cyacas/yacas-kernel"
    click INTER_INFIX "https://github.com/grzegorzmazur/yacas/blob/master/cyacas/libyacas/include/yacas/infixparser.h"
    click INTER_LISP "https://github.com/grzegorzmazur/yacas/blob/master/cyacas/libyacas/include/yacas/lispparser.h"
    click UI_GUI "https://github.com/grzegorzmazur/yacas/tree/master/cyacas/yacas-gui"
    click UI_JAVA "https://github.com/grzegorzmazur/yacas/tree/master/jyacas"
    click UI_JUPYTER "https://github.com/grzegorzmazur/yacas/tree/master/cyacas/xeus-yacas"
    click SCRIPT "https://github.com/grzegorzmazur/yacas/tree/master/scripts"
    click DOC "https://github.com/grzegorzmazur/yacas/tree/master/docs"
    click TEST "https://github.com/grzegorzmazur/yacas/tree/master/tests"
    click PACK "https://github.com/grzegorzmazur/yacas/tree/master/cyacas/packaging"

    %% Style Definitions
    classDef interface fill:#f9e79f,stroke:#d35400,stroke-width:2px;
    classDef interpreter fill:#aed6f1,stroke:#3498db,stroke-width:2px;
    classDef engine fill:#abebc6,stroke:#27ae60,stroke-width:2px;
    classDef aux fill:#f5cba7,stroke:#e67e22,stroke-width:2px;
```
