# jzar21/tfg architecture

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

- Interactive diagram: https://gitdiagram.com/jzar21/tfg
- Repository: https://github.com/jzar21/tfg

## Overview

##### Main Components
- Data Input & Preprocessing: Represented by modules such as data_loaders.py. This part is responsible for reading and pre-processing MRI images.
- Model Creation: Shown by create_model.py along with architectural directories (MedicalNet and resnets_3d). These components define and construct the deep learning models used for age estimation.
- Training & Optimization: Captured by train.py, main.py, and early_stopper.py. This section handles the training loop, optimization, and early stopping mechanisms.
- Dependencies & Environment Setup: Represent the external libraries and frameworks (as listed in requirements.txt and indicated by the PyTorch badge in the README). This could also include the virtual environment setup for reproducibility.

##### Relationships & Interactions
- Modular Dependencies: Show that the model construction (create_model.py) utilizes both MedicalNet and resnets_3d modules, indicating a layered design where specific network architectures are encapsulated in their own directories.

##### Architectural Patterns & Design Principles
- Separation of Concerns: Emphasize that each major functionality (data loading, model building, training) is isolated in separate modules/files.
- Modularity & Reusability: Note the use of dedicated directories for model definitions (MedicalNet, resnets_3d) which could facilitate experimentation with different architectures.
- Extensibility: The clear separation in the code structure (e.g., different files for early stopping and model creation) makes it easier to enhance or modify specific parts without affecting the rest.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Data Input & Preprocessing
    subgraph "Data Input & Preprocessing"
        DL["Data Loader"]:::data
    end

    %% Model Creation
    subgraph "Model Creation"
        CM["Model Constructor"]:::model
        MN["MedicalNet"]:::model
        RS["resnets_3d"]:::model
    end

    %% Training & Optimization
    subgraph "Training & Optimization"
        T["Train: train.py"]:::training
        M["Main: main.py"]:::training
        ES["Early Stopping"]:::training
    end

    %% Dependencies & Environment Setup
    subgraph "Dependencies & Environment Setup"
        DEP["Dependencies / Libraries"]:::dependency
    end

    %% Data Flow & Interactions
    DL -->|"preprocessedMRI"| CM
    CM -->|"invokes"| MN
    CM -->|"invokes"| RS
    CM -->|"modelWeights"| T
    CM -->|"modelWeights"| M
    DL -->|"feedsData"| T
    DL -->|"feedsData"| M
    T -->|"monitors"| ES
    M -->|"monitors"| ES
    DEP -->|"provides"| CM
    DEP -->|"provides"| T
    DEP -->|"provides"| M

    %% Click Events
    click DL "https://github.com/jzar21/tfg/blob/main/codigo/data_loaders.py"
    click CM "https://github.com/jzar21/tfg/blob/main/codigo/create_model.py"
    click MN "https://github.com/jzar21/tfg/tree/main/codigo/MedicalNet"
    click RS "https://github.com/jzar21/tfg/tree/main/codigo/resnets_3d"
    click T "https://github.com/jzar21/tfg/blob/main/codigo/train.py"
    click M "https://github.com/jzar21/tfg/blob/main/codigo/main.py"
    click ES "https://github.com/jzar21/tfg/blob/main/codigo/early_stopper.py"
    click DEP "https://github.com/jzar21/tfg/blob/main/requirements.txt"

    %% Styles
    classDef data fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef model fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef training fill:#FFA500,stroke:#000,stroke-width:1px;
    classDef dependency fill:#DDA0DD,stroke:#000,stroke-width:1px;
```
