# doansilinh/nckh-generative-ai architecture

> Architecture diagram of the GitHub repository doansilinh/nckh-generative-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/doansilinh/nckh-generative-ai
- Repository: https://github.com/doansilinh/nckh-generative-ai

## Overview

##### Main Components
- Data Acquisition & Preprocessing:
- get_data.py: Responsible for downloading data from Kaggle.
- load_data.py: Used to load and possibly preprocess the data.
- Model Components:
- generator_model.py: Defines the generator part of the GAN.
- discriminator_model.py: Defines the discriminator part.
- gan_model.py: Likely integrates the generator and discriminator into the complete GAN.
- Training & Testing:
- train_model.py: Handles the training process (using parameters from setting.py).
- test_model.py: Evaluates the trained model and outputs results.
- Settings & Configuration:
- setting.py: Contains key hyperparameters (e.g., number of epochs, learning rates) for both generator and discriminator.
- Output:
- models (as referenced in the README, even if not in file tree): Folder that stores model checkpoints.
- images folder: Stores output images from model testing.

- Data flow should start with the “Data Acquisition” component via get_data.py, followed by data importation using load_data.py.
- Once data is available, the “Training” module starts with train_model.py, which utilizes the GAN model (constructed from generator_model.py, discriminator_model.py, gan_model.py) and uses configuration from setting.py.
- After training, the “Testing” process in test_model.py picks up the trained model (or models saved into the models directory) and produces sample outputs stored in the images folder.
- External dependency on Kaggle for data download and on the Python libraries listed in requirements.txt.

##### Important Architectural Patterns and Design Principles
- Modular design: Each script (data, model, training, testing) represents a distinct module or layer.
- Separation of Concerns: Data handling is kept separate from model definitions and training logic.
- Configurability: settings (hyperparameters, number of epochs, learning rates) are externalized in setting.py, allowing easy tuning and experiments.

##### Relevant Technologies and Components
- Python is the primary language.
- Libraries specified in requirements.txt (likely including deep learning frameworks such as TensorFlow, PyTorch, or similar; check the file for exact libraries).
- Use of external datasets from Kaggle (data acquisition script).
- Storage of trained models and output images as stated in the README.

##### Elements
- Clear labels for each module:
– Data Acquisition: get_data.py
– Data Loading/Preprocessing: load_data.py
– Model Definitions: generator_model.py, discriminator_model.py, gan_model.py
– Training: train_model.py (with settings.py for hyperparameters)
– Testing: test_model.py
– Outputs: models (checkpoints) and images (generated samples)
– Data operations and data sources (e.g., external data from Kaggle)
– Model components (machine learning model definitions)
– Execution flows (training vs. testing)
- Dependencies on external libraries and note that pip install –r requirements.txt installs these dependencies.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Nodes
    KAGGLE["Kaggle (External)"]:::external
    DEPENDENCIES["requirements.txt"]:::dependency

    %% Data Acquisition & Preprocessing Subgraph
    subgraph "Data Acquisition & Preprocessing"
        GET_DATA["get_data.py"]:::data
        LOAD_DATA["load_data.py"]:::data
    end

    %% Model Definitions Subgraph
    subgraph "Model Definitions"
        GEN_MODEL["generator_model.py"]:::model
        DISC_MODEL["discriminator_model.py"]:::model
        GAN_MODEL["gan_model.py"]:::model
    end

    %% Training Phase Subgraph
    subgraph "Training Phase"
        TRAIN_MODEL["train_model.py"]:::training
        SETTING["setting.py"]:::config
    end

    %% Testing Phase Subgraph
    subgraph "Testing Phase"
        TEST_MODEL["test_model.py"]:::testing
    end

    %% Outputs Subgraph
    subgraph "Outputs"
        MODELS_OUTPUT["Models (Checkpoints)"]:::outputs
        IMAGES_OUTPUT["Images"]:::outputs
    end

    %% Flow connections
    KAGGLE -->|"downloads data"| GET_DATA
    GET_DATA -->|"data file"| LOAD_DATA
    LOAD_DATA -->|"preprocessed data"| TRAIN_MODEL
    SETTING -->|"configuration"| TRAIN_MODEL
    GEN_MODEL -->|"model used"| TRAIN_MODEL
    DISC_MODEL -->|"model used"| TRAIN_MODEL
    GAN_MODEL -->|"integration"| TRAIN_MODEL
    DEPENDENCIES -->|"dependencies"| TRAIN_MODEL
    DEPENDENCIES -->|"dependencies"| TEST_MODEL
    TRAIN_MODEL -->|"trained model"| TEST_MODEL
    TEST_MODEL -->|"saves checkpoints"| MODELS_OUTPUT
    TEST_MODEL -->|"generates outputs"| IMAGES_OUTPUT

    %% Click Events
    click GET_DATA "https://github.com/doansilinh/nckh-generative-ai/blob/main/src/get_data.py"
    click LOAD_DATA "https://github.com/doansilinh/nckh-generative-ai/blob/main/src/load_data.py"
    click GEN_MODEL "https://github.com/doansilinh/nckh-generative-ai/blob/main/src/generator_model.py"
    click DISC_MODEL "https://github.com/doansilinh/nckh-generative-ai/blob/main/src/discriminator_model.py"
    click GAN_MODEL "https://github.com/doansilinh/nckh-generative-ai/blob/main/src/gan_model.py"
    click TRAIN_MODEL "https://github.com/doansilinh/nckh-generative-ai/blob/main/src/train_model.py"
    click SETTING "https://github.com/doansilinh/nckh-generative-ai/blob/main/src/setting.py"
    click TEST_MODEL "https://github.com/doansilinh/nckh-generative-ai/blob/main/src/test_model.py"
    click IMAGES_OUTPUT "https://github.com/doansilinh/nckh-generative-ai/tree/main/images"
    click DEPENDENCIES "https://github.com/doansilinh/nckh-generative-ai/blob/main/requirements.txt"

    %% Styles
    classDef data fill:#8fbc8f,stroke:#2f4f4f,stroke-width:2px;
    classDef model fill:#add8e6,stroke:#00008b,stroke-width:2px;
    classDef training fill:#ffa500,stroke:#ff8c00,stroke-width:2px;
    classDef testing fill:#dda0dd,stroke:#800080,stroke-width:2px;
    classDef outputs fill:#ffb6c1,stroke:#ff69b4,stroke-width:2px;
    classDef external fill:#d3d3d3,stroke:#696969,stroke-width:2px;
    classDef config fill:#f0e68c,stroke:#bdb76b,stroke-width:2px;
    classDef dependency fill:#ffc0cb,stroke:#ff69b4,stroke-width:2px;
```
