# milkshiift/goofcord architecture

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

- Interactive diagram: https://gitdiagram.com/milkshiift/goofcord
- Repository: https://github.com/milkshiift/goofcord

## Overview

##### Project Type and Purpose
- Project Type: GoofCord is a standalone Discord client with privacy enhancements and customization options. It leverages plugins & themes support and is built using Electron.
- Purpose: It modernizes Discord’s interface, blocking tracking, enabling encryption, and supporting mod integrations (such as Vencord and Shelter) to offer a tailored, secure experience.

##### File Structure
- Top-level organization:
- “assets”: Contains front-end resources such as JavaScript for ad blockers, custom CSS files for Discord themed modifications, HTML for settings and dropdowns, and language files (i.e., localization JSON files).
- “assetsDev”: Includes development assets (like test language generation, meta information XML, language codes) that support development tasks.
- “src”: Houses all core source code including configuration files (config.ts, settingsSchema.ts), the Electron main process (main.ts), IPC generation and loader scripts, and modularized functionalities.
- “src/windows”: Contains code for various windows in the app:
- “main”: Main window logic, including preload scripts and bridge functionality.
- “screenshare”: Dedicated screensharing window with its main script and preload.
- “settings”: Handles settings rendering, cloud settings, and encryption related to settings.
- Other key files:
- Electron-specific files (electron-builder.ts) indicate packaging with Electron Builder.
- Package management files (package.json, bun.lock, tsconfig.json) show usage of Node.js/Bun.
- Configuration files such as biome.json suggest additional packaging or runtime configuration.

##### Insights from the README
- The README emphasizes the client’s features (privacy, performance, standalone nature) and describes practical packaging instructions for Windows, Linux, and macOS.
- It details how to compile the application using Node.js and Bun, giving insights about dependencies and build steps.
- Links to various external projects (LegCord, Vencord, Shelter) indicate integration points and inspiration for extensibility.

a. Main Components:
- Electron Main Process: Central entry point (src/main.ts) that initializes the app, loads modules, and manages windows.
- UI Windows: Each with its own directory under src/windows (main window, screenshare window, settings window). These use preload scripts (preload.mts) to safely expose APIs.
- Modules Layer: Under src/modules, each module handles a specific functionality like encryption (messageEncryption.ts), update checks (updateCheck.ts), caching (cacheManager.ts) or firewall controls.
- Assets and Localization: Resources from assets/ (CSS, fonts, HTML) and assets/lang (JSON) supporting UI styling and multi-language support.
- Configuration & IPC: Config files in src/config.ts and IPC generation in src/ipcGen.ts vital for internal communications between processes.

b. Relationships and Interactions:
- The main Electron process spawns and manages UI windows, routing through preload scripts for safe API communications.
- Modules are invoked by the main process as well as by UI handlers to provide functionalities (for instance, mod support or encryption).
- Assets are loaded into the windows for UI presentation with their associated CSS/HTML and language JSON files enabling localization.
- Build scripts gather sources from src and assets to package final binaries using Electron Builder integrations.
- External integrations (plugins & themes) tap into defined extension points provided by modules.

c. Architectural Patterns and Design Principles:
- Modular Architecture: Separates core functionalities into individual modules (e.g., assetLoader, cacheManager), which makes the codebase both maintainable and extensible.
- Layered Design: Clearly distinguishes between backend logic (main process and modules) and frontend user interface (windows and assets).
- IPC Communication: Use of preload scripts to mediate secure interactions between renderer processes and the main process.
- Platform Abstraction: Build scripts and platform-specific install packages handle differences among Windows, Linux, and macOS.

d. Relevant Technologies, Frameworks, and Libraries:
- Electron: Underpins the desktop application architecture by managing processes and windows.
- Node.js & Bun: For package management, script execution, and build automation.
- TypeScript: The majority of the project files are written in TypeScript, ensuring type safety and structured development.
- CSS/HTML: Utilized in asset management to provide the custom user interface.
- Localization: JSON language files support multi-language functionalities.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Backend Components
    subgraph "Backend"
        A["Electron Main Process"]:::backend
        B["Modules Layer (Encryption, Update, Mods, Cache, etc.)"]:::backend
        C["Configuration"]:::backend
        J["IPC"]:::backend
    end

    %% Frontend Components
    subgraph "Frontend"
        D["Main Window"]:::frontend
        E["Screenshare Window"]:::frontend
        F["Settings Window"]:::frontend
        G["Assets & Localization"]:::frontend
    end

    %% Build and Packaging Components
    subgraph "Build & Packaging"
        H["Build & Packaging Scripts"]:::build
        I["Electron Builder"]:::build
    end

    %% Relationships between Backend and Frontend
    A -->|"spawns"| D
    A -->|"spawns"| E
    A -->|"spawns"| F
    A -->|"invokes"| B
    A -->|"readsFrom"| C
    A -->|"uses"| J
    B -->|"utilizes"| C
    B -->|"communicatesVia"| J
    D -->|"triggers"| B

    %% Frontend dependencies
    G -->|"resourcesFor"| D
    G -->|"resourcesFor"| E
    G -->|"resourcesFor"| F

    %% Build process packaging
    H -->|"packages"| A
    H -->|"packages"| B
    H -->|"packages"| G
    H -->|"initiates"| I

    %% Styles
    classDef backend fill:#fdd,stroke:#333,stroke-width:2px;
    classDef frontend fill:#ddf,stroke:#333,stroke-width:2px;
    classDef build fill:#dfd,stroke:#333,stroke-width:2px;

    %% Click Events
    click A "https://github.com/milkshiift/goofcord/blob/main/src/main.ts"
    click D "https://github.com/milkshiift/goofcord/tree/main/src/windows/main"
    click E "https://github.com/milkshiift/goofcord/tree/main/src/windows/screenshare"
    click F "https://github.com/milkshiift/goofcord/tree/main/src/windows/settings"
    click B "https://github.com/milkshiift/goofcord/tree/main/src/modules"
    click G "https://github.com/milkshiift/goofcord/tree/main/assets"
    click H "https://github.com/milkshiift/goofcord/tree/main/build"
    click I "https://github.com/milkshiift/goofcord/blob/main/electron-builder.ts"
    click C "https://github.com/milkshiift/goofcord/blob/main/src/config.ts"
    click J "https://github.com/milkshiift/goofcord/blob/main/src/ipcGen.ts"
```
