# shouchenicu/fastsend architecture

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

- Interactive diagram: https://gitdiagram.com/shouchenicu/fastsend
- Repository: https://github.com/shouchenicu/fastsend

## Overview

##### Main Components Identification

The system architecture should be divided into these key components:

a) Frontend Layer:
- Vue.js/Nuxt3 Application
- PWA Implementation
- UI Components (components directory)
- WebRTC Client Implementation

b) Backend Layer:
- Nuxt Server
- API Endpoints
- WebRTC Signaling Server

c) Core Services:
- File Transfer Service
- WebRTC Connection Management
- Peer Discovery Service

##### Specific Components

Frontend (Both Sender and Recipient):
**┌─ User Interface Layer ─┐**
- Vue Components
- PWA Container
- File System API
- WebRTC Client

Server Middle Layer:
**┌─ Server Components ─┐**
- API Routes (/server/api)
- Connection Handler
- IP Detection Service
- Transfer Counter

Core Services:
**┌─ Services Layer ─┐**
- PeerDataChannel
- File Transfer Service
- STUN/TURN Services

##### Additional Elements

Supporting elements:
- Notes about security (P2P encryption)
- Local network optimization paths
- PWA installation flow

##### Technical Details to Highlight

- WebRTC connection establishment
- File system API integration
- Local network detection and optimization
- Internationalization support
- PWA capabilities

##### Progressive Web App architecture

Remember to maintain a balance between detail and clarity, focusing on the core WebRTC implementation while showing supporting features like PWA and internationalization as auxiliary components.

This system design should reflect FastSend's modern architecture while highlighting its key features: security, efficiency, and ease of use.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client1[Sender Client]
        direction TB
        UI1[User Interface]:::frontend
        PWA1[PWA Container]:::frontend
        FSA1[File System API]:::frontend
        WRC1[WebRTC Client]:::frontend
    end

    subgraph ServerLayer[Server Layer]
        direction TB
        API[API Routes]:::server
        CH[Connection Handler]:::server
        IPS[IP Detection]:::server
        TC[Transfer Counter]:::server
    end

    subgraph Client2[Recipient Client]
        direction TB
        UI2[User Interface]:::frontend
        PWA2[PWA Container]:::frontend
        FSA2[File System API]:::frontend
        WRC2[WebRTC Client]:::frontend
    end

    subgraph Services[Core Services]
        direction TB
        PDC[PeerDataChannel]:::service
        FTS[File Transfer Service]:::service
        STUN[STUN/TURN Services]:::external
    end

    UI1 --> FSA1
    UI1 --> WRC1
    FSA1 --> FTS
    WRC1 --> PDC
    
    UI2 --> FSA2
    UI2 --> WRC2
    FSA2 --> FTS
    WRC2 --> PDC

    PDC <--> STUN
    PDC <--> API
    API <--> CH
    CH <--> IPS
    CH <--> TC

    %% Click Events
    click UI1 "https://github.com/ShouChenICU/FastSend/blob/main/pages/sender.vue"
    click UI2 "https://github.com/ShouChenICU/FastSend/blob/main/pages/recipient.vue"
    click PWA1 "https://github.com/ShouChenICU/FastSend/blob/main/public/sw.js"
    click PWA2 "https://github.com/ShouChenICU/FastSend/blob/main/public/sw.js"
    click API "https://github.com/ShouChenICU/FastSend/tree/main/server/api"
    click IPS "https://github.com/ShouChenICU/FastSend/blob/main/server/api/getIP.post.ts"
    click TC "https://github.com/ShouChenICU/FastSend/blob/main/server/utils/TransCount.ts"
    click PDC "https://github.com/ShouChenICU/FastSend/blob/main/utils/PeerDataChannel.ts"
    click FTS "https://github.com/ShouChenICU/FastSend/blob/main/utils/files.ts"
    click STUN "https://github.com/ShouChenICU/FastSend/blob/main/utils/publicStunList.ts"

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef server fill:#2ecc71,stroke:#27ae60,color:white
    classDef service fill:#e67e22,stroke:#d35400,color:white
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        direction TB
        F[Frontend]:::frontend
        S[Server]:::server
        SV[Service]:::service
        E[External]:::external
    end
```
