# mike10004/har-replay architecture

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

- Interactive diagram: https://gitdiagram.com/mike10004/har-replay
- Repository: https://github.com/mike10004/har-replay

## Overview

##### Main Components

a. Core Components:
- HAR File Storage
- Proxy Server
- Replay Manager
- Request Matcher
- Response Encoder
- Configuration Manager

b. Integration Components:
- Browser Interface
- HTTP Client Interface
- Certificate Management System
- Variable Dictionary

##### Component Relationships

**[Client (Browser/HTTP Client)] → [Proxy Server]**
- ↓
- [Replay Manager]
- ↓
- [Request Matcher/Parser] ← [HAR File]
- ↓
- [Response Encoder] → [Response Interceptor]
- ↓
- [Client]

##### Architectural Patterns to Highlight

- Bridge Pattern (evident from the harbridge package)
- Factory Pattern (seen in various factory classes)
- Interceptor Pattern (for response manipulation)
- State Pattern (for session management)

##### Specific Implementation Details

a. Core Modules (from project structure):
- har-replay-core: Core functionality
- har-replay-vhs: VHS implementation
- virtual-har-server: Server implementation
- har-replay-exec: Execution module

b. Key Features:
- TLS/SSL support (shown by certificate management)
- Multiple browser support
- Content encoding handling
- Variable substitution

##### Technical Stack Elements

- Java-based implementation
- BrowserMob Proxy integration
- Selenium WebDriver support
- Maven build system

**┌─ Client Layer ─────────────────────┐**
- Web Browsers                     │
- HTTP Clients                     │
- Selenium WebDriver               │
- ┬───────────────────┘
- ↓
**┌─ Proxy Layer ─────────────────────┐**
- HTTP/HTTPS Proxy                │
- Certificate Management          │
- Request Interception            │
- ┬───────────────────┘
- ↓
**┌─ Core Layer ──────────────────────┐**
- Replay Manager                  │
- Request Matcher                 │
- Response Encoder                │
- Variable Dictionary             │
- ┬───────────────────┘
- ↓
**┌─ Storage Layer ────────────────────┐**
- HAR File Processing             │
- Response Cache                  │
- Configuration Store             │
- ┘

##### Additional Notes
- Version information (current: 0.26)
- Supported protocols (HTTP/HTTPS)
- Temporary storage locations
- Entry points (CLI and Library interfaces)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Define styles
    classDef client fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef storage fill:#FFD700,stroke:#333,stroke-width:2px
    classDef processing fill:#FFA500,stroke:#333,stroke-width:2px
    classDef support fill:#D3D3D3,stroke:#333,stroke-width:2px

    %% Client Layer
    subgraph ClientLayer
        Browser["Browser Interface"]:::client
        HTTPClient["HTTP Client Interface"]:::client
    end

    %% Proxy Layer
    subgraph ProxyLayer
        ProxyServer["Proxy Server"]:::core
        CertMgmt["Certificate Management"]:::support
    end

    %% Core Layer
    subgraph CoreLayer
        ReplayMgr["Replay Manager"]:::core
        ReqMatcher["Request Matcher"]:::core
        RespEncoder["Response Encoder"]:::processing
        VarDict["Variable Dictionary"]:::support
        RespInterceptor["Response Interceptor"]:::processing
        ConfigMgr["Configuration Manager"]:::support
    end

    %% Storage Layer
    subgraph StorageLayer
        HARFile["HAR File Storage"]:::storage
    end

    %% Relationships
    Browser --> ProxyServer
    HTTPClient --> ProxyServer
    ProxyServer --> CertMgmt
    ProxyServer --> ReplayMgr
    ReplayMgr --> ReqMatcher
    ReqMatcher --> HARFile
    ReqMatcher --> RespEncoder
    RespEncoder --> RespInterceptor
    RespInterceptor --> ProxyServer
    VarDict --> ReqMatcher
    ConfigMgr --> ReplayMgr

    %% Click events for component mapping
    click ReplayMgr "https://github.com/mike10004/har-replay/blob/master/har-replay-core/src/main/java/io/github/mike10004/harreplay/ReplayManager.java"
    click ReqMatcher "https://github.com/mike10004/har-replay/blob/master/virtual-har-server/src/main/java/io/github/mike10004/vhs/EntryMatcher.java"
    click ProxyServer "https://github.com/mike10004/har-replay/blob/master/virtual-har-server/src/main/java/io/github/mike10004/vhs/VirtualHarServer.java"
    click RespEncoder "https://github.com/mike10004/har-replay/blob/master/virtual-har-server/src/main/java/io/github/mike10004/vhs/harbridge/HarResponseEncoding.java"
    click ConfigMgr "https://github.com/mike10004/har-replay/blob/master/har-replay-core/src/main/java/io/github/mike10004/harreplay/ReplayServerConfig.java"
    click Browser "https://github.com/mike10004/har-replay/blob/master/har-replay-exec/src/main/java/io/github/mike10004/harreplay/exec/BrowserSupport.java"
    click CertMgmt "https://github.com/mike10004/har-replay/blob/master/virtual-har-server/src/main/java/io/github/mike10004/vhs/bmp/JreKeystoreGenerator.java"
    click VarDict "https://github.com/mike10004/har-replay/blob/master/har-replay-core/src/main/java/io/github/mike10004/harreplay/VariableDictionary.java"
    click HTTPClient "https://github.com/mike10004/har-replay/blob/master/virtual-har-server/src/main/java/io/github/mike10004/vhs/HttpRequests.java"
    click RespInterceptor "https://github.com/mike10004/har-replay/blob/master/virtual-har-server/src/main/java/io/github/mike10004/vhs/ResponseInterceptor.java"

    %% Legend
    subgraph Legend
        Client["Client Components"]:::client
        Core["Core Components"]:::core
        Storage["Storage Components"]:::storage
        Processing["Processing Components"]:::processing
        Support["Support Components"]:::support
    end
```
