# brotherz11/tfg_24 architecture

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

- Interactive diagram: https://gitdiagram.com/brotherz11/tfg_24
- Repository: https://github.com/brotherz11/tfg_24

## Overview

##### Project type and purpose
- This is a full-stack, Python-based web application (a “TFG” or capstone project) built on Flask.
- Its primary function appears to be audio transcription and evaluation.  The app offers three transcription models (basic, onsets, “transkun”) and uses Magenta’s open-source music/ML library for underlying model implementations.

##### File structure
- Top-level:
- app.py – Flask entry point
- app/ – your application package
- environment.yml, requirements.txt – dependency definitions
- magenta/ – vendored Magenta library (hundreds of ML models, pipelines, utilities)
- app/ contains:
- models/ – wrappers for three transcription approaches
- utils/ – preprocessing (spectrograms, audio cleaning), downloading, evaluation, scoring
- routes.py – HTTP endpoints
- static/ & templates/ – CSS and the index.html UI
- No database folder is present – likely no persistent datastore.

##### README
- Minimal: “Este es mi proyecto de TFG…” – no additional architecture notes.
- We infer architecture solely from file layout and naming.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Frontend Layer
    subgraph "Client" 
        Browser["Browser"]:::frontend
        Template["index.html"]:::frontend
        CSS["style.css"]:::frontend
    end

    %% Configuration Files
    subgraph "Configuration" 
        EnvYml["environment.yml"]:::config
        ReqTxt["requirements.txt"]:::config
    end

    %% Application Layer
    subgraph "app/"
        %% Server & Controllers
        subgraph "Server & Controllers"
            FlaskApp["app.py"]:::server
            Routes["routes.py"]:::server
        end

        %% Business Logic Layer
        subgraph "Business Logic"
            subgraph "Models"
                BasicModel["transcription_basic.py"]:::logic
                OnsetsModel["transcription_onsets.py"]:::logic
                TranskunModel["transcription_transkun.py"]:::logic
            end
            subgraph "Utils"
                Clean["clean.py"]:::logic
                SpectrogramService["spectogram.py"]:::logic
                Preprocess["preprocess.py"]:::logic
                Download["download.py"]:::logic
                Evaluate["evaluate_transcriptions.py"]:::logic
                ScoreGen["generate_score.py"]:::logic
            end
        end
    end

    %% Vendor Layer
    subgraph "Vendor Libraries"
        Magenta["Magenta ML Library"]:::vendor
    end

    %% Data Flow
    Browser -->|"loads UI"| Template
    Browser -->|"loads CSS"| CSS
    Browser -->|"POST audio file"| Routes
    Routes -->|"save temp file"| Routes
    Routes -->|"call clean"| Clean
    Clean -->|"call spectrogram"| SpectrogramService
    SpectrogramService -->|"call preprocess"| Preprocess
    Preprocess -->|"choose model wrapper"| BasicModel
    Preprocess -->|"choose model wrapper"| OnsetsModel
    Preprocess -->|"choose model wrapper"| TranskunModel
    BasicModel -->|"invoke Magenta API"| Magenta
    OnsetsModel -->|"invoke Magenta API"| Magenta
    TranskunModel -->|"invoke Magenta API"| Magenta
    Magenta -->|"return transcription data"| BasicModel
    Magenta -->|"return transcription data"| OnsetsModel
    Magenta -->|"return transcription data"| TranskunModel
    BasicModel -->|"send to evaluation"| Evaluate
    OnsetsModel -->|"send to evaluation"| Evaluate
    TranskunModel -->|"send to evaluation"| Evaluate
    Evaluate -->|"compute score"| ScoreGen
    ScoreGen -->|"return score"| Routes
    Routes -->|"response JSON or render"| Browser

    %% Configuration dependencies
    FlaskApp --> EnvYml
    FlaskApp --> ReqTxt

    %% Click Events
    click Template "https://github.com/brotherz11/tfg_24/blob/main/app/templates/index.html"
    click CSS "https://github.com/brotherz11/tfg_24/blob/main/app/static/style.css"
    click FlaskApp "https://github.com/brotherz11/tfg_24/blob/main/app.py"
    click Routes "https://github.com/brotherz11/tfg_24/blob/main/app/routes.py"
    click BasicModel "https://github.com/brotherz11/tfg_24/blob/main/app/models/transcription_basic.py"
    click OnsetsModel "https://github.com/brotherz11/tfg_24/blob/main/app/models/transcription_onsets.py"
    click TranskunModel "https://github.com/brotherz11/tfg_24/blob/main/app/models/transcription_transkun.py"
    click Clean "https://github.com/brotherz11/tfg_24/blob/main/app/utils/clean.py"
    click SpectrogramService "https://github.com/brotherz11/tfg_24/blob/main/app/utils/spectogram.py"
    click Preprocess "https://github.com/brotherz11/tfg_24/blob/main/app/utils/preprocess.py"
    click Download "https://github.com/brotherz11/tfg_24/blob/main/app/utils/download.py"
    click Evaluate "https://github.com/brotherz11/tfg_24/blob/main/app/utils/evaluate_transcriptions.py"
    click ScoreGen "https://github.com/brotherz11/tfg_24/blob/main/app/utils/generate_score.py"
    click Magenta "https://github.com/brotherz11/tfg_24/tree/main/magenta/"
    click EnvYml "https://github.com/brotherz11/tfg_24/blob/main/environment.yml"
    click ReqTxt "https://github.com/brotherz11/tfg_24/blob/main/requirements.txt"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#000;
    classDef server fill:#90EE90,stroke:#000;
    classDef logic fill:#FFA500,stroke:#000;
    classDef vendor fill:#D3D3D3,stroke:#000;
    classDef config fill:#DDA0DD,stroke:#000;
```
