# surfer-org/protocol architecture

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

- Interactive diagram: https://gitdiagram.com/surfer-org/protocol
- Repository: https://github.com/surfer-org/protocol

## Overview

##### Main Components

a) Desktop Application (Core Component)
- Frontend (React + Electron)
- Backend Services
- Platform-specific Exporters
- Local Storage System

b) SDK Component
- Python SDK Interface
- Client Libraries
- Protocol Implementation

c) Documentation System
- Next.js Documentation Site
- API Documentation
- Cookbook Examples

##### Architectural Relationships to Highlight

**[Desktop App Layer]**

- UI Components (React + Shadcn)
- Platform Dashboard
- Export Interface
- Settings/Configuration

- Core Services (Electron)
- Platform Handlers
- Authentication Manager
- Data Export Engine

- Platform Integrations
- Apple (iMessage)
- Google (Gmail)
- Microsoft
- Twitter/X
- Notion
- OpenAI (ChatGPT)

**[SDK Layer]**

- Python Client
- Protocol Implementation
- Data Processing

**[Storage Layer]**
- Local File System

##### Data Flow Indicators

- User interaction flows
- Data export paths
- SDK integration points
- Storage operations

##### Implementation Details

- Electron's main and renderer process separation
- Platform-specific export implementations
- SDK integration points
- Local storage management
- Cross-platform compatibility

##### Notes for Scale

- Potential expansion points for new platforms
- SDK extensibility
- Future integration possibilities

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Desktop["Desktop Application"]
        direction TB
        
        subgraph UI["Frontend Layer"]
            direction TB
            Dashboard["Platform Dashboard"]:::frontend
            ExportUI["Export Interface"]:::frontend
            Settings["Settings/Configuration"]:::frontend
        end

        subgraph Core["Core Services"]
            direction TB
            PlatformHandler["Platform Handlers"]:::core
            AuthManager["Authentication Manager"]:::core
            ExportEngine["Data Export Engine"]:::core
        end

        subgraph Platforms["Platform Integrations"]
            direction TB
            Apple["Apple/iMessage"]:::platform
            Google["Google/Gmail"]:::platform
            Microsoft["Microsoft"]:::platform
            Twitter["Twitter/X"]:::platform
            Notion["Notion"]:::platform
            OpenAI["OpenAI/ChatGPT"]:::platform
        end
    end

    subgraph SDK["SDK Layer"]
        direction TB
        PythonClient["Python Client"]:::sdk
        Protocol["Protocol Implementation"]:::sdk
        DataProc["Data Processing"]:::sdk
    end

    subgraph Storage["Storage Layer"]
        LocalFS[("Local File System")]:::storage
    end

    subgraph Docs["Documentation"]
        direction TB
        ApiDocs["API Documentation"]:::docs
        Cookbook["Cookbook Examples"]:::docs
        PlatformDocs["Platform Documentation"]:::docs
    end

    %% Relationships
    UI --> Core
    Core --> Platforms
    Platforms --> LocalFS
    Core --> LocalFS
    SDK --> Protocol
    Protocol --> Core
    
    %% Click Events
    click UI "https://github.com/Surfer-Org/Protocol/tree/main/desktop/src/renderer/"
    click Core "https://github.com/Surfer-Org/Protocol/tree/main/desktop/src/main/"
    click Dashboard "https://github.com/Surfer-Org/Protocol/tree/main/desktop/src/renderer/components/"
    click PlatformHandler "https://github.com/Surfer-Org/Protocol/blob/main/desktop/src/main/helpers/platforms.ts"
    click AuthManager "https://github.com/Surfer-Org/Protocol/blob/main/desktop/src/main/helpers/network.ts"
    click Apple "https://github.com/Surfer-Org/Protocol/tree/main/desktop/src/main/platforms/Apple/"
    click Google "https://github.com/Surfer-Org/Protocol/tree/main/desktop/src/main/platforms/Google/"
    click Microsoft "https://github.com/Surfer-Org/Protocol/tree/main/desktop/src/main/platforms/Microsoft/"
    click Twitter "https://github.com/Surfer-Org/Protocol/tree/main/desktop/src/main/platforms/X Corp/"
    click Notion "https://github.com/Surfer-Org/Protocol/tree/main/desktop/src/main/platforms/Notion/"
    click OpenAI "https://github.com/Surfer-Org/Protocol/tree/main/desktop/src/main/platforms/OpenAI/"
    click PythonClient "https://github.com/Surfer-Org/Protocol/tree/main/sdk/python/surfer_protocol/"
    click Cookbook "https://github.com/Surfer-Org/Protocol/tree/main/cookbook/python/"
    click PlatformDocs "https://github.com/Surfer-Org/Protocol/tree/main/docs/src/app/desktop/platforms/"
    click ApiDocs "https://github.com/Surfer-Org/Protocol/tree/main/docs/src/"

    %% Styling
    classDef frontend fill:#2563eb,color:white
    classDef core fill:#1d4ed8,color:white
    classDef platform fill:#16a34a,color:white
    classDef sdk fill:#ea580c,color:white
    classDef storage fill:#4c1d95,color:white
    classDef docs fill:#525252,color:white

    %% Legend
    subgraph Legend
        Frontend["Frontend Components"]:::frontend
        CoreComp["Core Services"]:::core
        PlatformInt["Platform Integrations"]:::platform
        SDKComp["SDK Components"]:::sdk
        StorageComp["Storage Systems"]:::storage
        DocsComp["Documentation"]:::docs
    end
```
