# danielzlln/bachelorthesis_bs architecture

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

- Interactive diagram: https://gitdiagram.com/danielzlln/bachelorthesis_bs
- Repository: https://github.com/danielzlln/bachelorthesis_bs

## Overview

##### Project Type and Purpose
- This is a data‐science‐driven dashboard application (“Bachelorthesis”) whose goal is to forecast bicycle traffic in Münster, evaluate model performance and explainability, and present results via a local web dashboard.

##### High‐Level Components
a. Data Sources
- Raw traffic counts (XLSX files under src/)
- External CSV ingest (raw_github_data)
b. Data Processing Layer (data/)
- Cleaning scripts (clean_data.py, imputation.ipynb)
- Feature engineering (feature_engineering.py, Ferien_Feiertage calendar)
c. Model Training & Artifacts (notebooks/)
- Modeling notebooks for Prophet, LSTM, GRU, Random Forest, XGBoost
- Stored model artifacts and metadata (pickled scalers, trained models, best‐params CSVs, experiment logs)
d. Dashboard Backend (application.py)
- Flask or Dash application entry point
- Loads cleaned data, features, and serialized model artifacts
- Exposes REST endpoints (if any) and serves HTML/JS/CSS
e. Frontend (assets/)
- style.css, custom layout or Dash components
f. Presentation/Reports (reports/)
- Static report modules (optional)

##### Relationships & Data Flow
1. Raw Data → Data Processing
2. Cleaned Data → Model Training
3. Model Artifacts + Cleaned Data → Dashboard
4. Dashboard → User

##### Architectural Patterns & Design Principles
- Layered architecture separating:
- Data ingestion/processing
- Model training & artifact management
- Application server (dashboard backend)
- Presentation layer (UI assets)
- Reusable modules (data/ and feature_engineering.py can be invoked by both notebooks and application.py)
- Artifacts versioning: notebooks/model_metadata stores parameters and pickles for reproducibility

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Raw Data Storage" 
        direction TB
        RDDir["src/"]:::data
        ZN2018["Zaehlstelle_Neutor_2018_Stundenauswertung.xlsx"]:::data
        ZN2019["Zaehlstelle_Neutor_2019_Stundenauswertung.xlsx"]:::data
        ZN2020["Zaehlstelle_Neutor_2020_Stundenauswertung.xlsx"]:::data
        ZN2021["Zaehlstelle_Neutor_2021_Stundenauswertung.xlsx"]:::data
        ZN2022["Zaehlstelle_Neutor_2022_Stundenauswertung.xlsx"]:::data
        RAWCSV["raw_github_data/2023-01.csv"]:::data
    end

    subgraph "Data Processing Layer" 
        direction TB
        DataDir["data/"]:::processing
        CleanPy["clean_data.py"]:::processing
        CleanNB["clean_data.ipynb"]:::processing
        CleanDash["clean_data_dash.py"]:::processing
        FE["feature_engineering.py"]:::processing
        Ferien["ferien_feiertage.ipynb"]:::processing
        Impute["imputation.ipynb"]:::processing
    end

    subgraph "Model Training" 
        direction TB
        NotebooksDir["notebooks/"]:::training
        PropNB["modelling_prophet.ipynb"]:::training
        LSTMNB["modelling_lstm.ipynb"]:::training
        GRUNB["modelling_gru.ipynb"]:::training
        RFNB["modelling_rf_xgb.ipynb"]:::training
    end

    subgraph "Model Artifacts & Metadata" 
        direction TB
        ArtifactDir["notebooks/model_metadata/"]:::artifacts
        BPGRU["best_params_gru.csv"]:::artifacts
        BPLSTM["best_params_lstm.csv"]:::artifacts
        ColNames["column_names.csv"]:::artifacts
        ELGRU["experiment_log_gru.csv"]:::artifacts
        ELLSTM["experiment_log_lstm.csv"]:::artifacts
        PRED["lstm_gru_predictions.csv"]:::artifacts
        MR["model_results.csv"]:::artifacts
        PMETA["prophet_metadata.json"]:::artifacts
        PPROP["train_prophet.pkl"]:::artifacts
        EPROP["encoder_prophet.pkl"]:::artifacts
        subgraph "Scalers" 
            direction TB
            S_X_GRU["scaler_X_gru.pkl"]:::artifacts
            S_Y_GRU["scaler_y_gru.pkl"]:::artifacts
            S_X_LSTM["scaler_X_lstm.pkl"]:::artifacts
            S_Y_LSTM["scaler_y_lstm.pkl"]:::artifacts
        end
    end

    subgraph "Serving Layer"
        direction TB
        App["Dashboard Server\n(application.py)"]:::serving
    end

    subgraph "Frontend Assets"
        direction TB
        AssetsDir["assets/"]:::ui
        StyleCSS["style.css"]:::ui
    end

    ReportsDir["reports/"]:::external
    DB["DB (placeholder)"]:::db
    User["User Interface\n(Browser)"]:::ui

    %% Connections
    RDDir -->|"raw XLSX & CSV"| DataDir
    ZN2018 --> DataDir
    ZN2019 --> DataDir
    ZN2020 --> DataDir
    ZN2021 --> DataDir
    ZN2022 --> DataDir
    RAWCSV --> DataDir

    DataDir --> CleanPy
    CleanPy --> FE
    FE -->|"cleaned_features.pkl"| NotebooksDir

    NotebooksDir --> PropNB
    NotebooksDir --> LSTMNB
    NotebooksDir --> GRUNB
    NotebooksDir --> RFNB

    PropNB --> ArtifactDir
    LSTMNB --> ArtifactDir
    GRUNB --> ArtifactDir
    RFNB --> ArtifactDir

    ArtifactDir --> App
    DataDir --> App
    App --> AssetsDir
    AssetsDir --> StyleCSS
    App --> User

    ReportsDir -.-> DataDir

    %% Click Events
    click RDDir "https://github.com/danielzlln/bachelorthesis_bs/tree/main/src/"
    click ZN2018 "https://github.com/danielzlln/bachelorthesis_bs/blob/main/src/Zaehlstelle_Neutor_2018_Stundenauswertung.xlsx"
    click ZN2019 "https://github.com/danielzlln/bachelorthesis_bs/blob/main/src/Zaehlstelle_Neutor_2019_Stundenauswertung.xlsx"
    click ZN2020 "https://github.com/danielzlln/bachelorthesis_bs/blob/main/src/Zaehlstelle_Neutor_2020_Stundenauswertung.xlsx"
    click ZN2021 "https://github.com/danielzlln/bachelorthesis_bs/blob/main/src/Zaehlstelle_Neutor_2021_Stundenauswertung.xlsx"
    click ZN2022 "https://github.com/danielzlln/bachelorthesis_bs/blob/main/src/Zaehlstelle_Neutor_2022_Stundenauswertung.xlsx"
    click RAWCSV "https://github.com/danielzlln/bachelorthesis_bs/blob/main/src/raw_github_data/2023-01.csv"

    click DataDir "https://github.com/danielzlln/bachelorthesis_bs/tree/main/data/"
    click CleanPy "https://github.com/danielzlln/bachelorthesis_bs/blob/main/data/clean_data.py"
    click CleanNB "https://github.com/danielzlln/bachelorthesis_bs/blob/main/data/clean_data.ipynb"
    click CleanDash "https://github.com/danielzlln/bachelorthesis_bs/blob/main/data/clean_data_dash.py"
    click FE "https://github.com/danielzlln/bachelorthesis_bs/blob/main/data/feature_engineering.py"
    click Ferien "https://github.com/danielzlln/bachelorthesis_bs/blob/main/data/ferien_feiertage.ipynb"
    click Impute "https://github.com/danielzlln/bachelorthesis_bs/blob/main/data/imputation.ipynb"

    click NotebooksDir "https://github.com/danielzlln/bachelorthesis_bs/tree/main/notebooks/"
    click PropNB "https://github.com/danielzlln/bachelorthesis_bs/blob/main/notebooks/modelling_prophet.ipynb"
    click LSTMNB "https://github.com/danielzlln/bachelorthesis_bs/blob/main/notebooks/modelling_lstm.ipynb"
    click GRUNB "https://github.com/danielzlln/bachelorthesis_bs/blob/main/notebooks/modelling_gru.ipynb"
    click RFNB "https://github.com/danielzlln/bachelorthesis_bs/blob/main/notebooks/modelling_rf_xgb.ipynb"

    click ArtifactDir "https://github.com/danielzlln/bachelorthesis_bs/tree/main/notebooks/model_metadata/"
    click BPGRU "https://github.com/danielzlln/bachelorthesis_bs/blob/main/notebooks/model_metadata/best_params_gru.csv"
    click BPLSTM "https://github.com/danielzlln/bachelorthesis_bs/blob/main/notebooks/model_metadata/best_params_lstm.csv"
    click ColNames "https://github.com/danielzlln/bachelorthesis_bs/blob/main/notebooks/model_metadata/column_names.csv"
    click ELGRU "https://github.com/danielzlln/bachelorthesis_bs/blob/main/notebooks/model_metadata/experiment_log_gru.csv"
    click ELLSTM "https://github.com/danielzlln/bachelorthesis_bs/blob/main/notebooks/model_metadata/experiment_log_lstm.csv"
    click PRED "https://github.com/danielzlln/bachelorthesis_bs/blob/main/notebooks/model_metadata/lstm_gru_predictions.csv"
    click MR "https://github.com/danielzlln/bachelorthesis_bs/blob/main/notebooks/model_metadata/model_results.csv"
    click PMETA "https://github.com/danielzlln/bachelorthesis_bs/blob/main/notebooks/model_metadata/prophet_metadata.json"
    click PPROP "https://github.com/danielzlln/bachelorthesis_bs/blob/main/notebooks/model_metadata/train_prophet.pkl"
    click EPROP "https://github.com/danielzlln/bachelorthesis_bs/blob/main/notebooks/model_metadata/encoder_prophet.pkl"
    click S_X_GRU "https://github.com/danielzlln/bachelorthesis_bs/blob/main/notebooks/scaler_gru/scaler_X_gru.pkl"
    click S_Y_GRU "https://github.com/danielzlln/bachelorthesis_bs/blob/main/notebooks/scaler_gru/scaler_y_gru.pkl"
    click S_X_LSTM "https://github.com/danielzlln/bachelorthesis_bs/blob/main/notebooks/scaler_lstm/scaler_X_lstm.pkl"
    click S_Y_LSTM "https://github.com/danielzlln/bachelorthesis_bs/blob/main/notebooks/scaler_lstm/scaler_y_lstm.pkl"

    click App "https://github.com/danielzlln/bachelorthesis_bs/blob/main/application.py"
    click AssetsDir "https://github.com/danielzlln/bachelorthesis_bs/tree/main/assets/"
    click StyleCSS "https://github.com/danielzlln/bachelorthesis_bs/blob/main/assets/style.css"
    click ReportsDir "https://github.com/danielzlln/bachelorthesis_bs/tree/main/reports/"

    %% Styles
    classDef data fill:#E0F7FA,stroke:#0288D1,color:#000
    classDef processing fill:#E8F5E9,stroke:#388E3C,color:#000
    classDef training fill:#FFF9C4,stroke:#F9A825,color:#000
    classDef artifacts fill:#DCEDC8,stroke:#689F38,color:#000
    classDef serving fill:#FFE0B2,stroke:#FB8C00,color:#000
    classDef ui fill:#F3E5F5,stroke:#8E24AA,color:#000
    classDef external fill:#FFFFFF,stroke:#BDBDBD,stroke-dasharray: 5 5,color:#000
    classDef db fill:#FFFFFF,stroke:#9E9E9E,stroke-dasharray: 5 5,color:#000
```
