# skyyyy0920/mtnet architecture

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

- Interactive diagram: https://gitdiagram.com/skyyyy0920/mtnet
- Repository: https://github.com/skyyyy0920/mtnet

## Overview

##### Overall Project Type and Purpose
- This project is a research prototype for a specialized recommendation engine using deep learning.
- The primary goal is to predict the next POI (point-of-interest) by learning from users’ check-in data, with an emphasis on time slot behaviors as captured by the Mobility Tree.
- The system involves data ingestion, model training, evaluation, and visualization of results.

##### Major Components
a. Configuration Management (config.py)
- Central file for setting hyperparameters, training parameters, and possibly dataset configurations.
b. Data Layer (dataset.py, dataset folder)
- Data ingestion and preprocessing are handled here. The dataset folder (with subfolders, e.g., NYC) contains train/val/test CSV files representing user check-in data.
c. Model Definition (model.py)
- This file defines the MTNet architecture which leverages the Mobility Tree for learning time slot preferences.
d. Training and Execution (main.py)
- Acts as the orchestrator: reads the configuration, loads the dataset, initializes the model, and runs the training and evaluation cycles.
e. Utility Functions (utils.py)
- Supporting functions used across the project (e.g., metrics, data transformations).
f. Visualization and Plotting (plot_MTNet.py; visualization directory with multiple plotting modules)
- Responsible for generating visual outputs (charts, graphs) to showcase model performance, user embedding analysis, time slot distributions, etc.

##### Interactions and Data Flow
- The “Data Loader” (which fetches and preprocesses the dataset).
- The “Training Controller” (which initiates model training with the data and configuration settings).
- The “Training Controller” then coordinates:
- Feeding the preprocessed data into the “Model” defined in model.py.
- Running the training loop where model updates occur.
- Once training is complete (or during evaluation), the “Training Controller” passes results to the “Visualization” module.
- The visualization modules (plot_MTNet.py and the files in the visualization directory) generate plots (line charts, period plots, user embedding plots, etc.) to analyze and demonstrate the results.
- The “Utilities” module supports various operations across the data processing, training, and visualization stages.

##### Architectural Patterns & Design Principles
- Modularity: Each key function (config, dataset loading, model definition, training, evaluation, visualization) is encapsulated in its own file/module.
- Pipeline Flow: The design follows a pipeline-like architecture from configuration → data ingestion → model training/evaluation → visualization.
- Reusability: Utility functions and visualization modules are separated into their own components, making them reusable across multiple experiments.
- Research-driven structure: Emphasize that while the design is monolithic (as common in research prototypes), attention is given to separation of concerns for enhancement and future extension.

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Configuration (config.py)"]:::configClass
    G["Utilities (utils.py)"]:::utilsClass

    subgraph "Data/Preprocessing"
        C["Dataset Folder (dataset/ + NYC CSVs)"]:::dataClass
        B["Data Loader (dataset.py)"]:::dataClass
        C -->|"reads_from"| B
    end

    D["Training Controller (main.py)"]:::trainingClass
    E["Model (MTNet in model.py)"]:::modelClass

    subgraph "Visualization & Analysis"
        F1["Visualization Script (plot_MTNet.py)"]:::visClass
        F2["Visualization Modules (visualization/)"]:::visClass
        F1 -->|"passes_output"| F2
    end

    A -->|"supplies"| B
    A -->|"supplies"| D
    B -->|"feeds"| D
    D -->|"trains"| E
    D -->|"outputs"| F1

    G ---|"supports"| B
    G ---|"supports"| D
    G ---|"supports"| F1
    G ---|"supports"| F2

    classDef configClass fill:#f9c,stroke:#333,stroke-width:2px;
    classDef dataClass fill:#ccf,stroke:#333,stroke-width:2px;
    classDef trainingClass fill:#fc9,stroke:#333,stroke-width:2px;
    classDef modelClass fill:#cfc,stroke:#333,stroke-width:2px;
    classDef visClass fill:#cff,stroke:#333,stroke-width:2px;
    classDef utilsClass fill:#eee,stroke:#333,stroke-dasharray: 5 5;

    click A "https://github.com/skyyyy0920/mtnet/blob/main/config.py"
    click B "https://github.com/skyyyy0920/mtnet/blob/main/dataset.py"
    click C "https://github.com/skyyyy0920/mtnet/tree/main/dataset/"
    click D "https://github.com/skyyyy0920/mtnet/blob/main/main.py"
    click E "https://github.com/skyyyy0920/mtnet/blob/main/model.py"
    click F1 "https://github.com/skyyyy0920/mtnet/blob/main/plot_MTNet.py"
    click F2 "https://github.com/skyyyy0920/mtnet/tree/main/visualization/"
    click G "https://github.com/skyyyy0920/mtnet/blob/main/utils.py"
```
