# potato-yao/landau architecture

> Architecture diagram of the GitHub repository potato-yao/landau, 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/potato-yao/landau
- Repository: https://github.com/potato-yao/landau

## Overview

##### A LaTeX Analyzer Subsystem
- Located in the “latex-analyzer” directory with dedicated modules such as lex.rs, parser.rs, and ast.rs.
- This subsystem is responsible for tokenizing and parsing LaTeX documents (with accompanying test files to verify its behavior).

##### A Math Library Subsystem
- Provided in the “math” directory, the library includes both a Rust interface (in math/src) and a C-based implementation (in math/c). Notice the supporting build scripts (build.rs and CMakeLists.txt).
- Within the Rust portion, modules like “linear_algebra” (with matrix.rs) and “util” (with approx.rs, pow.rs, and root.rs) indicate specialized mathematical operations.
– The C-based calculation layer interfaced via FFI.
– The Rust abstraction layer that exposes mathematical functions for use by the rest of the system.
- Clear interfaces between these layers to highlight integration.

##### A Main Application Core
- The “src” directory comprises files such as buildin_function.rs, config.rs, exec.rs, function.rs, known.rs, lib.rs, and transformer.rs.
- This area likely serves as the core execution engine or interpreter that brings together LaTeX document processing and math computations.
– The LaTeX Analyzer for parsing input documents.
– The Math Library for numerical operations.
– Possibly using configuration from “config.toml” and incorporating built-in functions designed in “buildin_function.rs.”

##### A LaTeX Extension Component
- Found in “landau-latex-extension”, containing a style file for Landau. This extension is likely an optional or supplementary tool that provides custom LaTeX styling or metadata.
- This as a distinct external module that might integrate with the primary LaTeX processing routine (e.g., post-parsing styling or document generation).

##### Overall Architectural and Communication Details
- Modular and layered design of the system:
- The Main Application orchestrates the workflow.
- The LaTeX Analyzer is one isolated module that manages parsing and syntax analysis.
- The Math Library is another core module offered in both Rust and C, indicating a performance-sensitive or legacy codebase component.
- The LaTeX Extension functions as a plugin/component for document styling.
- Rust components (perhaps using rounded rectangles).
- External extension modules.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% LaTeX Analyzer Subsystem
    subgraph "LaTeX Analyzer Subsystem"
        direction TB
        TexLex["Lexical Analysis"]:::rust
        TexParse["Parsing"]:::rust
        TexAST["AST Construction"]:::rust
        TexLex -->|"tokenizes"| TexParse
        TexParse -->|"builds"| TexAST
    end

    %% Math Library Subsystem
    subgraph "Math Library"
        direction TB
        subgraph "C-Based Calculation Layer"
            MathC["Math – C Library"]:::cComp
        end
        subgraph "Rust Abstraction Layer"
            MathRust["Math – Rust Interface"]:::rust
        end
        MathRust ---|"FFI_Integration"| MathC
    end

    %% Main Application Core
    subgraph "Main Application Core"
        direction TB
        Core["Main Executor"]:::rust
    end

    %% LaTeX Extension Component
    Ext["LaTeX Extension"]:::external

    %% Interactions
    Core -->|"calls_analysis"| TexLex
    Core -->|"calls_math"| MathRust
    Core -->|"applies_style"| Ext

    %% Styles
    classDef rust fill:#B7E1CD,stroke:#0B8043,stroke-width:2px,rx:5,ry:5;
    classDef cComp fill:#AED4FF,stroke:#005BBB,stroke-width:2px,rx:5,ry:5;
    classDef external fill:#FDEBD0,stroke:#D35400,stroke-width:2px,rx:5,ry:5;

    %% Click Events
    click TexLex "https://github.com/potato-yao/landau/tree/master/latex-analyzer/src"
    click MathRust "https://github.com/potato-yao/landau/tree/master/math/src"
    click MathC "https://github.com/potato-yao/landau/tree/master/math/c"
    click Core "https://github.com/potato-yao/landau/tree/master/src"
    click Ext "https://github.com/potato-yao/landau/tree/master/landau-latex-extension"
```
