# lexiforest/curl-impersonate architecture

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

- Interactive diagram: https://gitdiagram.com/lexiforest/curl-impersonate
- Repository: https://github.com/lexiforest/curl-impersonate

## Overview

##### Main Components

a) Core Components:
- libcurl-impersonate (Modified libcurl)
- BoringSSL Integration (Google's TLS library)
- Browser Impersonation Engine
- Command-line Interface
- Library Interface (libcurl-impersonate.so)

b) Browser Support Modules:
- Chrome/Chromium Implementation
- Edge Implementation
- Safari Implementation
- Firefox Implementation (in progress)

##### Key Relationships

a) Data Flow:
- Client Request → Command Line/Library Interface
- Browser Selection → Impersonation Engine
- TLS Handshake Flow
- HTTP/2 Handshake Flow

b) Integration Points:
- BoringSSL ↔ TLS Handler
- Browser Signatures ↔ Impersonation Engine
- Configuration Management

##### Architectural Elements

**[Client Applications]**
- ↓
**[Interface Layer]**
- CLI Wrappers (curl_chrome*, curl_safari*)
- Library API (libcurl-impersonate)
- ↓
**[Core Processing]**
- Browser Impersonation Engine
- Configuration Manager
- TLS/HTTP Handler
- ↓
**[Integration Layer]**
- BoringSSL Integration
- Browser Signatures
- ↓
**[Network Layer]**
- TLS Handshake
- HTTP/2 Protocol

##### Implementation Details to Highlight

- Blue: Core Components
- Green: Browser-specific Implementations
- Orange: External Dependencies
- Purple: Network Protocol Handlers

b) Special Features:
- TLS Extension Management
- HTTP/2 Settings Configuration
- Browser Signature Matching
- Certificate Handling

##### Configuration Elements

Configuration flows for:
- Browser Selection
- TLS Parameters
- HTTP Headers
- Cipher Suites
- Extension Orders

##### Testing & Validation

A section showing:
- Signature Verification
- Compatibility Testing
- Docker Testing Environment

##### Deployment Options

Different deployment methods:
- Direct Binary Usage
- Library Integration
- Docker Container
- LD_PRELOAD Usage

##### The integration points with external systems and libraries

Use standardized symbols:
- Rectangles: Components
- Diamonds: Decision Points
- Clouds: External Services/Networks

Keep the abstraction level high enough to show the overall architecture while including sufficient detail to understand the impersonation mechanism and configuration options.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Applications"]
        direction TB
        APP[Applications]
        CLI[Command Line Tools]
    end

    subgraph Interface["Interface Layer"]
        direction TB
        CHROME_CLI["Chrome CLI Wrappers"]:::cli
        SAFARI_CLI["Safari CLI Wrappers"]:::cli
        EDGE_CLI["Edge CLI Wrappers"]:::cli
        FF_CLI["Firefox CLI Wrappers"]:::cli
        LIB["libcurl-impersonate Library"]:::core
    end

    subgraph Core["Core Processing"]
        direction TB
        IMP_ENGINE["Browser Impersonation Engine"]:::core
        CONF_MGR["Configuration Manager"]:::core
        TLS_HANDLER["TLS/HTTP Handler"]:::core
    end

    subgraph Integration["Integration Layer"]
        direction TB
        BORING["BoringSSL Integration"]:::ext
        SIGNATURES["Browser Signatures"]:::data
        CURL_MOD["Core Curl Modifications"]:::core
    end

    subgraph Network["Network Layer"]
        direction TB
        TLS["TLS Handshake"]:::network
        HTTP2["HTTP/2 Protocol"]:::network
    end

    subgraph Support["Support Systems"]
        direction TB
        DOCKER["Docker Environment"]:::infra
        BUILD["Build System"]:::infra
        TEST["Testing Framework"]:::test
        WIN["Windows Support"]:::infra
    end

    %% Relationships
    APP & CLI --> Interface
    Interface --> IMP_ENGINE
    IMP_ENGINE --> CONF_MGR
    CONF_MGR --> TLS_HANDLER
    TLS_HANDLER --> BORING
    TLS_HANDLER --> SIGNATURES
    BORING & CURL_MOD --> Network
    
    %% Click Events
    click BORING "https://github.com/lexiforest/curl-impersonate/blob/main/chrome/patches/boringssl.patch"
    click CURL_MOD "https://github.com/lexiforest/curl-impersonate/blob/main/chrome/patches/curl-impersonate.patch"
    click CHROME_CLI "https://github.com/lexiforest/curl-impersonate/tree/main/chrome/curl_chrome*"
    click EDGE_CLI "https://github.com/lexiforest/curl-impersonate/tree/main/chrome/curl_edge*"
    click SAFARI_CLI "https://github.com/lexiforest/curl-impersonate/tree/main/chrome/curl_safari*"
    click FF_CLI "https://github.com/lexiforest/curl-impersonate/tree/main/chrome/curl_firefox120"
    click SIGNATURES "https://github.com/lexiforest/curl-impersonate/tree/main/tests/signatures/"
    click DOCKER "https://github.com/lexiforest/curl-impersonate/tree/main/docker/"
    click TEST "https://github.com/lexiforest/curl-impersonate/blob/main/tests/test_impersonate.py"
    click BUILD "https://github.com/lexiforest/curl-impersonate/tree/main/.github/workflows/"
    click CONF_MGR "https://github.com/lexiforest/curl-impersonate/blob/main/browsers.json"
    click WIN "https://github.com/lexiforest/curl-impersonate/tree/main/win/"

    %% Styling
    classDef core fill:#2374ab
    classDef cli fill:#2a9d8f
    classDef ext fill:#e76f51
    classDef network fill:#8338ec
    classDef data fill:#ffb703
    classDef infra fill:#606c38
    classDef test fill:#219ebc
```
