# huytrinhm/ikant architecture

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

- Interactive diagram: https://gitdiagram.com/huytrinhm/ikant
- Repository: https://github.com/huytrinhm/ikant

## Overview

##### Project Type and Purpose
- This project is a C++ application focused on implementing and visualizing Kolmogorov-Arnold Networks (KAN).
- It provides a GUI for editing network parameters and training settings, integrates with LAPACK for numerical computations, and uses Raylib for rendering the visuals.
- The notebook (development.ipynb) indicates that there is also an interactive or exploratory data/visualization aspect for understanding checkpoint and data formats.

##### Analyzing the File Structure
- Top-Level Components:
- The project’s root includes build scripts (Makefile), licensing/README, and a development notebook.
- The lib and include directories provide prebuilt libraries and header definitions (for LAPACK, Raylib, TinyFileDialogs, etc.).
- Directories:
- src: Contains the actual application code.
▪ src/kan: Houses the core implementation files for KAN (kan.cpp, spline, tensor) that handle the network computations and algorithms.
▪ src/gui: Contains the GUI components (gui.h) for interfacing with the user.
▪ main.cpp: Acts as the entry point integrating all components.
- External Libraries:
- The header and lib directories emphasize dependencies on external libraries like LAPACK and Raylib. This indicates clearly defined integration points for numerical and graphics functionalities.

a. Main Components:
- User Interface (GUI):
– Represented by the files in src/gui.
– Handles user input, parameter modifications, and visualization controls.
- Core Computational Engine:
– Implemented in src/kan (kan.cpp, spline.cpp, tensor.cpp).
– Implements Kolmogorov-Arnold Networks along with associated mathematical operations.
- External Libraries/Modules:
– LAPACK: Used for core numerical computations.
– Raylib: Used for rendering and graphical display.
– TinyFileDialogs: For lightweight file dialog support.
- Build and Configuration Layer:
– Managed by Makefile, and the lib and include directories which encapsulate compiled libraries and interface headers.

b. Relationships and Interactions:
- The GUI module sends user commands to the core KAN engine.
- The core engine processes data, performing computations with the help of LAPACK.
- Once computations are complete, the core engine sends output to the rendering module via Raylib.
- External dialogs (via TinyFileDialogs) may be triggered through the GUI for file operations.
- The main entry point (main.cpp) wires up these interactions, initializing the GUI and linking the computational routines with rendering and file interactions.
- The build process (Makefile) organizes these modules into the final executable.

c. Architectural Patterns/Design Principles:
- Separation of Concerns:
– The division between the GUI components and the core computation modules is evident.
- Modular Design:
– Each distinct functionality (numerical computation, rendering, file dialogs) is encapsulated in separate directories and files.
- Integration of third-party libraries:
– The architecture makes use of external libraries (LAPACK, Raylib, TinyFileDialogs) to handle specialized tasks, promoting code reuse and maintainability.

d. Relevant Technologies and Frameworks:
- C++: The primary programming language.
- LAPACK: For numerical linear algebra operations.
- Raylib: For graphics and visualization.
- TinyFileDialogs: For simple file dialog operations.
- Make: For building and deployment through the Makefile.

##### Instructing the Principal Software Engineer
- Create clear, labeled blocks for each of the following components:
- GUI layer (src/gui)
- Core KAN module with sub-components for spline computations and tensor operations (src/kan)
- External Libraries:
▪ LAPACK
▪ Raylib
▪ TinyFileDialogs
- Main execution point (main.cpp) that ties the system together.
- Build configuration (Makefile) and supporting libraries/headers (lib and include).
- The flow from user interactions (GUI) to backend processing (KAN core).
- How computed data is passed to the rendering layer via Raylib.
- Data dependencies between the core modules and LAPACK.
- The core engine in another, and external libraries in a distinct style.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Build and Configuration Layer
    subgraph "Build & Configuration"
        Build1["Makefile"]:::build
        Build2["Libraries & Headers (include, lib)"]:::build
    end

    %% Main Execution Point
    Main["Main Execution Point (src/main.cpp)"]:::main

    %% Application Layer containing GUI and Core KAN Module
    subgraph "Application Layer"
        GUI["GUI Module (src/gui)"]:::gui
        subgraph "Core KAN Module"
            KAN["KAN Engine (src/kan/kan.cpp)"]:::core
            Spline["Spline Computations (src/kan/spline.cpp)"]:::core
            Tensor["Tensor Operations (src/kan/tensor.cpp)"]:::core
        end
    end

    %% External Libraries
    subgraph "External Libraries"
        LAPACK["LAPACK"]:::external
        Raylib["Raylib"]:::external
        TinyFD["TinyFileDialogs"]:::external
    end

    %% Connections
    Build1 --> Main
    Build2 --> Main
    Main --> GUI
    Main --> KAN
    GUI -->|"sends_commands"| KAN
    KAN -->|"uses"| LAPACK
    KAN -->|"renders_with"| Raylib
    GUI -->|"triggers"| TinyFD
    KAN -->|"employs"| Spline
    KAN -->|"employs"| Tensor

    %% Click Events
    click Build1 "https://github.com/huytrinhm/ikant/tree/master/Makefile"
    click Main "https://github.com/huytrinhm/ikant/blob/master/src/main.cpp"
    click GUI "https://github.com/huytrinhm/ikant/blob/master/src/gui/gui.h"
    click KAN "https://github.com/huytrinhm/ikant/blob/master/src/kan/kan.cpp"
    click Spline "https://github.com/huytrinhm/ikant/blob/master/src/kan/spline.cpp"
    click Tensor "https://github.com/huytrinhm/ikant/blob/master/src/kan/tensor.cpp"
    click LAPACK "https://github.com/huytrinhm/ikant/blob/master/include/lapacke.h"
    click Raylib "https://github.com/huytrinhm/ikant/blob/master/include/raylib.h"
    click TinyFD "https://github.com/huytrinhm/ikant/blob/master/include/tinyfiledialogs.h"

    %% Styles
    classDef build fill:#f8d7da,stroke:#333,stroke-width:2px;
    classDef main fill:#fff3cd,stroke:#333,stroke-width:2px;
    classDef gui fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef core fill:#d4edda,stroke:#333,stroke-width:2px;
    classDef external fill:#ffeeba,stroke:#333,stroke-width:2px;
```
