# shujanislam/vehicleneuralnetwork architecture

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

- Interactive diagram: https://gitdiagram.com/shujanislam/vehicleneuralnetwork
- Repository: https://github.com/shujanislam/vehicleneuralnetwork

## Overview

##### Project Type & Purpose
- Type: Command-line, single-process C++ feedforward neural-network tool
- Purpose: Classify input sentences as “Car” or “Bike” using a tiny neural net
- Key Characteristics:
– No client/server layers
– Modular separation of data loading, model training, and inference

##### File Structure
- main.cpp
– Entry point; handles user I/O and orchestrates the pipeline
- headers/DataSet.hpp
– Loads and preprocesses training data; maps words to indices/weights
- headers/TrainModel.hpp
– Implements the feedforward + weight-update logic for training
- headers/DetectType.hpp
– Runs the trained network in inference mode to predict Car vs. Bike

##### Core Components & Responsibilities
- CLI Module (main.cpp)
– Reads user sentences
– Calls DataSet to build or refresh word-weight maps
– Triggers TrainModel (optional or on first run)
– Invokes DetectType for each new input
– Displays prediction to console
- DataSet Module
– Vocabulary management
– Example-sentence loading & vectorization
– Interface: getFeatureVector(sentence)
- TrainModel Module
– Network topology: input layer (words) → hidden layer (2 neurons × 2 categories) → output layer
– Weight matrices & bias vectors
– Forward pass + simple gradient updates
– Interface: train(featureMatrix, labels) → weightStore
- DetectType Module
– Uses stored weights for feedforward inference
– Returns category with highest activation

##### Relationships & Data Flow
- Sequence:
1. User enters sentence → main.cpp
2. main.cpp → DataSet: preprocess & vectorize
3. main.cpp → DetectType: feed vector through network
4. DetectType → output label back to main.cpp
- Training (one-time or on demand):
1. main.cpp → DataSet: load training examples
2. main.cpp → TrainModel: compute & store weights
3. TrainModel → persistent in-memory store (could be file in future)

##### Architectural Patterns & Design Principles
- Single responsibility per module (I/O vs. data vs. training vs. inference)
- Layered structure within the neural network (input → hidden → output)
- Minimal external dependencies—pure C++ STL

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CLI Module
    subgraph "CLI Module"
        CLI["CLI (main.cpp)"]:::cli
    end

    %% Data Handling
    subgraph "Data Handling"
        DS["DataSet"]:::data
    end

    %% Training Flow
    subgraph "Training Flow"
        TM["TrainModel"]:::train
        subgraph "Neural Network Topology"
            W1["Weight Matrix W1"]
            B1["Bias Vector b1"]
            Hidden["Hidden Layer\n(2 neurons × 2 categories)"]
            W2["Weight Matrix W2"]
            B2["Bias Vector b2"]
        end
        Store["Weight Store"]:::store
    end

    %% Inference Flow
    subgraph "Inference Flow"
        DT["DetectType"]:::infer
    end

    %% Data Flow Arrows
    CLI -->|"vectorize(sentence)"| DS
    DS -->|"featureMatrix,labels"| TM
    TM -->|"saveWeights()"| Store
    CLI -->|"predict(vector)"| DT
    DT -->|"loadWeights()"| Store
    DS -->|"featureVector"| DT

    %% Click Events
    click CLI "https://github.com/shujanislam/vehicleneuralnetwork/blob/main/main.cpp"
    click DS "https://github.com/shujanislam/vehicleneuralnetwork/blob/main/headers/DataSet.hpp"
    click TM "https://github.com/shujanislam/vehicleneuralnetwork/blob/main/headers/TrainModel.hpp"
    click DT "https://github.com/shujanislam/vehicleneuralnetwork/blob/main/headers/DetectType.hpp"

    %% Styles
    classDef cli fill:#E3F2FD,stroke:#2196F3,stroke-width:2px;
    classDef data fill:#E8F5E9,stroke:#4CAF50,stroke-width:2px;
    classDef train fill:#FFF3E0,stroke:#FB8C00,stroke-width:2px;
    classDef infer fill:#F3E5F5,stroke:#9C27B0,stroke-width:2px;
    classDef store fill:#ECEFF1,stroke:#607D8B,stroke-width:2px;
```
