# vzepec/miyoo_downloader_spanish architecture

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

- Interactive diagram: https://gitdiagram.com/vzepec/miyoo_downloader_spanish
- Repository: https://github.com/vzepec/miyoo_downloader_spanish

## Overview

##### Main Components
- User Environment/Terminal: This includes the Miyoo Mini Plus (or Linux terminal) from where the user executes commands.
- Main Script (main.sh): Acts as the central controller. On startup, it displays the platform selector, handles updates, and directs the workflow.
- Downloader Scripts (located under the “downloaders” directory): Each script (e.g., download_gb_spa.sh, download_nes_spa.sh, etc.) corresponds to a different gaming platform. They manage the paginated ROM listing and downloading logic.
- ROM Storage Directory: Although not directly part of the project files, the README indicates that downloaded ROMs are placed in directories like “../Roms/[Plataforma]”.
- External Service – Internet Archive: The ROM files are downloaded from this service. The system interacts with an external Internet resource.
- Supporting Elements: Auxiliary files (cookies.txt for session management or authentication, configuration files, etc.) and the Gifs folder which provides demo images for documentation.

##### Relationships and Data Flow
- The user interacts with the system via a console (Terminal app on Miyoo or Linux).
- When the user executes main.sh, it checks for updates and initializes the user interface (platform selection).
- The chosen downloader script then:
- Fetches the list of available ROMs (with pagination)
- Receives and processes user input for navigation, searching, or file selection.
- Initiates ROM downloads by reaching out to the Internet Archive server, potentially handling cookies or session data.
- Downloaded ROMs are then stored in the designated ROM folder structure “../Roms/[Plataforma]”.

##### Important Architectural Details
- Procedural Script-Oriented Design: This project uses a procedural approach with a central control (main.sh) and multiple subordinate scripts for handling different ROM download tasks.
- Separation of Concerns: Although it’s a single-script application collection, there is a clear separation between the user interface (main.sh) and the platform-specific downloading logic (in individual scripts).
- Update Mechanism: The main script includes functionality for updating itself and other scripts, emphasizing maintainability.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Components
    UT["User Terminal (Miyoo / Linux)"]:::terminal
    main_sh["main.sh (Controller)"]:::controller
    IA["Internet Archive"]:::external
    ROM["Local ROM Storage (../Roms/[Plataforma])"]:::storage
    SE["Supporting Elements"]:::support

    %% Supporting Elements Subgraph
    subgraph "Supporting Elements"
        gifs["Demo Assets (Gifs)"]:::support
        cookies["Session Management (cookies.txt)"]:::support
    end

    %% Downloader Scripts Subgraph
    subgraph "Downloader Scripts"
        gb["download_gb_spa.sh (GB)"]:::downloader
        gba["download_gba_spa.sh (GBA)"]:::downloader
        gbc["download_gbc_spa.sh (GBC)"]:::downloader
        nds["download_nds_spa.sh (NDS)"]:::downloader
        nes["download_nes_spa.sh (NES)"]:::downloader
        psx["download_psx_spa.sh (PSX)"]:::downloader
        snes["download_snes_spa.sh (SNES)"]:::downloader
    end

    %% Flow Connections
    UT -->|"UserInput&CommandExecution"| main_sh
    main_sh -->|"SelectPlatform"| gb
    main_sh -->|"SelectPlatform"| gba
    main_sh -->|"SelectPlatform"| gbc
    main_sh -->|"SelectPlatform"| nds
    main_sh -->|"SelectPlatform"| nes
    main_sh -->|"SelectPlatform"| psx
    main_sh -->|"SelectPlatform"| snes

    %% Update mechanism loop on main.sh
    main_sh -- "Check/DownloadUpdates" --> main_sh

    %% Downloader Scripts interactions
    gb -->|"ROMFileRequest"| IA
    gba -->|"ROMFileRequest"| IA
    gbc -->|"ROMFileRequest"| IA
    nds -->|"ROMFileRequest"| IA
    nes -->|"ROMFileRequest"| IA
    psx -->|"ROMFileRequest"| IA
    snes -->|"ROMFileRequest"| IA

    gb -->|"SaveDownloadedROM"| ROM
    gba -->|"SaveDownloadedROM"| ROM
    gbc -->|"SaveDownloadedROM"| ROM
    nds -->|"SaveDownloadedROM"| ROM
    nes -->|"SaveDownloadedROM"| ROM
    psx -->|"SaveDownloadedROM"| ROM
    snes -->|"SaveDownloadedROM"| ROM

    %% Main script supporting elements interactions
    main_sh -->|"LoadSession"| cookies
    main_sh -->|"DisplayDemoAssets"| gifs

    %% Styles
    classDef terminal fill:#D6E9C6,stroke:#4CAF50,stroke-width:2px;
    classDef controller fill:#FFF3CD,stroke:#FFC107,stroke-width:2px;
    classDef downloader fill:#D1ECF1,stroke:#17A2B8,stroke-width:2px;
    classDef external fill:#F8D7DA,stroke:#DC3545,stroke-width:2px;
    classDef storage fill:#E2E3E5,stroke:#6C757D,stroke-width:2px;
    classDef support fill:#E2E5E5,stroke:#343A40,stroke-width:2px;

    %% Click Events
    click main_sh "https://github.com/vzepec/miyoo_downloader_spanish/blob/main/main.sh"
    click gb "https://github.com/vzepec/miyoo_downloader_spanish/blob/main/downloaders/download_gb_spa.sh"
    click gba "https://github.com/vzepec/miyoo_downloader_spanish/blob/main/downloaders/download_gba_spa.sh"
    click gbc "https://github.com/vzepec/miyoo_downloader_spanish/blob/main/downloaders/download_gbc_spa.sh"
    click nds "https://github.com/vzepec/miyoo_downloader_spanish/blob/main/downloaders/download_nds_spa.sh"
    click nes "https://github.com/vzepec/miyoo_downloader_spanish/blob/main/downloaders/download_nes_spa.sh"
    click psx "https://github.com/vzepec/miyoo_downloader_spanish/blob/main/downloaders/download_psx_spa.sh"
    click snes "https://github.com/vzepec/miyoo_downloader_spanish/blob/main/downloaders/download_snes_spa.sh"
    click gifs "https://github.com/vzepec/miyoo_downloader_spanish/tree/main/Gifs"
    click cookies "https://github.com/vzepec/miyoo_downloader_spanish/blob/main/cookies.txt"
```
