# scriptedbits/emulator-auto-downloads architecture

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

- Interactive diagram: https://gitdiagram.com/scriptedbits/emulator-auto-downloads
- Repository: https://github.com/scriptedbits/emulator-auto-downloads

## Overview

##### Project Type and Purpose
- This project is an automation tool designed to download the latest versions of various gaming emulators from public sources. It’s not a full-fledged application with a frontend/back-end separation but rather a multi-version command-line tool (with executables, PowerShell scripts, and batch files) that automates file downloads.
- The main purpose is to save time by automatically grabbing emulator updates, meaning the design focuses on file operations, version management, and scheduling (via GitHub Actions).

##### File Structure
- Top-level directories include:
- .github: Contains configurations for issues and GitHub Actions workflows. This shows continuous integration (CI) support for updating the README and potentially automating releases.
- 3.x and 4.x directories: Hold different versions of emulator download executables and scripts. This indicates version management is an architectural component.
- Various config files like emulator_info.json and emulators.json: These files likely maintain data about supported emulators or download sources.
- update_readme.py: Suggests a utility script to refresh documentation, integrating the latest release information.
- These elements imply that the core system logic is built around versioned binaries, metadata configuration, and automation scripts.

##### Key Components
a. Version Management Modules:
- 3.x and 4.x components as distinct modules that house different builds (with executables like EAD.exe, EAD-3.exe, etc.).
- How these versioned binaries are maintained separately while still conforming to the same overall operational logic.

b. Metadata/Data Sources:
- Emulator_info.json and emulators.json as sources of configuration/meta information that drive which emulators to download and from where.
- That these JSON files feed into the download logic, perhaps through parsers or configuration readers.

c. Download/Automation Engine:
- Core logic responsible for automating downloads (this is the heart of the project). Even though the code itself isn’t explicitly structured in a “backend” directory, it is implied by the scripts and executables distributed in the version folders.
- That this module interprets the configuration data and orchestrates the downloading process.

d. GitHub Integration and CI/CD:
- GitHub Actions workflows (.github/workflows/update-readme.yml) that automate processes like updating the README or handling version releases.
- Optionally, include the issue templates as part of repository management, although they aren’t part of the runtime architecture.

e. Utility Tools and Scripts:
- Update_readme.py as a utility that synchronizes release metadata into project documentation.
- This utility back to the GitHub workflows, indicating a cyclic dependency for automated documentation updates.

f. External Dependencies:
- That the tool operates on Windows (Windows 10/11 requirement) and interacts with online emulator sources, which should be shown as external endpoints.

##### Relationships and Data Flow
- The GitHub Actions workflow triggers the update_readme.py script, which updates the README based on current data.
- The main automation engine reads data from the JSON configuration files.
- The version-specific directories (3.x and 4.x) represent output artifacts (i.e., various builds) that are either deployed or executed based on user needs.
- That the automation engine has a one-way data flow: from configuration (JSON sources) → processing/download tasks → releasing binaries (in versioned directories).
- Optionally, indicate user interaction: a user downloads the correct executable (from 3.x or 4.x) based on their environment.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The project neatly separates configurations, downloadable executables, and automation utilities.
- Versioning: Distinct directories for different versions imply a clean modular structure to handle version-specific changes.
- CI/CD Integration: GitHub workflows automate and streamline documentation and possibly release processes.
- Automation: The project uses scripting (Python and batch/PowerShell) to automate repetitive tasks.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Configuration"
        json1["emulator_info.json"]:::config
        json2["emulators.json"]:::config
    end

    subgraph "Automation Engine"
        engine["Download/Automation Engine"]:::engine
    end

    subgraph "Version Artifacts"
        artifact3["3.x Artifacts"]:::version
        artifact4["4.x Artifacts"]:::version
    end

    subgraph "CI/CD & Documentation"
        ghWorkflow["GitHub Actions Workflow"]:::ci
        updateScript["update_readme.py"]:::ci
        readme["README Documentation"]:::ci
    end

    externalSources["Online Emulator Sources"]:::external

    %% Data flow from configuration to automation engine
    json1 --> engine
    json2 --> engine

    %% Automation engine communicates with external sources
    engine -->|"download"| externalSources

    %% Automation engine produces versioned artifacts
    engine --> artifact3
    engine --> artifact4

    %% CI/CD flow for documentation updates
    ghWorkflow -->|"triggers"| updateScript
    updateScript -->|"updates"| readme

    %% Click Events
    click json1 "https://github.com/scriptedbits/emulator-auto-downloads/blob/main/emulator_info.json"
    click json2 "https://github.com/scriptedbits/emulator-auto-downloads/blob/main/emulators.json"
    click artifact3 "https://github.com/scriptedbits/emulator-auto-downloads/blob/main/3.x"
    click artifact4 "https://github.com/scriptedbits/emulator-auto-downloads/blob/main/4.x"
    click ghWorkflow "https://github.com/scriptedbits/emulator-auto-downloads/blob/main/.github/workflows/update-readme.yml"
    click updateScript "https://github.com/scriptedbits/emulator-auto-downloads/blob/main/update_readme.py"

    %% Styles
    classDef config fill:#FFCC00,stroke:#333,stroke-width:2px;
    classDef engine fill:#66CCFF,stroke:#333,stroke-width:2px;
    classDef version fill:#CCFFCC,stroke:#333,stroke-width:2px;
    classDef ci fill:#FF9999,stroke:#333,stroke-width:2px;
    classDef external fill:#CCCCFF,stroke:#333,stroke-width:2px;
```
