# guitheg/technicalysis architecture

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

- Interactive diagram: https://gitdiagram.com/guitheg/technicalysis
- Repository: https://github.com/guitheg/technicalysis

## Overview

##### Project Type and Purpose
- This is an open-source, cross-language library for financial technical analysis indicators.
- Core is implemented in Rust (high performance, type safety) and exposed to both Rust consumers (Cargo) and Python consumers (PyO3/PyPI).

##### Key Components
- Rust Core Library (core/lib.rs): implements indicators (EMA, SMA, and placeholders for others).
- Python Binding Layer (core/pybinding.rs + python/technicalysis): uses PyO3 to expose Rust functions as a Python package.
- Packaging and Build:
- Cargo.toml / Cargo.lock: Rust crate configuration.
- pyproject.toml / requirements-dev.txt: Python package configuration and dev dependencies.
- GitHub Actions workflow (rust.yml): CI for building, testing, and publishing.
- Benchmarks and Examples:
- benches/: Rust and Python benchmarks for performance comparison.
- examples/: sample code demonstrating usage in both Rust and Python.
- launch_benchmark.sh: orchestrates bench runs.

##### Relationships and Data Flow
- Rust Consumer → pulls core crate from Cargo → calls indicators directly.
- Python Consumer → installs technicalysis from PyPI → at runtime Python code calls into the Rust core via PyO3.
- CI/CD builds both Rust crate and Python wheel, runs tests and benchmarks.
- Benchmarks compare native Rust vs. Python wrapper performance.

##### Architectural Patterns and Technologies
- Single code base in Rust, multi-language bindings via PyO3.
- Modular design: each indicator is a module under core/features.
- Test harnesses in both languages ensure correctness.
- Examples and benchmarks decoupled from core logic.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        direction TB
        CICD["GitHub Actions\n(.github/workflows/rust.yml)"]:::cicd
    end

    %% Rust Layer
    subgraph "Rust Layer"
        direction TB
        RustConsumer["Rust Consumer (Cargo)"]:::rust
        RustCore["Rust Core Library\n(core/, Rust)"]:::rust
        CargoConfig["Cargo Config\n(Cargo.toml)"]:::rust
        RustConsumer -->|"calls"| RustCore
        CargoConfig -->|"builds/tests"| RustCore
    end

    %% Binding Layer
    subgraph "Binding Layer"
        direction TB
        Binding["PyO3 Binding Layer\n(core/pybinding.rs)"]:::rust
        Binding -->|"calls"| RustCore
    end

    %% Python Layer
    subgraph "Python Layer"
        direction TB
        PyPkg["Python Package\n(python/technicalysis, Python)"]:::python
        PyConfig["Python Config\n(pyproject.toml)"]:::python
        PyPkg -->|"uses"| Binding
        PyConfig -->|"builds/tests"| PyPkg
    end

    %% Benchmarks and Examples
    subgraph "Benchmarks and Examples"
        direction TB
        RustBench["Rust Benchmarks\n(benches/, Rust)"]:::bench
        PyBench["Python Benchmarks\n(benches/python/, Python)"]:::bench
        RustExample["Rust Examples\n(examples/rust/, Rust)"]:::example
        PyExample["Python Examples\n(examples/python/, Python)"]:::example

        RustBench -.->|"benchmarks"| RustCore
        RustBench -.->|"benchmarks"| RustConsumer
        PyBench -.->|"benchmarks"| PyPkg
        RustExample -.->|"examples"| RustCore
        PyExample -.->|"examples"| PyPkg
    end

    %% CI/CD connections
    CICD -->|"builds/tests"| RustCore
    CICD -->|"builds/tests"| PyPkg

    %% Click Events
    click RustCore "https://github.com/guitheg/technicalysis/blob/main/core/lib.rs"
    click Binding "https://github.com/guitheg/technicalysis/blob/main/core/pybinding.rs"
    click PyPkg "https://github.com/guitheg/technicalysis/tree/main/python/technicalysis/"
    click CargoConfig "https://github.com/guitheg/technicalysis/blob/main/Cargo.toml"
    click PyConfig "https://github.com/guitheg/technicalysis/blob/main/pyproject.toml"
    click CICD "https://github.com/guitheg/technicalysis/blob/main/.github/workflows/rust.yml"
    click RustBench "https://github.com/guitheg/technicalysis/blob/main/benches/ema_bench.rs"
    click PyBench "https://github.com/guitheg/technicalysis/blob/main/benches/python/benchmark_timeit.py"
    click RustExample "https://github.com/guitheg/technicalysis/blob/main/examples/rust/features/bin/sma.rs"
    click PyExample "https://github.com/guitheg/technicalysis/blob/main/examples/python/ema.py"

    %% Styles
    classDef rust fill:#a3cef1,stroke:#0366d6,stroke-width:2px,color:#0366d6;
    classDef python fill:#fddc69,stroke:#d69e2e,stroke-width:2px,color:#d69e2e;
    classDef cicd fill:#cccccc,stroke:#666666,stroke-width:2px,color:#333333;
    classDef bench stroke-dasharray: 5 5,fill:#e8e8e8,stroke:#999999,stroke-width:1px,color:#666666;
    classDef example stroke-dasharray: 5 5,fill:#f0f0f0,stroke:#bbbbbb,stroke-width:1px,color:#777777;
```
