# shahzaib3120/apollo-backend architecture

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

- Interactive diagram: https://gitdiagram.com/shahzaib3120/apollo-backend
- Repository: https://github.com/shahzaib3120/apollo-backend

## Overview

##### Project Type and Purpose
- This is a standalone C++17 machine-learning framework (“Apollo”) for building and training feed-forward neural networks with minimal dependencies (Eigen3 for linear algebra) and a modular code structure. It is not a web app or microservices suite but a library + CLI (and separate Qt GUI) that supports custom layers, activations, and loss functions, demonstrated by a spam-email binary classifier.

##### File Structure Analysis
Top-level:
- Apollo.h, CMakeLists.txt, main.cpp – core library header, build configuration, and the CLI entry point for training/evaluation.
- Dataset/ – sample CSVs and preprocessing scripts, used by Dataloader and Preprocessing modules.
- Layers/ – implementations of Layer base class plus derived Dense, Relu, Sigmoid, Softmax.
- Loss/ – namespace Loss with BCE and MSE functions and derivatives.
- Model/ – Model class that holds a vector<variant<Dense,Sigmoid>> of layers, orchestrates compile(), fit(), predict(), save/load.
- Preprocessing/ – functions for normalization, standardization, and spam-specific feature extraction.
- Utils/ – Dataloader class (splits CSV into train/val Eigen matrices) and linalg namespace (broadcast helpers).
- Tests/ – unit tests exercising layers, loss, model behavior.
- Models/ – sample serialized model outputs and CSVs for regression/spam testing.
- TODO.txt, images/, readme.md – documentation/artifacts.

##### Key Architectural Insights from README
- Modular “Layer” interface (forward/backward/update) → concrete layers via polymorphism + std::variant.
- Preprocessing & Dataloader separate concerns: feature extraction vs. I/O + batching.
- Utils.linalg provides low-level matrix ops beyond Eigen’s core.
- CMake orchestrates build; Eigen3 is the sole heavy dependency.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Data Layer
    Dataset["Dataset<br/>(.csv files & scripts)"]:::data
    Dataloader["Dataloader"]:::data
    Preprocessing["Preprocessing<br/>(normalization, feature extraction)"]:::data

    %% Core Computation
    Model["Model Engine<br/>compile(), fit(), predict(), saveModel()/loadModel()"]:::core
    Layers["Layer Library<br/>Layer interface, Dense, Relu, Sigmoid, Softmax"]:::core
    Loss["Loss Functions<br/>BCE, MSE"]:::core
    Linalg["Utils.linalg<br/>(broadcast helpers)"]:::core

    %% I/O & Persistence
    CLI["CLI (main.cpp)"]:::io
    Persistence["Persistence<br/>(Model Serialization)"]:::io
    Models["Models<br/>(sample outputs)"]:::io
    Docs["Documentation & Artifacts<br/>(readme.md, TODO.txt, images/)"]:::io

    %% Build & Dependencies
    Build["CMake & Eigen3"]:::build

    %% Testing
    Tests["Tests"]:::test

    %% Data Flow
    Dataset --> Dataloader --> Preprocessing --> Model
    %% CLI Interactions
    CLI --> Dataloader
    CLI --> Preprocessing
    CLI --> Model
    %% Model Structure
    Model --> Layers
    Model --> Loss
    Model --> Linalg
    Model --> Persistence
    Persistence --> Models
    %% Testing Hooks
    Tests --> Dataloader
    Tests --> Preprocessing
    Tests --> Model
    Tests --> Layers
    Tests --> Loss
    %% Build Dependency
    Build -.-> CLI
    Build -.-> Dataloader
    Build -.-> Preprocessing
    Build -.-> Model
    Build -.-> Layers
    Build -.-> Loss
    Build -.-> Linalg
    Build -.-> Tests

    %% Click Events
    click CLI "https://github.com/shahzaib3120/apollo-backend/blob/main/main.cpp"
    click Build "https://github.com/shahzaib3120/apollo-backend/blob/main/CMakeLists.txt"
    click Dataloader "https://github.com/shahzaib3120/apollo-backend/blob/main/Utils/Dataloader.h"
    click Preprocessing "https://github.com/shahzaib3120/apollo-backend/blob/main/Preprocessing/Preprocessing.h"
    click Model "https://github.com/shahzaib3120/apollo-backend/blob/main/Model/Model.h"
    click Layers "https://github.com/shahzaib3120/apollo-backend/blob/main/Layers/Layer.h"
    click Loss "https://github.com/shahzaib3120/apollo-backend/blob/main/Loss/Loss.h"
    click Linalg "https://github.com/shahzaib3120/apollo-backend/blob/main/Utils/linalg.h"
    click Tests "https://github.com/shahzaib3120/apollo-backend/blob/main/Tests/main.cpp"
    click Models "https://github.com/shahzaib3120/apollo-backend/tree/main/Models/"
    click Docs "https://github.com/shahzaib3120/apollo-backend/blob/main/readme.md"

    %% Styles
    classDef data fill:#D0E6FF,stroke:#4A90E2,color:#000;
    classDef core fill:#D0FFD0,stroke:#3C8031,color:#000;
    classDef io fill:#FFE7C0,stroke:#CB842E,color:#000;
    classDef build fill:#EEEEEE,stroke:#AAAAAA,color:#000;
    classDef test fill:#F3E6FF,stroke:#A45EC2,color:#000;
```
