# mhdimo/bws-v2 architecture

> Architecture diagram of the GitHub repository mhdimo/bws-v2, 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/mhdimo/bws-v2
- Repository: https://github.com/mhdimo/bws-v2

## Overview

##### Project Overview and Main Components
- Project Type & Purpose: BWS-V2 is a C++ application that calculates player rankings by parsing player data, performing date calculations, and using a simple neural network within the weight generator to predict dynamic weights. It also implements caching of these predictions.
- Main Components:
- Data Input: Player data file (src/player_data.txt) which contains raw data.
- Parsing Module: Handled by the Parser (Parser.hpp/Parser.cpp) that processes the input file into structured Player objects (Player.hpp/Player.cpp).
- Date & Utility Modules: Date and DateUtils (Date.hpp, Date.cpp, DateUtils.hpp, DateUtils.cpp) support time-based calculations.
- Math & Neural Network Module: MathUtils (MathUtils.hpp/MathUtils.cpp) and WeightGenerator (WeightGenerator.hpp/WeightGenerator.cpp) that includes the neural network logic responsible for predicting the weights, as well as applying dynamic weight calculations.
- Output Mechanism: Results are saved in results.txt (and weight predictions cached in weight_cache.txt).

##### Relationships and Data Flow
- Data flows from the external source (player_data.txt) into the Parser component.
- The Parser transforms this data into Player objects, which are then used by the neural network contained in the WeightGenerator.
- DateUtils and MathUtils support computations across modules.
- Results are output to results.txt and weight predictions are stored in weight_cache.txt.
- The overall application logic is initiated via main.cpp in the src directory.

##### Architectural Patterns and Design Principles
- Modular Design: Each major function (parsing, date handling, neural network weight prediction) is encapsulated in its module, making it easier to understand and test separately.
- Separation of Concerns: Input parsing, computation (including dynamic weight prediction), and result output are clearly separated.
- Cache Mechanism: Explicit component for caching weight predictions to optimize future calculations.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Control Layer
    subgraph "Control Layer"
        Main["main.cpp"]:::entry
    end

    %% Input & Parsing Layer
    subgraph "Input & Parsing Layer"
        DataInput["Player Data File"]:::external
        Parser["Parser Module"]:::module
        Player["Player Model"]:::module
    end

    %% Utilities Layer
    subgraph "Utilities Layer"
        Date["Date"]:::utility
        DateUtils["DateUtils"]:::utility
        MathUtils["MathUtils"]:::utility
    end

    %% Processing Layer
    subgraph "Processing Layer"
        WeightGenerator["Weight Generator (Neural Network+Dynamic Weights)"]:::module
    end

    %% Output Layer
    subgraph "Output Layer"
        Results["Results File"]:::storage
        Cache["Weight Cache File"]:::storage
    end

    %% Testing Suite
    subgraph "Testing Suite"
        Tests["Unit Tests"]:::test
    end

    %% Connections
    Main -->|"initiates"| DataInput
    Main -->|"initiates"| Parser
    DataInput -->|"parsedBy"| Parser
    Parser -->|"creates"| Player
    Player -->|"processedBy"| WeightGenerator
    MathUtils -->|"supports"| WeightGenerator
    DateUtils -->|"provides"| WeightGenerator
    WeightGenerator -->|"writesOutput"| Results
    WeightGenerator -->|"cachesWeights"| Cache

    Tests ---|"tests"| Parser
    Tests ---|"tests"| Player
    Tests ---|"tests"| WeightGenerator

    %% Click Events
    click DataInput "https://github.com/mhdimo/bws-v2/blob/main/src/player_data.txt"
    click Parser "https://github.com/mhdimo/bws-v2/blob/main/include/Parser.hpp"
    click Parser "https://github.com/mhdimo/bws-v2/blob/main/src/Parser.cpp"
    click Player "https://github.com/mhdimo/bws-v2/blob/main/include/Player.hpp"
    click Player "https://github.com/mhdimo/bws-v2/blob/main/src/Player.cpp"
    click Date "https://github.com/mhdimo/bws-v2/blob/main/include/Date.hpp"
    click Date "https://github.com/mhdimo/bws-v2/blob/main/src/Date.cpp"
    click DateUtils "https://github.com/mhdimo/bws-v2/blob/main/include/DateUtils.hpp"
    click DateUtils "https://github.com/mhdimo/bws-v2/blob/main/src/DateUtils.cpp"
    click MathUtils "https://github.com/mhdimo/bws-v2/blob/main/include/MathUtils.hpp"
    click MathUtils "https://github.com/mhdimo/bws-v2/blob/main/src/MathUtils.cpp"
    click WeightGenerator "https://github.com/mhdimo/bws-v2/blob/main/include/WeightGenerator.hpp"
    click WeightGenerator "https://github.com/mhdimo/bws-v2/blob/main/src/WeightGenerator.cpp"
    click Results "https://github.com/mhdimo/bws-v2/blob/main/src/results.txt"
    click Cache "https://github.com/mhdimo/bws-v2/blob/main/src/weight_cache.txt"
    click Main "https://github.com/mhdimo/bws-v2/blob/main/src/main.cpp"
    click Tests "https://github.com/mhdimo/bws-v2/tree/main/tests"

    %% Styles
    classDef entry fill:#ffcc00,stroke:#333,stroke-width:2px
    classDef module fill:#bbf,stroke:#333,stroke-width:2px
    classDef external fill:#cfc,stroke:#333,stroke-width:2px
    classDef utility fill:#fcf,stroke:#333,stroke-width:2px
    classDef storage fill:#cff,stroke:#333,stroke-width:2px
    classDef test fill:#fdd,stroke:#333,stroke-width:2px
```
