# juangpartida/osrs-toolkit architecture

> Architecture diagram of the GitHub repository juangpartida/osrs-toolkit, 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/juangpartida/osrs-toolkit
- Repository: https://github.com/juangpartida/osrs-toolkit

## Overview

##### Project Type and Purpose
- The project is a local desktop application built using Electron.js that tracks various aspects of Old School RuneScape (OSRS).
- It uses a combination of Node.js for the Electron main process and Python-based microservices communicating via ZeroMQ to fetch data (e.g., quest progress, player stats, hi-scores, and GE prices) from external OSRS APIs.

##### File Structure
- Top-level Files:
- main.js – Serves as the Electron main process responsible for application startup and inter-process communications.
- package.json & package-lock.json – Manage Node.js dependencies and scripts.
- Renderer Directory:
- renderer/index.html – Defines the primary layout of the UI.
- renderer/renderer.js – Contains frontend logic associated with rendering and possibly interfacing with the backend.
- Microservices Directory:
- Contains multiple Python scripts (quest-tracker.py, osrs-skills.py, hi-score.py, ge-tracker.py) that operate as individual services.
- Styles:
- styles/styles.css – Manages the UI styling.
- Additional Test Files:
- test.html and test.py – Likely used for testing purposes.

##### README for Additional Insights
- The README clearly defines that the project uses Electron.js for the desktop environment and ZeroMQ for inter-process communication among the Node.js backend and Python microservices.
- It also lists the major features and the external APIs each microservice interacts with (OSRS Wiki API, OSRS Hiscores, GE Market API).

a. Main Components:
- Electron Main Process (main.js): Handles the lifecycle of the application and spawns or manages renderer processes.
- Renderer Process (frontend): Comprises index.html and renderer.js which together form the UI.
- Python Microservices:
- Quest Tracker Service (quest-tracker.py)
- OSRS Skills/Player Stats Service (osrs-skills.py)
- Hi-Score Tracker Service (hi-score.py)
- GE Tracker Service (ge-tracker.py)
- External APIs:
- OSRS Wiki API (for quest information)
- OSRS Hiscores/API (for player statistics and hi-score comparisons)
- GE Market API (for price tracking)

b. Relationships and Interactions:
- The Electron main process initiates and coordinates communication between the renderer and the microservices.
- The Renderer process sends requests (or receives data notifications) via the main process to the backend.
- The Python microservices operate as independent components and use ZeroMQ to handle communication. They fetch and process data from external OSRS APIs.
- Data flows from external APIs to microservices and then via ZeroMQ to the Node.js backend, which may in turn pass data to the renderer for display to the user.
- Optionally, include pathways for testing (represented by test.html/test.py) if they play a role in the architectural overview.

c. Architectural Patterns and Design Principles:
- Separation of concerns: UI (renderer) is completely separated from the business logic and external data-fetch services (microservices).
- Microservices architecture: Each service is isolated and focused on a specific domain (e.g., quest tracking, stat tracking) to enable modular development and testing.
- Use of Electron.js implies a hybrid desktop app architecture that leverages web technologies (HTML, CSS, JavaScript) for the frontend.
- ZeroMQ serves as the messaging middleware for decoupled, asynchronous communications between the main Node.js process and Python scripts.

d. Relevant Technologies and Frameworks:
- Frontend: Electron.js, HTML, CSS, JavaScript (renderer process)
- Backend: Node.js (main.js), ZeroMQ for messaging
- Microservices: Python-based scripts handling domain-specific functionalities
- External APIs: OSRS Wiki API, OSRS Hiscores API, GE Market API

##### Final Assembly
- To clearly mark communication mechanisms, especially labeling the use of ZeroMQ between the Node.js and Python components.
- Notes or callouts to indicate where additional configurations (like dependency management via package.json) may influence the deployment or development process.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Electron Main Process
    subgraph "Electron App"
        EM["Electron Main Process (main.js)"]:::electron
    end

    %% Renderer Process Subgraph
    subgraph "Renderer Process"
        RI["index.html"]:::electron
        RJ["renderer.js"]:::electron
        UI["UI Styling (styles.css)"]:::electron
        RI -->|"loads"| RJ
    end

    %% Python Microservices Subgraph
    subgraph "Python Microservices"
        QT["Quest Tracker Service (quest-tracker.py)"]:::microservice
        OS["OSRS Skills Service (osrs-skills.py)"]:::microservice
        HS["Hi-Score Tracker Service (hi-score.py)"]:::microservice
        GE["GE Tracker Service (ge-tracker.py)"]:::microservice
    end

    %% External APIs Subgraph
    subgraph "External APIs"
        Wiki["OSRS Wiki API"]:::external
        Hiscores["OSRS Hiscores API"]:::external
        GEAPI["GE Market API"]:::external
    end

    %% Test Components Subgraph
    subgraph "Test Components"
        TH["Test UI (test.html)"]:::test
        TP["Test Service (test.py)"]:::test
    end

    %% Connections between Renderer and Electron Main Process
    RI -->|"sendsRequest"| EM
    EM -->|"updatesUI"| RI

    %% Connection from Renderer to UI Styling
    RI ---|"loadsStyling"| UI

    %% Communications between Electron Main Process and Python Microservices (using ZeroMQ)
    EM -->|"ZeroMQ_send"| QT
    EM -->|"ZeroMQ_send"| OS
    EM -->|"ZeroMQ_send"| HS
    EM -->|"ZeroMQ_send"| GE

    QT -->|"ZeroMQ_response"| EM
    OS -->|"ZeroMQ_response"| EM
    HS -->|"ZeroMQ_response"| EM
    GE -->|"ZeroMQ_response"| EM

    %% Microservices fetching data from External APIs
    QT -->|"fetch"| Wiki
    OS -->|"fetch"| Hiscores
    HS -->|"fetch"| Hiscores
    GE -->|"fetch"| GEAPI

    %% Test Components interactions (optional)
    RI ---|"loadTests"| TH
    EM ---|"runTests"| TP

    %% Styles
    classDef electron fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef microservice fill:#90EE90,stroke:#000,stroke-width:2px;
    classDef external fill:#FFB6C1,stroke:#000,stroke-width:2px;
    classDef test fill:#FFD700,stroke:#000,stroke-width:2px;

    %% Click Events
    click EM "https://github.com/juangpartida/osrs-toolkit/blob/main/main.js"
    click RI "https://github.com/juangpartida/osrs-toolkit/blob/main/renderer/index.html"
    click RJ "https://github.com/juangpartida/osrs-toolkit/blob/main/renderer/renderer.js"
    click UI "https://github.com/juangpartida/osrs-toolkit/blob/main/styles/styles.css"
    click QT "https://github.com/juangpartida/osrs-toolkit/blob/main/microservices/quest-tracker.py"
    click OS "https://github.com/juangpartida/osrs-toolkit/blob/main/microservices/osrs-skills.py"
    click HS "https://github.com/juangpartida/osrs-toolkit/blob/main/microservices/hi-score.py"
    click GE "https://github.com/juangpartida/osrs-toolkit/blob/main/microservices/ge-tracker.py"
    click TH "https://github.com/juangpartida/osrs-toolkit/blob/main/test.html"
    click TP "https://github.com/juangpartida/osrs-toolkit/blob/main/test.py"
```
