# ulichovick/ann_fashion_mnist architecture

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

- Interactive diagram: https://gitdiagram.com/ulichovick/ann_fashion_mnist
- Repository: https://github.com/ulichovick/ann_fashion_mnist

## Overview

##### Project Overview & Purpose
- This is a Flask-based web application that provides endpoints for working with neural networks.
- It integrates two different neural network implementations – one built using pure NumPy and one using TensorFlow – which serve for different experimentation or performance use cases.
- The application is designed to offer front-end interactions (through templates, static assets) and back-end processing via its neural network modules.

##### Main Components
a. Frontend (Web Presentation Layer)
- Templates: Located in the “templates” directory. These include base.html, index.html, predict.html, train.html, etc.
- Static Assets: Including CSS, JavaScript, graphics, and Sass files in the “static” directory that define the look-and-feel.
b. Flask Application (Backend Server)
- Flask initialization and route management (likely initiated via the “init_flask” directory and “network.py” script). This is the glue that connects the HTTP requests from the browser to the business logic.
c. Neural Network Modules
- NumPy Network Component:
- Directory: “numpy_network”
- Contains scripts for activation neurons, backpropagation, forward propagation, cost, data preparation, parameters initialization, updating, predictions, and model training/evaluation.
- Also includes pre-generated score files and a “parameters.npy” file.
- TensorFlow Network Component:
- Directory: “tf_network”
- Contains similar functionality for data preparation, model creation, compilation, and prediction specific to TensorFlow (including a pre-trained or pre-built model “ann_tf_fashmnist.h5”).
d. Configuration & Dependencies
- Files: requirements.txt, LICENSE, and additional configuration files that help manage project dependencies.

##### Relationships and Interactions
- The Flask server acts as the central hub, receiving requests from the client’s browser (through the UI) and then delegating tasks.
- For operations related to prediction or training:
- The Flask routes (web API) will call either the NumPy-based or the TensorFlow-based neural network processing.
- Static assets and templates flow from the server to the client, while the neural network modules work behind the scenes to process data, train models, and return results.

##### Architectural Patterns & Design Principles
- Modular Design: Emphasize the modular nature of the neural network components. Each (numpy_network and tf_network) is encapsulated and could be updated independently.
- MVC-Like Structure: The “templates” (view) and “init_flask”/”network.py” (controller and model management logic) indicate an approach similar to MVC.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["Browser/Client"]:::ui

    subgraph "Frontend UI"
        direction TB
        Templates["Templates"]:::ui
        StaticAssets["Static Assets"]:::ui
    end

    subgraph "Flask Server"
        direction TB
        FlaskInit["Flask Initialization"]:::server
        NetworkRoutes["Network Routes"]:::server
    end

    subgraph "Neural Network Modules"
        direction TB
        subgraph "NumPy Neural Network Module"
            direction TB
            NumpyActivation["activation_neurons.py"]:::numpy
            NumpyBackprop["backpropagation.py"]:::numpy
            NumpyForward["forward_propagation.py"]:::numpy
            NumpyDataPrep["data_prep.py"]:::numpy
            NumpyParams["parameters.npy"]:::numpy
        end
        subgraph "TensorFlow Neural Network Module"
            direction TB
            TfSeqApi["seq_api.py"]:::tf
            TfDataPrep["data_prep.py"]:::tf
            TfCompile["compile.py"]:::tf
            TfPredict["tf_predict.py"]:::tf
            TfModel["ann_tf_fashmnist.h5"]:::tf
        end
    end

    subgraph "Configuration"
        direction TB
        Requirements["requirements.txt"]:::config
        License["LICENSE"]:::config
    end

    %% Connections from Browser to Frontend
    Browser -->|"requestUI"| Templates
    Browser -->|"loadAssets"| StaticAssets

    %% Frontend sends requests to Flask Initialization
    Templates -->|"submitRequest"| FlaskInit
    StaticAssets -->|"assetRequest"| FlaskInit

    %% Flask Server flow
    FlaskInit -->|"initializeRoutes"| NetworkRoutes

    %% Neural network invocations from Flask Server
    NetworkRoutes -->|"process:NumPy"| NumpyDataPrep
    NumpyParams -->|"returnResult:NumPy"| NetworkRoutes
    NetworkRoutes -->|"process:TF"| TfDataPrep
    TfModel -->|"returnResult:TF"| NetworkRoutes

    %% Response back to Browser
    NetworkRoutes -->|"sendResponse"| Browser

    %% Configuration dependencies
    Requirements ---|"dependency"| FlaskInit
    License ---|"config"| FlaskInit

    %% Styles
    classDef ui fill:#AED6F1,stroke:#1F618D,stroke-width:2px,color:black;
    classDef server fill:#A9DFBF,stroke:#28B463,stroke-width:2px,color:black;
    classDef numpy fill:#F9E79F,stroke:#F39C12,stroke-width:2px,color:black;
    classDef tf fill:#F5B7B1,stroke:#EC7063,stroke-width:2px,color:black;
    classDef config fill:#D2B4DE,stroke:#8E44AD,stroke-width:2px,color:black;

    %% Click Events for Frontend
    click Templates "https://github.com/ulichovick/ann_fashion_mnist/tree/master/templates"
    click StaticAssets "https://github.com/ulichovick/ann_fashion_mnist/tree/master/static"

    %% Click Events for Flask Server
    click FlaskInit "https://github.com/ulichovick/ann_fashion_mnist/tree/master/init_flask"
    click NetworkRoutes "https://github.com/ulichovick/ann_fashion_mnist/blob/master/network.py"

    %% Click Events for NumPy Neural Network Module
    click NumpyActivation "https://github.com/ulichovick/ann_fashion_mnist/blob/master/numpy_network/activation_neurons.py"
    click NumpyBackprop "https://github.com/ulichovick/ann_fashion_mnist/blob/master/numpy_network/backpropagation.py"
    click NumpyForward "https://github.com/ulichovick/ann_fashion_mnist/blob/master/numpy_network/forward_propagation.py"
    click NumpyDataPrep "https://github.com/ulichovick/ann_fashion_mnist/blob/master/numpy_network/data_prep.py"
    click NumpyParams "https://github.com/ulichovick/ann_fashion_mnist/blob/master/numpy_network/parameters.npy"

    %% Click Events for TensorFlow Neural Network Module
    click TfSeqApi "https://github.com/ulichovick/ann_fashion_mnist/blob/master/tf_network/seq_api.py"
    click TfDataPrep "https://github.com/ulichovick/ann_fashion_mnist/blob/master/tf_network/data_prep.py"
    click TfCompile "https://github.com/ulichovick/ann_fashion_mnist/blob/master/tf_network/compile.py"
    click TfPredict "https://github.com/ulichovick/ann_fashion_mnist/blob/master/tf_network/tf_predict.py"
    click TfModel "https://github.com/ulichovick/ann_fashion_mnist/blob/master/tf_network/ann_tf_fashmnist.h5"

    %% Click Events for Configuration
    click Requirements "https://github.com/ulichovick/ann_fashion_mnist/blob/master/requirements.txt"
    click License "https://github.com/ulichovick/ann_fashion_mnist/tree/master/LICENSE"
```
