# danny-dasilva/cycletls architecture

> Architecture diagram of the GitHub repository danny-dasilva/cycletls, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/danny-dasilva/cycletls
- Repository: https://github.com/danny-dasilva/cycletls

## Overview

##### Main Components

a. Core Components:
- Node.js Interface Layer
- Golang Core Engine
- Request Handler Pool
- Transport Layer
- Cookie Management System
- Response Processor

b. External Interfaces:
- HTTP/HTTPS Endpoints
- Proxy Services
- TLS Handshake System

**[Client Application]**
- ↓
**[Node.js Interface Layer]**
- ↓
**[Golang Process Manager]**
- ↓
**[Request Handler Pool] ←→ [Worker Goroutines]**
- ↓
**[Transport Layer]**
- ↙     ↘
**[TLS Engine]  [HTTP Client]**
- ↓           ↓
**[Network Layer / Proxy]**
- ↓
**[External Services]**

##### Component Details

a. Node.js Interface Layer:
- Request initialization
- Configuration parsing
- Process management
- Response handling

b. Golang Core Engine:
- Goroutine pool management
- Request queue handling
- Concurrent request processing
- Memory management

c. Transport Layer:
- Custom TLS configuration
- JA3 fingerprint handling
- Header ordering
- Cookie management
- Proxy support

d. Response Processor:
- Status code handling
- Header processing
- Body parsing
- Image encoding (for supported types)

##### Data Flow Indicators

- Request flow: Client → Server
- Response flow: Server → Client
- Internal communication between components
- Worker pool distribution

##### Special Features to Highlight

- Concurrent request handling capability
- Custom header ordering system
- JA3 fingerprint configuration
- Cookie jar implementation
- Image handling support
- Proxy integration points

##### Technical Details

- Supported protocols (HTTP/1.1, HTTP/2)
- TLS version support
- Content type handling
- Authentication methods
- Error handling paths

##### Implementation Notes

- Separation between Node.js and Golang processes
- Where goroutine pooling occurs
- Points where JA3 fingerprinting is applied
- Proxy integration points

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        CA[Client Application]
    end

    subgraph Interface
        NI[Node.js Interface]:::nodejs
        GP[Golang Process Manager]:::golang
    end

    subgraph Core
        RHP[Request Handler Pool]:::core
        WG[Worker Goroutines]:::core
    end

    subgraph Transport
        TL[Transport Layer]:::transport
        TLE[TLS Engine]:::security
        HC[HTTP Client]:::transport
    end

    subgraph Management
        CMS[Cookie Management]:::util
        RP[Response Processor]:::util
        EH[Error Handler]:::util
    end

    subgraph Network
        NP[Network/Proxy Layer]:::network
        ES[External Services]:::external
    end

    %% Connections
    CA --> NI
    NI --> GP
    GP --> RHP
    RHP <--> WG
    WG --> TL
    TL --> TLE
    TL --> HC
    TLE --> NP
    HC --> NP
    NP --> ES
    
    %% Support System Connections
    WG --> CMS
    WG --> RP
    WG --> EH

    %% Click Events
    click NI "https://github.com/Danny-Dasilva/CycleTLS/blob/main/src/index.ts"
    click GP "https://github.com/Danny-Dasilva/CycleTLS/blob/main/src/index.go"
    click TL "https://github.com/Danny-Dasilva/CycleTLS/blob/main/cycletls/roundtripper.go"
    click CMS "https://github.com/Danny-Dasilva/CycleTLS/blob/main/cycletls/cookie.go"
    click TLE "https://github.com/Danny-Dasilva/CycleTLS/blob/main/cycletls/extensions.go"
    click EH "https://github.com/Danny-Dasilva/CycleTLS/blob/main/cycletls/errors.go"
    click WG "https://github.com/Danny-Dasilva/CycleTLS/blob/main/cycletls/client.go"
    click RHP "https://github.com/Danny-Dasilva/CycleTLS/blob/main/main.go"

    %% Styling
    classDef nodejs fill:#68a063,stroke:#333,stroke-width:2px
    classDef golang fill:#00add8,stroke:#333,stroke-width:2px
    classDef core fill:#2ecc71,stroke:#333,stroke-width:2px
    classDef transport fill:#f1c40f,stroke:#333,stroke-width:2px
    classDef security fill:#e74c3c,stroke:#333,stroke-width:2px
    classDef network fill:#3498db,stroke:#333,stroke-width:2px
    classDef external fill:#95a5a6,stroke:#333,stroke-width:2px
    classDef util fill:#9b59b6,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1[Node.js Components]:::nodejs
        L2[Golang Components]:::golang
        L3[Core Processing]:::core
        L4[Transport Layer]:::transport
        L5[Security Components]:::security
        L6[Network Layer]:::network
        L7[External Services]:::external
        L8[Utility Services]:::util
    end
```
