# dusterbloom/cycl3s_beta architecture

> Architecture diagram of the GitHub repository dusterbloom/cycl3s_beta, 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/dusterbloom/cycl3s_beta
- Repository: https://github.com/dusterbloom/cycl3s_beta

## Overview

##### Main System Components

a) Client-Side (Frontend):
- Sub-components:
- User Interface (Components)
- Authentication Context
- Encryption Services
- Wallet Integration

b) External Services:
- On the right side:
- Bluesky API
- Web3.Storage
- Keplr Wallet

c) Backend Services:
- At the bottom:
- Node.js Server
- Smart Contract (Key Registry)

##### Component Relationships

- UI Components → Authentication Context
- UI Components → Encryption Services
- Authentication Context → Wallet Integration
- Wallet Integration → Smart Contract

- Frontend → Bluesky API
- Frontend → Backend Server
- Frontend → Web3.Storage

- E2E encryption path between users
- Encryption services to key registry

##### Detailed Component Breakdown

a) Encryption System:
**Web Crypto API → ECDH Key Exchange → AES-256-GCM**
- ↓               ↓                    ↓
**Key Generation → Public Key Registry → Encrypted Messages**

b) Authentication Flow:
**Keplr Wallet → Smart Contract → JWT → Protected Routes**

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        UI["UI Components"]
        AC["Authentication Context"]:::auth
        ES["Encryption Services"]:::security
        WI["Wallet Integration"]:::wallet
        
        subgraph Components
            Feed["Feed Component"]:::ui
            Messages["Messages Component"]:::ui
            Profile["Profile Component"]:::ui
            Auth["Authentication UI"]:::ui
            WalletUI["Wallet UI"]:::ui
        end
        
        subgraph Services
            EncService["Encryption Service"]:::security
            SignalEnc["Signal Protocol"]:::security
            EncMessages["Encrypted Messages"]:::security
            APIService["API Service"]:::service
            BSkyService["Bluesky Service"]:::service
        end
    end
    
    subgraph External
        BSky["Bluesky API"]:::external
        W3S["Web3.Storage"]:::external
        KW["Keplr Wallet"]:::external
    end
    
    subgraph Backend
        Server["Node.js Server"]:::backend
        Contract["Smart Contract (Key Registry)"]:::contract
    end
    
    %% Relationships
    UI --> AC
    UI --> ES
    AC --> WI
    WI --> Contract
    Frontend -.-> BSky
    Frontend -.-> W3S
    Frontend -.-> Server
    ES ...-> Contract
    WI --> KW
    
    %% Component Relationships
    Components --> Services
    
    %% Legend
    classDef ui fill:#2196F3,stroke:#1565C0,color:#fff
    classDef auth fill:#9C27B0,stroke:#7B1FA2,color:#fff
    classDef security fill:#FF9800,stroke:#F57C00,color:#fff
    classDef wallet fill:#4CAF50,stroke:#388E3C,color:#fff
    classDef external fill:#607D8B,stroke:#455A64,color:#fff
    classDef backend fill:#795548,stroke:#5D4037,color:#fff
    classDef contract fill:#FFC107,stroke:#FFA000,color:#fff
    classDef service fill:#00BCD4,stroke:#0097A7,color:#fff

    %% Click Events
    click Feed "https://github.com/dusterbloom/cycl3s_beta/blob/main/src/components/Feed.jsx"
    click Messages "https://github.com/dusterbloom/cycl3s_beta/blob/main/src/components/Messages.jsx"
    click Profile "https://github.com/dusterbloom/cycl3s_beta/blob/main/src/components/Profile.jsx"
    click Auth "https://github.com/dusterbloom/cycl3s_beta/blob/main/src/components/Login.jsx"
    click WalletUI "https://github.com/dusterbloom/cycl3s_beta/blob/main/src/components/LinkWallet.jsx"
    click AC "https://github.com/dusterbloom/cycl3s_beta/blob/main/src/context/AuthContext.jsx"
    click WI "https://github.com/dusterbloom/cycl3s_beta/blob/main/src/services/wallet.js"
    click EncService "https://github.com/dusterbloom/cycl3s_beta/blob/main/src/services/encryption.js"
    click SignalEnc "https://github.com/dusterbloom/cycl3s_beta/blob/main/src/services/signalEncryption.js"
    click EncMessages "https://github.com/dusterbloom/cycl3s_beta/blob/main/src/components/EncryptedMessages.jsx"
    click Contract "https://github.com/dusterbloom/cycl3s_beta/blob/main/src/contracts/key-registry/index.js"
    click BSkyService "https://github.com/dusterbloom/cycl3s_beta/blob/main/src/services/bluesky.js"
    click APIService "https://github.com/dusterbloom/cycl3s_beta/blob/main/src/services/api.js"
    click Server "https://github.com/dusterbloom/cycl3s_beta/blob/main/server.js"
    click UI "https://github.com/dusterbloom/cycl3s_beta/tree/main/src/components/"
```
