# unageek/graphest architecture

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

- Interactive diagram: https://gitdiagram.com/unageek/graphest
- Repository: https://github.com/unageek/graphest

## Overview

##### Component Relationships

- IPC communication between renderer and main processes
- Data flow from UI input to Rust core calculations
- Result propagation back to the UI
- Integration with external libraries (FFTW, Arb)

##### Specific Implementation Details

- Blue rectangles: UI components
- Green hexagons: Core mathematical processing modules
- Yellow diamonds: External system interfaces
- Purple rectangles: State management components

##### Key Architectural Elements

Crucial aspects:
**┌─────────────────────────────────────────┐**
- Electron Application          │
- ┐        ┌──────────────────┤
- Renderer   │        │   Main Process   │
- (React UI) │◄─────►│   (TypeScript)   │
- ┘        └──────────────────┤

- Rust Mathematical Core           │
- ┤
- External Libraries (FFTW, Arb)       │
- ┘

##### Important Subsystems

- Graph processing pipeline
- Mathematical expression parsing and evaluation
- Interval arithmetic system
- UI state management flow

##### Technical Details

- Electron/React for UI
- Rust for core computation
- TypeScript for application logic
- FFTW for Fourier transforms
- Arb for arbitrary-precision arithmetic

##### Integration Points

Highlight:
- Native module bridges
- IPC channels
- File system interactions
- External library interfaces

Remember to maintain a balance between detail and clarity, focusing on the unique aspects of this mathematical graphing calculator, particularly the reliable plotting system and the interaction between the UI and mathematical core.

- Component types
- Connection types
- State flow
- Data transformation steps
- Error handling paths

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and classes
    classDef frontend fill:#a8d1f0,stroke:#333
    classDef backend fill:#90ee90,stroke:#333
    classDef rust fill:#ffa07a,stroke:#333
    classDef ffi fill:#dda0dd,stroke:#333
    classDef common fill:#f0e68c,stroke:#333
    classDef state fill:#98fb98,stroke:#333

    %% Frontend Layer
    subgraph Frontend
        UI["UI Components"]
        GraphView["Graph View"]:::frontend
        GraphBar["Graph Bar"]:::frontend
        RelationInput["Relation Input"]:::frontend
        
        subgraph StateManagement
            AppState["App State"]:::state
            GraphState["Graph State"]:::state
            Store["Store"]:::state
        end
    end

    %% Backend Layer
    subgraph Backend
        MainProcess["Main Process"]:::backend
        MenuSystem["Menu System"]:::backend
        Serialization["Serialization"]:::backend
        IPC["IPC Communication"]:::common
    end

    %% Rust Core Layer
    subgraph RustCore
        GraphProcessor["Graph Processing"]:::rust
        ASTProcessor["AST Processing"]:::rust
        EvalCache["Expression Evaluation"]:::rust
        IntervalArith["Interval Arithmetic"]:::rust
        Parser["Parser"]:::rust

        subgraph GraphTypes
            ExplicitGraph["Explicit Graphs"]:::rust
            ImplicitGraph["Implicit Graphs"]:::rust
            ParametricGraph["Parametric Graphs"]:::rust
        end

        subgraph FFIBridges
            ArbBridge["Arb Bridge"]:::ffi
            FFTWBridge["FFTW Bridge"]:::ffi
        end
    end

    %% Common Utilities
    subgraph Common
        Constants["Constants"]:::common
        GridRenderer["Grid Renderer"]:::common
        ParseUtils["Parsing Utils"]:::common
        ResultHandler["Result Handler"]:::common
    end

    %% Relationships
    UI --> GraphView
    UI --> GraphBar
    UI --> RelationInput
    GraphView --> Store
    GraphBar --> Store
    RelationInput --> Store
    Store --> AppState
    Store --> GraphState
    IPC --> MainProcess
    MainProcess --> MenuSystem
    MainProcess --> Serialization
    IPC --> GraphProcessor
    GraphProcessor --> ASTProcessor
    ASTProcessor --> Parser
    GraphProcessor --> EvalCache
    EvalCache --> IntervalArith
    GraphProcessor --> ExplicitGraph
    GraphProcessor --> ImplicitGraph
    GraphProcessor --> ParametricGraph
    GraphProcessor --> FFTWBridge
    GraphProcessor --> ArbBridge

    %% Click events
    click GraphView "https://github.com/unageek/graphest/blob/main/src/renderer/GraphView.tsx"
    click GraphBar "https://github.com/unageek/graphest/blob/main/src/renderer/GraphBar.tsx"
    click RelationInput "https://github.com/unageek/graphest/blob/main/src/renderer/RelationInput.tsx"
    click AppState "https://github.com/unageek/graphest/blob/main/src/renderer/models/app.ts"
    click GraphState "https://github.com/unageek/graphest/blob/main/src/renderer/models/graph.ts"
    click Store "https://github.com/unageek/graphest/blob/main/src/renderer/models/store.ts"
    click MainProcess "https://github.com/unageek/graphest/blob/main/src/main/main.ts"
    click MenuSystem "https://github.com/unageek/graphest/blob/main/src/main/mainMenu.ts"
    click Serialization "https://github.com/unageek/graphest/blob/main/src/main/serialize.ts"
    click IPC "https://github.com/unageek/graphest/blob/main/src/common/ipc.ts"
    click GraphProcessor "https://github.com/unageek/graphest/tree/main/rust/src/graph/"
    click ASTProcessor "https://github.com/unageek/graphest/blob/main/rust/src/ast.rs"
    click EvalCache "https://github.com/unageek/graphest/blob/main/rust/src/eval_cache.rs"
    click IntervalArith "https://github.com/unageek/graphest/blob/main/rust/src/interval_set.rs"
    click Parser "https://github.com/unageek/graphest/blob/main/rust/src/parse.rs"
    click ArbBridge "https://github.com/unageek/graphest/tree/main/rust/graphest-arb-sys/"
    click FFTWBridge "https://github.com/unageek/graphest/tree/main/rust/graphest-fftw-sys/"
    click Constants "https://github.com/unageek/graphest/blob/main/src/common/constants.ts"
    click GridRenderer "https://github.com/unageek/graphest/blob/main/src/common/gridRenderer.ts"
    click ParseUtils "https://github.com/unageek/graphest/blob/main/src/common/parse.ts"
    click ResultHandler "https://github.com/unageek/graphest/blob/main/src/common/result.ts"
    click ExplicitGraph "https://github.com/unageek/graphest/blob/main/rust/src/graph/explicit.rs"
    click ImplicitGraph "https://github.com/unageek/graphest/blob/main/rust/src/graph/implicit.rs"
    click ParametricGraph "https://github.com/unageek/graphest/blob/main/rust/src/graph/parametric.rs"
```
