# kashiyyy/autodartstouch_jules architecture

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

- Interactive diagram: https://gitdiagram.com/kashiyyy/autodartstouch_jules
- Repository: https://github.com/kashiyyy/autodartstouch_jules

## Overview

##### Project type and purpose
- AutodartsTouch is a kiosk-style touchscreen application built with Node.js/Electron, targeting a Raspberry Pi. It wraps web content (by default the Autodarts website) in a full-screen interface, provides an on-screen keyboard, toolbar, and settings page, and can switch between up to five configurable web “tabs.”

##### File structure
- Top-level scripts:
- AutodartsTouchInstall.sh – installation orchestration (system updates, Node.js install, Autodarts + AutodartsTouch fetch, config)
- AutodartsTouch/AutodartsTouch.sh – launch script for the Electron app
- Electron application folder (AutodartsTouch/):
- package.json & package-lock.json – Node.js/Electron dependencies and metadata
- main.js – Electron “main” process, creates BrowserWindow in kiosk mode, sets up IPC
- preload.js – exposes limited Node.js/IPC APIs to renderer pages
- index.html – primary UI shell with toolbar, tab container, WebView or BrowserView for web content
- settings.html – UI for adjusting volume, keyboard size, tab URLs
- keyboard-server.js – lightweight HTTP server serving the on-screen keyboard assets
- keyboard/index.html (plus supporting assets) – the HTML/JS/CSS for the pop-up keyboard

##### README for additional insights
- Describes kiosk mode behavior, toolbar controls (keyboard toggle, tabs, reload, settings), automatic on-screen keyboard on input focus, settings persistence and restart requirements.
- Indicates external dependency on Autodarts installation and the Autodarts web service.

##### Components
a. Main components:
- Operating System (Raspbian/Linux)
- Installation Script (AutodartsTouchInstall.sh)
- Electron Main Process (Node.js/Electron runtime)
- Renderer Processes:
– UI Renderer (index.html + toolbar + embedded web content view)
– Settings Renderer (settings.html)
– Keyboard Renderer (served by keyboard-server.js)
- Preload Script (preload.js) – IPC bridge & safe Node APIs
- Local Configuration Store (e.g. JSON file or Electron Store)
- External Services:
– Autodarts Web Service or any configured website URLs
– Optional local service pages
- Hardware Interfaces:
– Touchscreen input
– System volume control

b. Relationships & interactions:
- User taps → UI Renderer → IPC via preload → Main Process
- Main Process launches BrowserWindow (index.html) in kiosk mode, spawns keyboard HTTP server
- Renderer requests keyboard → WebView points to localhost:keyboard-port → keyboard-server responds with keyboard UI
- Settings adjustments → Settings Renderer IPC → Main Process writes config store → Signals renderer to apply or restart
- Tab switch / reload → IPC calls from UI Renderer → Main Process updates BrowserView or reloads WebView
- On boot/autostart → OS runs AutodartsTouch.sh → invokes Electron app

c. Architectural patterns & design principles:
- Electron multi-process model (main vs. renderers)
- IPC for secure separation of UI and privileged operations
- Modular renderer pages: index, settings, keyboard – each isolated
- Service-oriented keyboard server for dynamic injection

d. Key technologies/frameworks:
- Electron (desktop shell)
- Node.js (runtime for main process + keyboard-server.js)
- IPC + preload.js (context isolation)
- HTML/CSS/JS for renderers
- Bash scripts for installation & autostart configuration

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Setup Phase
    subgraph "Setup Phase"
        OS["Raspbian/Linux OS"]:::os
        InstallScript["Installation Script\n(AutodartsTouchInstall.sh)"]:::script
        AppFolder["AutodartsTouch Folder"]:::folder
        OS -->|"runs"| InstallScript
        InstallScript -->|"fetch & config"| AppFolder
    end

    %% Runtime Startup
    OS -->|"autostart"| LaunchScript["Autostart Launch Script\n(AutodartsTouch.sh)"]:::script
    LaunchScript -->|"launch"| MainProcess["Electron Main Process\nmain.js (--kiosk)"]:::core

    %% Electron Core
    subgraph "Electron Core"
        Preload["Preload Script\npreload.js"]:::core
        MainProcess --> Preload
    end

    %% Renderers
    subgraph "Renderers"
        UIRenderer["UI Renderer\nindex.html\n(toolbar + WebView)"]:::ui
        SettingsRenderer["Settings Renderer\nsettings.html"]:::ui
        MainProcess -->|"creates BrowserWindow"| UIRenderer
        MainProcess -->|"creates BrowserWindow"| SettingsRenderer
        UIRenderer -->|"IPC via preload"| Preload
        SettingsRenderer -->|"IPC via preload"| Preload
    end

    %% Auxiliary Service
    subgraph "Auxiliary Service"
        KeyboardServer["Keyboard HTTP Server\nkeyboard-server.js"]:::service
        KeyboardUI["On-Screen Keyboard UI\nkeyboard/index.html"]:::ui
        MainProcess -->|"spawn"| KeyboardServer
        UIRenderer -->|"GET /keyboard/index.html"| KeyboardServer
        KeyboardServer -->|"serves UI"| KeyboardUI
        KeyboardUI --> UIRenderer
    end

    %% Config & Dependencies
    subgraph "Config & Dependencies"
        PackageJSON["package.json"]:::config
        LockJSON["package-lock.json"]:::config
        ConfigStore["Local Configuration Store\n(JSON/Electron Store)"]:::config
        MainProcess -->|"reads/writes"| ConfigStore
        MainProcess --> PackageJSON
        PackageJSON --> LockJSON
    end

    %% External Dependencies
    subgraph "External Dependencies"
        ExternalWeb["Autodarts Web Service\n(or configurable URLs)"]:::external
        UIRenderer -->|"embedded WebView"| ExternalWeb
    end

    %% Click Events
    click InstallScript "https://github.com/kashiyyy/autodartstouch_jules/blob/main/AutodartsTouchInstall.sh"
    click LaunchScript "https://github.com/kashiyyy/autodartstouch_jules/blob/main/AutodartsTouch/AutodartsTouch.sh"
    click MainProcess "https://github.com/kashiyyy/autodartstouch_jules/blob/main/AutodartsTouch/main.js"
    click Preload "https://github.com/kashiyyy/autodartstouch_jules/blob/main/AutodartsTouch/preload.js"
    click UIRenderer "https://github.com/kashiyyy/autodartstouch_jules/blob/main/AutodartsTouch/index.html"
    click SettingsRenderer "https://github.com/kashiyyy/autodartstouch_jules/blob/main/AutodartsTouch/settings.html"
    click KeyboardServer "https://github.com/kashiyyy/autodartstouch_jules/blob/main/AutodartsTouch/keyboard-server.js"
    click KeyboardUI "https://github.com/kashiyyy/autodartstouch_jules/blob/main/AutodartsTouch/keyboard/index.html"
    click PackageJSON "https://github.com/kashiyyy/autodartstouch_jules/blob/main/AutodartsTouch/package.json"
    click LockJSON "https://github.com/kashiyyy/autodartstouch_jules/blob/main/AutodartsTouch/package-lock.json"

    %% Styles
    classDef os fill:#d3d3d3,stroke:#888;
    classDef script fill:#c0c0c0,stroke:#666;
    classDef folder fill:#e0e0e0,stroke:#999;
    classDef core fill:#add8e6,stroke:#31708f,color:#000;
    classDef ui fill:#90ee90,stroke:#3c763d,color:#000;
    classDef service fill:#ffa500,stroke:#8a6d3b,color:#000;
    classDef config fill:#f4a460,stroke:#a0522d,color:#000;
    classDef external fill:#f0f0f0,stroke:#aaa;
```
