# r8025n/neural-network architecture

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

- Interactive diagram: https://gitdiagram.com/r8025n/neural-network
- Repository: https://github.com/r8025n/neural-network

## Overview

##### Project Type and Purpose
- This is a standalone Python application implementing a fully-connected feedforward neural network using only NumPy.
- Purpose: load the MNIST dataset, train a network via mini-batch SGD and backpropagation, and allow easy experimentation.

##### File Structure
- Top-level scripts:
- main.py – entry point / orchestrator
- network.py – the NeuralNetwork class (forward pass, backprop, weight updates)
- data_loader.py – loads and preprocesses MNIST from data/mnist.pkl.gz
- utils.py – activation functions (sigmoid, sigmoid_prime), evaluation helpers
- Data folder: data/mnist.pkl.gz – compressed dataset
- No external services or microservices—monolithic script.

##### Extract Key Architecture Insights from README
- Single process, linear pipeline: Data → Network → Training loop.
- Core dependencies: Python 3.x, NumPy only.
- No REST API or UI layer—CLI-driven training script.

##### Main Components
A. Data Source
- MNIST dataset file (data/mnist.pkl.gz)
B. Data Loader Layer (data_loader.py)
- Loads, unpacks, yields mini-batches
C. Model Layer (network.py)
- NeuralNetwork class with:
– Weight and bias storage
– forward() method
– backprop() method
– update_mini_batch() method
D. Utility Layer (utils.py)
- Activation functions (sigmoid, sigmoid_prime)
E. Orchestration Layer (main.py)
- Reads parameters (epochs, batch size, architecture)
- Invokes data loader → training loop → evaluation
F. Environment
- Python runtime, NumPy library

##### Relationships and Data Flow
- Loop: Orchestration Layer iterates over epochs and batches

##### Architectural Patterns and Principles
- Layered architecture: separate data ingestion, computation, and orchestration
- Single-responsibility: each module has a well-defined role
- Pipeline pattern: sequential processing of mini-batches
- No external service dependencies—self-contained.

##### Technologies and Frameworks
- Python 3.x – runtime
- NumPy – numerical computations
- gzip / pickle – data serialization

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Python Process (Python Runtime)"
        direction TB
        Orchestrator["Orchestration Layer\n(main.py)"]:::module
        DataLoader["Data Loader Layer\n(data_loader.py)"]:::module
        Model["Model Layer\n(network.py)"]:::module
        Utils["Utility Layer\n(utils.py)"]:::module
    end
    DataSource["MNIST Dataset\n(data/mnist.pkl.gz)"]:::datasource
    PY["Python 3.x & NumPy"]:::env

    DataSource -->|"load_data()"| DataLoader
    DataLoader -->|"yield_batch()"| Orchestrator
    Orchestrator -->|"forward()"| Model
    Orchestrator -->|"update_mini_batch()"| Model
    Model -->|"sigmoid()/sigmoid_prime()"| Utils
    Model -->|"backprop()"| Utils
    Model -->|"performance_metrics()"| Orchestrator
    PY --> Orchestrator
    PY --> DataLoader
    PY --> Model
    PY --> Utils

    click DataSource "https://github.com/r8025n/neural-network/blob/main/data/mnist.pkl.gz"
    click DataLoader "https://github.com/r8025n/neural-network/blob/main/data_loader.py"
    click Model "https://github.com/r8025n/neural-network/blob/main/network.py"
    click Utils "https://github.com/r8025n/neural-network/blob/main/utils.py"
    click Orchestrator "https://github.com/r8025n/neural-network/blob/main/main.py"

    classDef datasource fill:#3b82f6,stroke:#1e40af,color:#fff;
    classDef module fill:#10b981,stroke:#065f46,color:#fff;
    classDef env fill:#f3f4f6,stroke:#9ca3af,color:#111,stroke-dasharray: 5 5;
```
