# fabewe/mlp_c architecture

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

- Interactive diagram: https://gitdiagram.com/fabewe/mlp_c
- Repository: https://github.com/fabewe/mlp_c

## Overview

##### Project type and purpose
- This is a small C‐based machine learning tool—specifically, a command‐line implementation of a Multilayer Perceptron (MLP). Its primary purpose is to load training/test datasets, train an MLP model, and evaluate or infer results.

##### File structure
- Top‐level files:
- README.md – project description
- main.c – entry point, orchestration of data loading and MLP routines
- dataset.c/h – code to parse and manage datasets
- mlp.c/h – implementation of the MLP algorithm (network initialization, forward/backward passes, weight updates)
- datasets/ – folder containing sample .dat files (train/test data for different tasks)
- No separate “src” or “lib” folder—everything is at the root.
- No build scripts shown, but typical would be a Makefile (you may want to add one).

##### README for additional insights
- Very brief: “Highly based on a college assignment made in C++.”

a. Main components:
- CLI Interface (main.c)
- Data Loader module (dataset.c/h)
- MLP Engine (mlp.c/h)
- Data artifacts (datasets/*.dat)
- (Optional) Logging/Utils if implemented or to be added
b. Relationships & interactions:
1. User runs the binary with command‐line arguments (paths, hyperparameters).
2. main.c invokes Data Loader to read train/test files into in‐memory structures.
3. main.c initializes the MLP Engine (sets layer sizes, learning rate).
4. Training loop: main.c calls MLP forward‐pass, computes loss, then backward‐pass through the MLP Engine.
5. After training, main.c uses MLP Engine to run inference on test data.
6. Results are printed to console or written to a file (depending on implementation).
c. Architectural patterns/principles:
- Modular separation: data I/O separate from algorithm logic.
- Single Responsibility: each .c/.h pair handles one concern.
- Procedural layering: main orchestrates high‐level flow, lower layers provide services.
d. Key technologies/libraries:
- Standard C99 (stdlib, stdio, math)
- No external dependencies—pure C implementation.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core orchestration
    CLI["CLI Interface\n(main.c)"]:::orchestration
    click CLI "https://github.com/fabewe/mlp_c/blob/main/main.c"

    %% I/O components
    DataFiles(["Dataset Files\n(datasets/*.dat)"]):::io
    click DataFiles "https://github.com/fabewe/mlp_c/tree/main/datasets"
    DataLoader["Data Loader Module\n(dataset.c/h)"]:::io
    click DataLoader "https://github.com/fabewe/mlp_c/blob/main/dataset.c"
    click DataLoader "https://github.com/fabewe/mlp_c/blob/main/dataset.h"

    %% Core logic
    MLPEngine["MLP Engine\n(mlp.c/h)"]:::logic
    click MLPEngine "https://github.com/fabewe/mlp_c/blob/main/mlp.c"
    click MLPEngine "https://github.com/fabewe/mlp_c/blob/main/mlp.h"

    %% Documentation
    README["Project Description\n(README.md)"]:::docs
    click README "https://github.com/fabewe/mlp_c/blob/main/README.md"

    %% Extension points
    subgraph "Future Modules" 
        style FutureModules fill:none,stroke-dasharray: 5 5
        FutureMetrics["Metrics Module\n(placeholder)"]:::ext
        FutureOptimizers["Optimizers Module\n(placeholder)"]:::ext
        FutureActivations["Activation Functions\n(placeholder)"]:::ext
    end

    %% Flow sequence
    CLI -->|1. parse args, hyperparams| DataLoader
    DataLoader -->|2. parse .dat into matrices| CLI
    CLI -->|3. init network| MLPEngine
    CLI -->|4. train: forward/backward| MLPEngine
    CLI -->|5. inference on test data| MLPEngine
    MLPEngine -->|6. output results| CLI

    %% Documentation link
    CLI --> README

    %% Future integration
    MLPEngine -.-> FutureMetrics
    MLPEngine -.-> FutureOptimizers
    MLPEngine -.-> FutureActivations

    %% Legend
    subgraph Legend
      direction LR
      Orch["Orchestration"]:::orchestration
      IO["I/O Components"]:::io
      Logic["Core Logic"]:::logic
      Docs["Documentation"]:::docs
      Ext["Extension Points"]:::ext
    end

    classDef orchestration fill:#ffcc99,stroke:#e69500,color:#000;
    classDef io fill:#ccffcc,stroke:#33cc33,color:#000;
    classDef logic fill:#cce5ff,stroke:#3399ff,color:#000;
    classDef docs fill:#f2f2f2,stroke:#999,color:#000;
    classDef ext fill:none,stroke:#999,stroke-dasharray: 5 5,color:#000;
```
