# getstation/desktop-app architecture

> Architecture diagram of the GitHub repository getstation/desktop-app, 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/getstation/desktop-app
- Repository: https://github.com/getstation/desktop-app

## Overview

##### Main Components
- Electron Main Process – This is where startup, window management, inter-process communication (IPC), auto-updater, and service orchestration live (evident in files within packages/app/src like main.ts, services, and persistence modules).
- Renderer Process / UI Layer – Contains all the view components, dialogs, notifications, and state management (observed in the 'src' directory which spans components, containers, and Redux store). Include sub-sections for features like the bang interface, dock, context menus, and themes.
- Application Store – A separate package (packages/appstore) that provides the integrated “app store” functionality, complete with its own React components, GraphQL schemas, and Redux management.
- SDK – Another package (packages/sdk) that exposes APIs and consumers for other modules or possibly external integrations.
- Services and Plugins – Modules within packages/app/src/services and packages/app/src/plugins that provide cross-cutting functionalities like authentication, auto-updater, notifications, and other integration tasks.
- Persistence and Database – Modules for managing and migrating the local SQLite DB (as described in the “Migrations” section and under packages/app/src/persistence) that store state and historical data.
- Development and Build Tools – Scripts, configuration files, CI-related workflows, and documentation that support development tasks as well as environment configuration.

##### Relationships and Interactions
- How the Electron Main Process initializes the application, loads windows/subwindows, and registers services.
- How the Renderer Processes connect to the main process via IPC channels and utilize shared libraries (for example, via the @getstation/sdk).
- Integration between UI components (React/Redux based) and underlying business logic (services, plugins, persistence modules).
- Demonstrate how the App Store component sits as a separate module while integrating with the main application via inter-package dependencies.
- Build, packaging, and native module rebuilding scripts (for cross-platform compatibility using tools like electron-builder and scripts in the “scripts” directory).

##### Architectural Patterns and Technologies
- Electron’s Multi-Process Architecture: Separate out processes for main and renderer, with dedicated communication channels (using ipcMain, ipcRenderer, and possibly sockets for auto-update events).
- Modular Monorepo Structure: Emphasize clear boundaries between packages (app, appstore, sdk) and their own dependency graphs.
- Redux & GraphQL: Acknowledge the usage of Redux for state management and GraphQL for API transactions (as referenced by the graphql and apollo client devtools sections).
- Asynchronous Service Operations: Many services (such as auto-updater, authentication, and window management) work asynchronously and may use sagas (as seen in the test and src directories).

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "System/Integration Layer"
        mainProc["Electron Main Process"]:::system
    end

    subgraph "Business Logic Layer"
        services["Services"]:::business
        plugins["Plugins"]:::business
        persistence["Persistence & Database"]:::business
        sdk["SDK"]:::business
        appStore["Application Store"]:::business
    end

    subgraph "Presentation Layer"
        renderer["Renderer Process / UI Layer"]:::presentation
    end

    devtools["Dev & Build Tools"]:::tool

    renderer -->|"IPC"| mainProc
    mainProc -->|"initServices"| services
    mainProc -->|"loadPlugins"| plugins
    mainProc -->|"DBOperations"| persistence
    mainProc -->|"appStoreIPC"| appStore
    mainProc -->|"SDKintegration"| sdk
    renderer -->|"SDKcalls"| sdk
    sdk -->|"stateUpdates"| renderer
    appStore -->|"UIIntegration"| renderer
    devtools -->|"buildScripts"| mainProc
    devtools -->|"nativeRebuild"| services

    click mainProc "https://github.com/getstation/desktop-app/blob/main/packages/app/src/main.ts"
    click renderer "https://github.com/getstation/desktop-app/tree/main/packages/app/src"
    click appStore "https://github.com/getstation/desktop-app/tree/main/packages/appstore"
    click sdk "https://github.com/getstation/desktop-app/tree/main/packages/sdk"
    click services "https://github.com/getstation/desktop-app/tree/main/packages/app/src/services"
    click plugins "https://github.com/getstation/desktop-app/tree/main/packages/app/src/plugins"
    click persistence "https://github.com/getstation/desktop-app/tree/main/packages/app/src/persistence"
    click devtools "https://github.com/getstation/desktop-app/tree/main/scripts"

    classDef system fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef business fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef presentation fill:#FFFFE0,stroke:#000,stroke-width:1px;
    classDef tool fill:#FFC0CB,stroke:#000,stroke-width:1px;
```
