# nulldev/senpa-io-client architecture

> Architecture diagram of the GitHub repository nulldev/senpa-io-client, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nulldev/senpa-io-client
- Repository: https://github.com/nulldev/senpa-io-client

## Overview

##### Project Type and Purpose
- This is an Electron-based desktop application (“Senpa.io Client”) that serves as the official cross-platform UI for interacting with the Senpa.io service.
- It bundles a Node.js “main” process and one or more Chromium “renderer” processes into installers (Windows, macOS, Linux).

##### File-Structure Analysis
- Top-level configs:
- electron-builder.yml, package.json → build and packaging configuration
- .eslintrc, .editorconfig → coding style
- /src
- app.js → Electron main-process entrypoint
- /modules → core logic modules (cli parsing, RPC handler, window builder)
- /layout → static UI assets for splash screen (HTML/CSS)
- /scripts → renderer-side scripts (preload.js for safe IPC, splash.js for UI behavior)

##### README Insights
- Describes build steps: NodeJS + npm, “npm start” invokes Electron, “npm run build” triggers electron-builder.
- No deeply detailed architectural description, so we reverse-engineer from the code layout.

##### Main Components & Their Relationships
a. Electron Main Process (src/app.js)
- Parses CLI switches (cliSwitches.js)
- Initializes RPC Handler (rpcHandler.js) for IPC and backend calls
- Uses Window Builder module (windowBuilder.js) to create BrowserWindow instances
b. Renderer Processes
- Splash window: loads splash.html + splash.css, runs splash.js (injected via preload.js)
- Later windows (e.g., main UI) follow the same pattern via windowBuilder
c. Preload Script (src/scripts/preload.js)
- Exposes a limited IPC API to the renderer for secure communications with the main process
d. External Service: Senpa.io backend APIs
- Accessed through rpcHandler (could be HTTP or WebSocket under the hood)

##### Architectural Patterns & Design Principles
- Process isolation: Main vs. Renderer
- Module decomposition: each concern (CLI, window creation, RPC) in its own file
- Secure IPC: preload script exposes minimal, well-scoped API to UI

##### Technology Stack
- Electron (Node.js + Chromium)
- JavaScript ES modules
- HTML & CSS for UI
- electron-builder for packaging

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interaction
    User["User"]:::external
    User -->|"interacts"| SplashProc

    %% Renderer Process: Splash
    subgraph "Renderer Process: Splash"
        direction TB
        SplashProc["Splash Renderer"]:::electron
        SplashHTML["splash.html"]:::electron
        SplashCSS["splash.css"]:::electron
        SplashJS["splash.js"]:::electron
        Preload["preload.js (IPC Bridge)"]:::electron
    end

    %% Electron Main Process
    Main["Electron Main Process<br/>(app.js)"]:::electron

    %% Internal Modules
    subgraph "Main Process Modules"
        direction TB
        CLI["CLI Switches Module"]:::modules
        WindowBuilder["Window Builder Module"]:::modules
        RPC["RPC Handler Module"]:::modules
    end

    %% External Service
    SenpaAPI["Senpa.io Backend API"]:::externalService

    %% Build & CI/CD
    subgraph "Build & Packaging (CI/CD)" 
        direction TB
        BuildConfig["electron-builder.yml"]:::build
        NPMConfig["package.json"]:::build
        CICD[".github/workflows/build.yml"]:::build
    end

    %% Relationships
    SplashProc -->|"loads HTML/CSS/JS"| SplashHTML
    SplashProc --> SplashCSS
    SplashProc --> SplashJS
    SplashProc -->|"uses safe IPC"| Preload
    Preload -->|"ipcRenderer.send()"| Main
    Main -->|"parse CLI switches"| CLI
    Main -->|"create windows"| WindowBuilder
    Main -->|"initialize RPC handler"| RPC
    Main -->|"load renderer"| SplashProc
    RPC -->|"HTTP/WebSocket"| SenpaAPI

    %% Click Events
    click Main "https://github.com/nulldev/senpa-io-client/blob/master/src/app.js"
    click CLI "https://github.com/nulldev/senpa-io-client/blob/master/src/modules/cliSwitches.js"
    click RPC "https://github.com/nulldev/senpa-io-client/blob/master/src/modules/rpcHandler.js"
    click WindowBuilder "https://github.com/nulldev/senpa-io-client/blob/master/src/modules/windowBuilder.js"
    click SplashHTML "https://github.com/nulldev/senpa-io-client/blob/master/src/layout/splash.html"
    click SplashCSS "https://github.com/nulldev/senpa-io-client/blob/master/src/layout/splash.css"
    click SplashJS "https://github.com/nulldev/senpa-io-client/blob/master/src/scripts/splash.js"
    click Preload "https://github.com/nulldev/senpa-io-client/blob/master/src/scripts/preload.js"
    click BuildConfig "https://github.com/nulldev/senpa-io-client/blob/master/electron-builder.yml"
    click NPMConfig "https://github.com/nulldev/senpa-io-client/blob/master/package.json"
    click CICD "https://github.com/nulldev/senpa-io-client/blob/master/.github/workflows/build.yml"

    %% Styles
    classDef electron fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef modules fill:#98FB98,stroke:#000,stroke-width:1px
    classDef externalService fill:#FFA500,stroke:#000,stroke-width:1px
    classDef build fill:#D3D3D3,stroke:#000,stroke-width:1px
    classDef external fill:#FFFACD,stroke:#000,stroke-width:1px
```
