# outerbase/studio-desktop architecture

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

- Interactive diagram: https://gitdiagram.com/outerbase/studio-desktop
- Repository: https://github.com/outerbase/studio-desktop

## Overview

##### Main Architectural Components

a) Electron Layer
- Main Process (electron/main.ts)
- Renderer Process (src/ React application)
- Preload Scripts (electron/preload.ts)

b) Database Drivers Layer
- Multiple database support (MySQL, PostgreSQL, SQLite, Cloudflare, Starbase)
- Connection Pool management
- Driver base implementation

c) Frontend Application Layer
- React Components
- Context Providers
- Routing System
- UI Components

##### Component Relationships

**[Desktop Application]**
- [Electron Main Process]
- Window Management
- IPC Handlers
- File System Access

- [Database Drivers]
- Base Driver Interface
- Connection Pool
- Database-Specific Implementations

- [React Frontend]
- UI Components
- Database Editors
- Connection Management
- Theme System

##### Specific Implementation Details

- Electron Processes (Main & Renderer) - Hexagons
- Database Drivers - Rectangles with rounded corners
- UI Components - Regular rectangles

##### Key Architectural Patterns to Highlight

a) IPC Communication Pattern
- Bidirectional communication between main and renderer processes
- Preload script's role in securing IPC

b) Driver Architecture
- Demonstrate the inheritance structure from base.ts
- How different database drivers implement the base interface

c) Frontend Architecture
- Component hierarchy
- Routing system
- State management flow

##### Technical Stack Indicators

Technology badges or labels for:
- Electron
- React
- TypeScript
- Various Database Drivers
- Tailwind CSS

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Desktop["Outerbase Studio Desktop"]
        subgraph Electron["Electron Layer"]
            MainProcess["Main Process"]:::electron
            PreloadScripts["Preload Scripts"]:::electron
            WindowMgmt["Window Management"]:::electron
            IPC["IPC Communication"]:::electron
        end

        subgraph Drivers["Database Drivers Layer"]
            BaseDriver["Base Driver Interface"]:::driver
            ConnPool["Connection Pool"]:::driver
            subgraph DBDrivers["Database Implementations"]
                MySQL["MySQL Driver"]:::driver
                PostgreSQL["PostgreSQL Driver"]:::driver
                SQLite["SQLite Driver"]:::driver
                Cloudflare["Cloudflare Driver"]:::driver
                Starbase["Starbase Driver"]:::driver
            end
        end

        subgraph Frontend["Frontend Application Layer"]
            ReactApp["Main React App"]:::frontend
            subgraph UI["UI Layer"]
                UIComponents["UI Components"]:::frontend
                DBEditor["Database Editor"]:::frontend
                AnimRouter["Animated Router"]:::frontend
            end
            subgraph State["State Management"]
                ThemeProvider["Theme Provider"]:::state
                ConnManager["Connection Manager"]:::state
                DBManager["Database Manager"]:::state
            end
        end
    end

    %% Relationships
    MainProcess -.->|IPC| PreloadScripts
    PreloadScripts -.->|IPC| ReactApp
    MainProcess --> WindowMgmt
    MainProcess --> IPC
    
    BaseDriver --> ConnPool
    ConnPool --> DBDrivers
    BaseDriver --> MySQL
    BaseDriver --> PostgreSQL
    BaseDriver --> SQLite
    BaseDriver --> Cloudflare
    BaseDriver --> Starbase

    ReactApp --> UI
    ReactApp --> State
    
    %% Click Events
    click MainProcess "https://github.com/outerbase/studio-desktop/blob/master/electron/main.ts"
    click PreloadScripts "https://github.com/outerbase/studio-desktop/blob/master/electron/preload.ts"
    click BaseDriver "https://github.com/outerbase/studio-desktop/blob/master/electron/drivers/base.ts"
    click MySQL "https://github.com/outerbase/studio-desktop/blob/master/electron/drivers/mysql.ts"
    click PostgreSQL "https://github.com/outerbase/studio-desktop/blob/master/electron/drivers/postgres.ts"
    click SQLite "https://github.com/outerbase/studio-desktop/blob/master/electron/drivers/sqlite.ts"
    click Cloudflare "https://github.com/outerbase/studio-desktop/blob/master/electron/drivers/cloudflare.ts"
    click Starbase "https://github.com/outerbase/studio-desktop/blob/master/electron/drivers/starbase.ts"
    click ConnPool "https://github.com/outerbase/studio-desktop/blob/master/electron/connection-pool.ts"
    click WindowMgmt "https://github.com/outerbase/studio-desktop/tree/master/electron/window"
    click IPC "https://github.com/outerbase/studio-desktop/tree/master/electron/ipc"
    click ReactApp "https://github.com/outerbase/studio-desktop/blob/master/src/App.tsx"
    click UIComponents "https://github.com/outerbase/studio-desktop/tree/master/src/components/ui"
    click DBEditor "https://github.com/outerbase/studio-desktop/blob/master/src/database/editor.tsx"
    click ThemeProvider "https://github.com/outerbase/studio-desktop/blob/master/src/context/theme-provider.tsx"
    click ConnManager "https://github.com/outerbase/studio-desktop/blob/master/src/lib/conn-manager-store.tsx"
    click DBManager "https://github.com/outerbase/studio-desktop/blob/master/src/lib/db-manager-store.tsx"
    click AnimRouter "https://github.com/outerbase/studio-desktop/blob/master/src/components/animated-router.tsx"

    %% Styles
    classDef electron fill:#f9f,stroke:#333,stroke-width:2px
    classDef driver fill:#afd,stroke:#333,stroke-width:2px
    classDef frontend fill:#ddf,stroke:#333,stroke-width:2px
    classDef state fill:#fda,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        E["Electron Component"]:::electron
        D["Driver Component"]:::driver
        F["Frontend Component"]:::frontend
        S["State Management"]:::state
        I["-.- IPC Communication"]
        C["— Component Relationship"]
    end
```
