# pustoslov/neural-kt architecture

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

- Interactive diagram: https://gitdiagram.com/pustoslov/neural-kt
- Repository: https://github.com/pustoslov/neural-kt

## Overview

- Neural Network Library Module (NeuralNetLib):
– Contains the core implementations: NeuralNet1L, NeuralNet2L, and NeuralNet3L.
– Organized under package com.github.pustoslov.NeuralNetLib.
– Represents the “engine” of the project that handles network creation, training, weight management, and querying.
- Sample Application:
– Located in src/main/kotlin with Main.kt.
– Demonstrates how to use the NeuralNetLib, including loading the MNIST dataset (CSV files in src/main/resources).
- Data Resources:
– Training and testing CSV files (e.g., test.csv and train.csv) that provide the MNIST dataset for experimentation.
- Build and Configuration Components:
– Gradle build scripts (build.gradle.kts, settings.gradle.kts, gradle wrapper files) that orchestrate the build, dependency inclusion, and configuration.
– README instructions on how to add the dependency for using the library in other projects.

##### Component Relationships and Data Flows
- The Sample Application (Main.kt) acts as a client:
– It initializes a neural network object (e.g., NeuralNet1L).
– Passes the input data (from CSV files) into the neural network.
– Invokes the training (train()) and querying (query()) methods, representing data flow from the application to the library.
- Inside the Neural Network Library:
– Show interactions between methods: for example, weights being set or retrieved using getWeights() and setWeights().

##### Important Architectural Patterns and Design Principles
- Modularity: The project is split into a reusable library (NeuralNetLib) and an application demonstration.
- Encapsulation: The neural network details (e.g., architecture parameters, learning rate) are encapsulated within dedicated classes.
- Flexibility/Extensibility: Multiple neural network variants (1L, 2L, 3L) are provided, which hints at a design that allows easy extension or variation in network architecture.

##### Relevant Technologies and Frameworks
- Programming Language: Kotlin.
- Build Tool: Gradle (with both Groovy and Kotlin DSL support, as evident in build.gradle and build.gradle.kts).
- External Dependency: Instructions in the README show how to pull the neural network library from the jitpack.io repository.
- Data Input: CSV formatted files to simulate a dataset (in this case, MNIST).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Build & Configuration"
        BG1["build.gradle.kts"]:::buildFile
        BG2["settings.gradle.kts"]:::buildFile
        BG3["gradle/wrapper"]:::buildFile
    end

    subgraph "NeuralNetLib Module"
        LIB["NeuralNetLib Module"]:::lib
        NN1["NeuralNet1L"]:::lib
        NN2["NeuralNet2L"]:::lib
        NN3["NeuralNet3L"]:::lib
        LIB -->|"contains"| NN1
        LIB -->|"contains"| NN2
        LIB -->|"contains"| NN3
    end

    subgraph "Sample Application"
        APP["Main.kt"]:::app
    end

    subgraph "Data Resources"
        TEST["test.csv"]:::dataFile
        TRAIN["train.csv"]:::dataFile
    end

    APP -->|"uses_library"| LIB
    TEST -->|"provides_data"| APP
    TRAIN -->|"provides_data"| APP

    BG1 -.->|"build_setup"| LIB
    BG2 -.->|"build_setup"| LIB
    BG3 -.->|"build_setup"| LIB
    BG1 -.->|"build_setup"| APP
    BG2 -.->|"build_setup"| APP
    BG3 -.->|"build_setup"| APP

    click LIB "https://github.com/pustoslov/neural-kt/tree/main/NeuralNetLib/src/main/java/com/github/pustoslov/NeuralNetLib"
    click NN1 "https://github.com/pustoslov/neural-kt/blob/main/NeuralNetLib/src/main/java/com/github/pustoslov/NeuralNetLib/NeuralNet1L.kt"
    click NN2 "https://github.com/pustoslov/neural-kt/blob/main/NeuralNetLib/src/main/java/com/github/pustoslov/NeuralNetLib/NeuralNet2L.kt"
    click NN3 "https://github.com/pustoslov/neural-kt/blob/main/NeuralNetLib/src/main/java/com/github/pustoslov/NeuralNetLib/NeuralNet3L.kt"
    click APP "https://github.com/pustoslov/neural-kt/blob/main/src/main/kotlin/Main.kt"
    click TEST "https://github.com/pustoslov/neural-kt/blob/main/src/main/resources/test.csv"
    click TRAIN "https://github.com/pustoslov/neural-kt/blob/main/src/main/resources/train.csv"
    click BG1 "https://github.com/pustoslov/neural-kt/blob/main/build.gradle.kts"
    click BG2 "https://github.com/pustoslov/neural-kt/blob/main/settings.gradle.kts"
    click BG3 "https://github.com/pustoslov/neural-kt/tree/main/gradle/wrapper"

    classDef lib fill:#fef2cc,stroke:#cc6,stroke-width:2px;
    classDef app fill:#cce5ff,stroke:#428bca,stroke-width:2px;
    classDef dataFile fill:#d4edda,stroke:#28a745,stroke-width:2px;
    classDef buildFile fill:#f8d7da,stroke:#dc3545,stroke-width:2px;
```
