# apperside/thunderclone architecture

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

- Interactive diagram: https://gitdiagram.com/apperside/thunderclone
- Repository: https://github.com/apperside/thunderclone

## Overview

##### Main Components Overview

A. Browser Extension (Chrome)
- Content Scripts (UI layer)
- Background Service
- Message Handling System

B. Desktop Application (Electron)
- Main Process
- Renderer Process
- WebSocket Server
- File System Operations

##### Browser Extension Layer
- Content Script Component (injects UI)
- Background Service (handles communications)
- Password Authentication UI

##### Desktop Application Layer
- WebSocket Server
- Repository Manager
- Password Verification System
- File System Interface
- Configuration Manager

##### Component Relationships and Data Flow

**[GitHub Repository Page] → [Chrome Extension]**
- ↓
**[Injected Clone Button] → [Password Dialog]**
- ↓
**[Signature Generation] → [WebSocket Message]**
- ↓
**[Desktop App WebSocket Server] → [Auth Verification]**
- ↓
**[Clone Operation] → [Local File System]**

##### Specific Implementation Details

Technical aspects:
- WebSocket connection on local port
- Password-based security system
- Repository cloning path structure
- Content script injection points

##### Security Flow Representation

Security workflow:
**[Password Input] → [Signature Generation]**
- ↓
**[Timestamp + URL + Password Hash]**
- ↓
**[Signature Verification]**
- ↓
**[Clone Authorization]**

##### Configuration Flow

Configuration system:
**[User Preferences] → [Desktop App Storage]**
- ↓
**[Clone Directory Settings]**
- ↓
**[System Startup Config]**

##### Important Notes

- Clear separation between browser and desktop environments
- WebSocket communication channel
- Temporary nature of password storage
- Future implementation points (AI integration, config panel)
- Error handling paths
- Path for repository cloning structure

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph External
        GitHub[GitHub Repository]
        FileSystem[Local File System]
        Browser[Chrome Browser]
    end

    subgraph BrowserExtension[Browser Extension Layer]
        ContentScript["Content Scripts (UI)"]:::ui
        BackgroundSvc["Background Service"]:::service
        UIComp["UI Components"]:::ui
        ButtonInj["Button Injector"]:::ui
        ExtUtils["Extension Utilities"]:::util
        PassDialog["Password Dialog"]:::security
    end

    subgraph DesktopApp[Desktop Application Layer]
        MainProc["Main Process"]:::core
        RendererProc["Renderer Process"]:::core
        WSServer["WebSocket Server"]:::network
        RepoManager["Repository Manager"]:::core
        ConfigManager["Configuration Manager"]:::config
        PassSystem["Password System"]:::security
        Cache["Cache Management"]:::util
        Notifier["Notification System"]:::util
        NetUtils["Networking Utilities"]:::network
    end

    %% Relationships
    GitHub --> ContentScript
    ContentScript --> ButtonInj
    ButtonInj --> PassDialog
    PassDialog --> BackgroundSvc
    BackgroundSvc --> WSServer
    WSServer --> PassSystem
    PassSystem --> RepoManager
    RepoManager --> FileSystem
    ConfigManager --> RepoManager
    MainProc --> RendererProc
    RendererProc --> WSServer
    WSServer --> NetUtils
    RepoManager --> Notifier
    PassSystem --> Cache

    %% Click Events
    click ContentScript "https://github.com/apperside/thunderclone/blob/main/browser-extension/content/content.tsx"
    click BackgroundSvc "https://github.com/apperside/thunderclone/blob/main/browser-extension/background.ts"
    click UIComp "https://github.com/apperside/thunderclone/blob/main/browser-extension/content/ContentApp.tsx"
    click ButtonInj "https://github.com/apperside/thunderclone/blob/main/browser-extension/content/buttonInjector.ts"
    click MainProc "https://github.com/apperside/thunderclone/blob/main/desktop-app/src/main.ts"
    click RendererProc "https://github.com/apperside/thunderclone/blob/main/desktop-app/src/renderer.ts"
    click WSServer "https://github.com/apperside/thunderclone/blob/main/desktop-app/src/utils/networking/socketMessageDispatcher.ts"
    click RepoManager "https://github.com/apperside/thunderclone/blob/main/desktop-app/src/utils/networking/socket-message-handlers/cloneRepo.handler..ts"
    click ConfigManager "https://github.com/apperside/thunderclone/blob/main/desktop-app/src/preferences.ts"
    click PassSystem "https://github.com/apperside/thunderclone/blob/main/desktop-app/src/password.html"
    click Cache "https://github.com/apperside/thunderclone/blob/main/desktop-app/src/inMemoryCache.ts"
    click Notifier "https://github.com/apperside/thunderclone/blob/main/desktop-app/src/utils/notifications-utils.ts"
    click NetUtils "https://github.com/apperside/thunderclone/blob/main/desktop-app/src/utils/networking/networking-utils.ts"
    click ExtUtils "https://github.com/apperside/thunderclone/blob/main/browser-extension/content/utils.ts"

    %% Styles
    classDef ui fill:#2196F3,color:white
    classDef service fill:#1976D2,color:white
    classDef core fill:#4CAF50,color:white
    classDef network fill:#00BCD4,color:white
    classDef security fill:#F44336,color:white
    classDef config fill:#FFC107,color:black
    classDef util fill:#9E9E9E,color:white
    classDef external fill:#757575,color:white

    %% Legend
    subgraph Legend
        UI[UI Components]:::ui
        Service[Services]:::service
        Core[Core Components]:::core
        Network[Network Components]:::network
        Security[Security Components]:::security
        Config[Configuration]:::config
        Utils[Utilities]:::util
        Ext[External Systems]:::external
    end
```
