# mistweaverco/bananas architecture

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

- Interactive diagram: https://gitdiagram.com/mistweaverco/bananas
- Repository: https://github.com/mistweaverco/bananas

## Overview

##### Main Components
- Electron Main Process: This is found under src/main (files like index.ts, ipcMainHandlers.ts, stateKeeper.ts, and utils.ts). It orchestrates the application’s lifecycle, manages native integrations (e.g., screen capture), and handles IPC communication.
- Preload Process: Under src/preload, the preload scripts expose controlled, secure APIs to the renderer process. This acts as the bridge between the main process and the renderer.
- Renderer Process: The UI is built with Svelte and lives inside src/renderer (including HTML, Svelte components, and accompanying assets and style files). This component displays the application interface and interacts with the main process via the preload scripts.
- Internationalization (i18n): The src/i18n directory contains modules for multiple languages (de, en, fr, zh) along with utilities and configuration to provide localized UI support.
- Build & Packaging Infrastructure: Tools and configuration files like electron-builder.yml, electron.vite.config.ts, package.json, and several scripts in the scripts/ directory indicate build, versioning, and release automation processes.
- External Communication: Though not in the file tree explicitly as a module, the README references the use of STUN/TURN and signaling servers to set up the peer-to-peer connection. Represent these as external components that the application communicates with.

- Inside the container, separate the application into:
- Main Process (src/main): Label important functions, including IPC handling.
- Preload Scripts (src/preload): Indicate their role as a secure bridge.
- Renderer Process (src/renderer): Show that this is where the Svelte-based UI logic resides.
- Internationalization Layer (src/i18n): Connect it to the renderer and possibly the main process if localization is applied during startup.
- Additionally, include a “Build & Deployment Pipeline” component to represent the scripts and configurations that bundle, release, and notarize the application (using tools such as electron-builder).

##### Architectural Patterns and Technologies
- Separation of Concerns: Distinct boundaries exist between the main process, preload scripts, and the renderer (Svelte UI). This follows Electron’s recommended architecture for security and maintainability.
- IPC (Inter-Process Communication): Emphasize the role of IPC channels (as seen in src/main/ipcMainHandlers.ts) which are critical in the interaction between frontend and backend layers within the Electron app.
- TypeScript and Svelte: Mention that the use of TypeScript (as indicated by tsconfig files) provides type safety across the project, and Svelte ensures a streamlined UI layer.
- Internationalization: The i18n directory shows the commitment to multi-language support, with modules handling different languages and formats.

## Diagram (Mermaid)

```mermaid
graph TD
    subgraph "Electron App"
        MP["Main Process (IPC,native integrations)"]:::main
        PL["Preload Scripts (Bridge)"]:::preload
        RP["Renderer (Svelte UI)"]:::renderer
        I18["Internationalization (i18n)"]:::i18n
    end

    BD["Build & Deployment Pipeline"]:::build
    EX["External Services (STUN/TURN/Signaling Servers)"]:::external

    RP -->|"calls"| PL
    PL -->|"communicates"| MP
    I18 -->|"supports"| RP
    MP -->|"connects"| EX
    BD -->|"packages"| MP

    click MP "https://github.com/mistweaverco/bananas/tree/main/src/main"
    click PL "https://github.com/mistweaverco/bananas/tree/main/src/preload"
    click RP "https://github.com/mistweaverco/bananas/tree/main/src/renderer"
    click I18 "https://github.com/mistweaverco/bananas/tree/main/src/i18n"
    click BD "https://github.com/mistweaverco/bananas/tree/main/scripts/"

    classDef main fill:#FFE6E6,stroke:#FF5733,stroke-width:2px;
    classDef preload fill:#E6FFE6,stroke:#33FF57,stroke-width:2px;
    classDef renderer fill:#E6E6FF,stroke:#3357FF,stroke-width:2px;
    classDef i18n fill:#FFF0E6,stroke:#FFA533,stroke-width:2px;
    classDef build fill:#F0E6FF,stroke:#B833FF,stroke-width:2px;
    classDef external fill:#FFE6F0,stroke:#FF33A8,stroke-width:2px;
```
