# kuluruvineeth/silent-coder architecture

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

- Interactive diagram: https://gitdiagram.com/kuluruvineeth/silent-coder
- Repository: https://github.com/kuluruvineeth/silent-coder

## Overview

##### Project type and purpose
- This is a desktop application built on Electron, combining a Node.js “main” process with a React/TypeScript “renderer” process.
- Its purpose is to let users take screenshots, process them, and present results via a modern UI.

##### File structure
- Top-level:
- build/, electron-builder.yml, notarize.js → packaging and notarization for macOS/Windows/Linux
- src/main → Electron Main process code (app startup, IPC, config, screenshot & processing managers, keyboard shortcuts)
- src/preload → Preload script to safely expose Main-process APIs to the Renderer
- src/renderer → React-based UI (Vite-powered, TSX components, styling, providers for state/queries)
- Config files: tsconfig.*, electron.vite.config.ts, ESLint & Prettier configs, package.json + pnpm-lock.yaml.

##### README
- Confirms it’s an Electron + React + TypeScript app.
- Shows standard pnpm scripts for dev and build across OS targets.

a. Electron Main Process
- ConfigManager (loads/saves settings)
- ScreenshotManager (captures screen)
- ProcessingManager (runs algorithmic work on images)
- IpcHandler (routes IPC calls)
- KeyboardShortcut manager (global hotkeys)
b. Preload Script
- Exposes a typed API surface via contextBridge to the Renderer
c. Renderer Process (React UI)
- Components (App, Queue, ScreenshotsView, SettingsDialog, Debug panels)
- Providers (QueryProvider, ToastProvider)
- Assets & Stylesheets
d. System/OS Layer
- File system, native OS screenshot & shortcut APIs
e. Build/Packaging Layer

##### Relationships & data flow
- User clicks UI → React component calls window.api.* (preload) → IPC → Main Process
- Main Process executes native operations (e.g., take screenshot) → returns result via IPC → Renderer updates UI
- Settings changes in UI → API call → ConfigManager persists to disk
- Processing tasks may spawn child processes or threads (if implemented in ProcessingManager)

##### Architectural patterns & principles
- Layered Separation: UI (Renderer) ↔ IPC boundary (Preload) ↔ System logic (Main) ↔ OS
- Single Responsibility per module (each manager handles one domain)
- Typed contracts (TypeScript definitions in preload and renderer env.d.ts)
- Event-driven communication via Electron’s IPC

##### Technologies & frameworks
- Electron (main + renderer)
- Vite (fast bundling for renderer)
- React + TypeScript (UI)
- PNPM (package management)
- electron-builder (packaging & code signing)
- ESLint, Prettier (code quality)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Renderer Process
    subgraph "Renderer Process"
        direction TB
        REntry["Renderer Entry (main.tsx)"]:::process
        App["App.tsx"]:::component
        subgraph "Components"
            direction TB
            Debug["Debug Panels"]:::component
            Queue["Queue Views"]:::component
            ScreenshotsView["ScreenshotsView"]:::component
            SettingsDialog["Settings Dialog"]:::component
            Solutions["Solutions Panels"]:::component
            UIWidgets["Common UI Widgets"]:::component
            Welcome["Welcome Screen"]:::component
        end
        subgraph "Providers"
            direction TB
            QueryProvider["QueryProvider"]:::module
            ToastContext["Toast Context & Provider"]:::module
        end
        Assets["Assets & Styles (CSS)"]:::artifact
        EnvTypes["env.d.ts"]:::artifact
    end

    %% Preload Layer
    subgraph "Preload Layer"
        direction TB
        Def["API Surface Definition (index.d.ts)"]:::module
        Impl["Preload Implementation (index.ts)"]:::module
    end

    %% Main Process
    subgraph "Main Process"
        direction TB
        MainEntry["Entry Point (index.ts)"]:::process
        ConfigMgr["ConfigManager"]:::module
        ScreenshotMgr["ScreenshotManager"]:::module
        ProcessingMgr["ProcessingManager"]:::module
        IpcHandler["IpcHandler"]:::module
        ShortcutMgr["KeyboardShortcut Manager"]:::module
    end

    %% OS / System Layer
    subgraph "OS / System"
        direction TB
        OSAPIs["Native OS APIs"]:::external
        FileSys["File System"]:::external
    end

    %% Build & Packaging
    subgraph "Build & Packaging"
        direction TB
        BuildRes["build/ resources"]:::artifact
        BuilderCfg["electron-builder.yml"]:::artifact
        Notarize["notarize.js"]:::artifact
        ViteCfg["electron.vite.config.ts"]:::artifact
    end

    %% Data Flows
    App -->|"calls api"| Impl
    Impl -->|"IPC request"| IpcHandler
    IpcHandler -->|"invoke captureScreen()"| ScreenshotMgr
    ScreenshotMgr -->|"uses"| OSAPIs
    IpcHandler -->|"invoke processImage()"| ProcessingMgr
    ProcessingMgr -->|"spawns threads"| OSAPIs
    IpcHandler -->|"invoke saveConfig()"| ConfigMgr
    ConfigMgr -->|"writes"| FileSys
    IpcHandler -->|"register shortcuts"| ShortcutMgr
    ShortcutMgr -->|"uses"| OSAPIs
    IpcHandler -->|"IPC response"| Impl
    Impl -->|"delivers result"| App

    %% Renderer internals
    REntry --> App
    App --> Debug
    App --> Queue
    App --> ScreenshotsView
    App --> SettingsDialog
    App --> Solutions
    App --> UIWidgets
    App --> Welcome
    App --> QueryProvider
    App --> ToastContext

    %% Click Events
    click REntry "https://github.com/kuluruvineeth/silent-coder/blob/main/src/renderer/src/main.tsx"
    click App "https://github.com/kuluruvineeth/silent-coder/blob/main/src/renderer/src/App.tsx"
    click Debug "https://github.com/kuluruvineeth/silent-coder/tree/main/src/renderer/src/components/debug/"
    click Queue "https://github.com/kuluruvineeth/silent-coder/tree/main/src/renderer/src/components/queue/"
    click ScreenshotsView "https://github.com/kuluruvineeth/silent-coder/blob/main/src/renderer/src/components/screenshots-view.tsx"
    click SettingsDialog "https://github.com/kuluruvineeth/silent-coder/blob/main/src/renderer/src/components/settings-dialog.tsx"
    click Solutions "https://github.com/kuluruvineeth/silent-coder/tree/main/src/renderer/src/components/solutions/"
    click UIWidgets "https://github.com/kuluruvineeth/silent-coder/tree/main/src/renderer/src/components/ui/"
    click Welcome "https://github.com/kuluruvineeth/silent-coder/blob/main/src/renderer/src/components/welcome-screen.tsx"
    click QueryProvider "https://github.com/kuluruvineeth/silent-coder/blob/main/src/renderer/src/providers/query-provider.tsx"
    click ToastContext "https://github.com/kuluruvineeth/silent-coder/blob/main/src/renderer/src/providers/toast-context.tsx"
    click Assets "https://github.com/kuluruvineeth/silent-coder/tree/main/src/renderer/src/assets/"
    click EnvTypes "https://github.com/kuluruvineeth/silent-coder/blob/main/src/renderer/src/env.d.ts"

    click Def "https://github.com/kuluruvineeth/silent-coder/blob/main/src/preload/index.d.ts"
    click Impl "https://github.com/kuluruvineeth/silent-coder/blob/main/src/preload/index.ts"

    click MainEntry "https://github.com/kuluruvineeth/silent-coder/blob/main/src/main/index.ts"
    click ConfigMgr "https://github.com/kuluruvineeth/silent-coder/blob/main/src/main/lib/config-manager.ts"
    click ScreenshotMgr "https://github.com/kuluruvineeth/silent-coder/blob/main/src/main/lib/screenshot-manager.ts"
    click ProcessingMgr "https://github.com/kuluruvineeth/silent-coder/blob/main/src/main/lib/processing-manager.ts"
    click IpcHandler "https://github.com/kuluruvineeth/silent-coder/blob/main/src/main/lib/ipc-handler.ts"
    click ShortcutMgr "https://github.com/kuluruvineeth/silent-coder/blob/main/src/main/lib/keyboard-shortcut.ts"

    click BuildRes "https://github.com/kuluruvineeth/silent-coder/tree/main/build/"
    click BuilderCfg "https://github.com/kuluruvineeth/silent-coder/blob/main/electron-builder.yml"
    click Notarize "https://github.com/kuluruvineeth/silent-coder/blob/main/notarize.js"
    click ViteCfg "https://github.com/kuluruvineeth/silent-coder/blob/main/electron.vite.config.ts"

    %% Styles
    classDef process fill:#f9f,stroke:#333,stroke-width:1px
    classDef module fill:#bbf,stroke:#333,stroke-width:1px
    classDef component fill:#bfb,stroke:#333,stroke-width:1px
    classDef artifact fill:#ffb,stroke:#333,stroke-width:1px
    classDef external fill:#ddd,stroke:#333,stroke-width:1px
```
