# benruijl/symbolica architecture

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

- Interactive diagram: https://gitdiagram.com/benruijl/symbolica
- Repository: https://github.com/benruijl/symbolica

## Overview

##### Main Components

a) Core Engine Layer:
- Located in src/lib.rs as the main entry point
- Core mathematical components:
- Atom system (src/atom/)
- Polynomial operations (src/poly/)
- Domain implementations (src/domains/)
- Expression evaluation (src/evaluate.rs)
- Pattern matching (src/transformer.rs)

b) Language Bindings Layer:
- API interfaces (src/api/):
- Python bindings (python.rs)
- C++ bindings (cpp.rs)
- Mathematica bindings (mathematica.rs)

c) Mathematical Features Layer:
- Specialized mathematical operations:
- Series expansion
- Pattern matching
- Linear system solving
- Rational arithmetic
- Numerical integration

**[Language Bindings Layer]**
- ↑↓
**[Core Engine Layer]**
- ↑↓
**[Mathematical Features Layer]**

##### Specific Component Details

- Rectangles for primary modules
- Hexagons for domain implementations
- Diamonds for transformation operations

- Blue: Core engine components
- Green: Language bindings
- Orange: Mathematical operations
- Purple: Domain implementations

##### Data Flow Representation

- Language bindings and core engine
- Core engine and mathematical features
- Domain implementations and core operations

##### Important Elements to Highlight

a) Expression Handling:
- Parser (src/parser.rs)
- Printer (src/printer.rs)
- Evaluator (src/evaluate.rs)
- Transformer (src/transformer.rs)

b) Mathematical Domains:
- Rational numbers
- Polynomials
- Finite fields
- Algebraic numbers

##### Detailed Component Relationships

- How expression parsing flows through the system
- How pattern matching integrates with the core engine
- How mathematical operations utilize different domains
- How the API layer interfaces with the core functionality

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Language_Bindings
        PY["Python Interface"]:::binding
        CPP["C++ Interface"]:::binding
        MATH["Mathematica Interface"]:::binding
    end

    subgraph Core_Engine
        CORE["Core Engine Entry Point"]:::core
        
        subgraph Atom_System
            ATOM["Core Atom"]:::core
            COEF["Coefficient Handler"]:::core
            REP["Representation"]:::core
        end

        subgraph Expression_Processing
            EVAL["Evaluation Engine"]:::process
            TRANS["Pattern Matching"]:::process
            PARSE["Parser"]:::process
            PRINT["Printer"]:::process
        end

        subgraph Polynomial_Ops
            POLY["Base Polynomial"]:::poly
            GCD["GCD Operations"]:::poly
            FACT["Factorization"]:::poly
            SER["Series Operations"]:::poly
            GROEB["Groebner Basis"]:::poly
        end
    end

    subgraph Mathematical_Features
        subgraph Domains
            RAT["Rational Numbers"]:::domain
            FF["Finite Fields"]:::domain
            ALG["Algebraic Numbers"]:::domain
            RATPOLY["Rational Polynomials"]:::domain
        end

        subgraph Operations
            SOLVE["Linear System Solver"]:::math
            NUMINT["Numerical Integration"]:::math
            DERIV["Derivative Operations"]:::math
            MATRIX["Matrix Operations"]:::math
        end
    end

    %% Build System
    BUILD["Build System"]:::build

    %% Relationships
    Language_Bindings --> CORE
    CORE --> Expression_Processing
    CORE --> Atom_System
    CORE --> Polynomial_Ops
    Expression_Processing --> Mathematical_Features
    Polynomial_Ops --> Domains
    Operations --> Domains

    %% Styling
    classDef core fill:#2b6cb0
    classDef binding fill:#48bb78
    classDef process fill:#805ad5
    classDef poly fill:#d69e2e
    classDef domain fill:#c53030
    classDef math fill:#dd6b20
    classDef build fill:#718096

    %% Click Events
    click CORE "https://github.com/benruijl/symbolica/blob/main/src/lib.rs"
    click ATOM "https://github.com/benruijl/symbolica/blob/main/src/atom/core.rs"
    click COEF "https://github.com/benruijl/symbolica/blob/main/src/atom/coefficient.rs"
    click REP "https://github.com/benruijl/symbolica/blob/main/src/atom/representation.rs"
    click POLY "https://github.com/benruijl/symbolica/blob/main/src/poly/polynomial.rs"
    click GCD "https://github.com/benruijl/symbolica/blob/main/src/poly/gcd.rs"
    click FACT "https://github.com/benruijl/symbolica/blob/main/src/poly/factor.rs"
    click SER "https://github.com/benruijl/symbolica/blob/main/src/poly/series.rs"
    click GROEB "https://github.com/benruijl/symbolica/blob/main/src/poly/groebner.rs"
    click RAT "https://github.com/benruijl/symbolica/blob/main/src/domains/rational.rs"
    click FF "https://github.com/benruijl/symbolica/blob/main/src/domains/finite_field.rs"
    click ALG "https://github.com/benruijl/symbolica/blob/main/src/domains/algebraic_number.rs"
    click RATPOLY "https://github.com/benruijl/symbolica/blob/main/src/domains/rational_polynomial.rs"
    click EVAL "https://github.com/benruijl/symbolica/blob/main/src/evaluate.rs"
    click TRANS "https://github.com/benruijl/symbolica/blob/main/src/transformer.rs"
    click PARSE "https://github.com/benruijl/symbolica/blob/main/src/parser.rs"
    click PRINT "https://github.com/benruijl/symbolica/blob/main/src/printer.rs"
    click PY "https://github.com/benruijl/symbolica/blob/main/src/api/python.rs"
    click CPP "https://github.com/benruijl/symbolica/blob/main/src/api/cpp.rs"
    click MATH "https://github.com/benruijl/symbolica/blob/main/src/api/mathematica.rs"
    click SOLVE "https://github.com/benruijl/symbolica/blob/main/src/solve.rs"
    click NUMINT "https://github.com/benruijl/symbolica/blob/main/src/numerical_integration.rs"
    click DERIV "https://github.com/benruijl/symbolica/blob/main/src/derivative.rs"
    click MATRIX "https://github.com/benruijl/symbolica/blob/main/src/tensors/matrix.rs"
    click BUILD "https://github.com/benruijl/symbolica/blob/main/Cargo.toml"
```
