# tkohegyi/mitmjavaproxy architecture

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

## Overview

##### Core Proxy Components
- ProxyServer (Main entry point)
- Request Interceptor System
- Response Interceptor System
- SSL/TLS Handler
- Certificate Management System

##### HTTP/HTTPS Processing Layer
- HTTP Client Handler
- HTTP Server Handler
- Message Processing Pipeline
- Content Encoding/Decoding System

##### External Interfaces
- Client Connection Point
- Server Connection Point
- Certificate Authority Interface

- [Client] <---> [MITM Proxy Server] <---> [Target Server]

##### Detailed Component Breakdown
- [Client]
- ↓
- [SSL/TLS Layer]
- ↓
- [Request Interceptor Chain]
- ↓
- [HTTP Processing]
- ↓
- [Response Interceptor Chain]
- ↓
- [Target Server]

- Blue: Core proxy components
- Green: Security-related components (SSL/TLS, Certificates)
- Yellow: Interceptor components
- Gray: Utility and support components

Key Relationships to Highlight:

##### Message Flow
- Points of interception
- Content manipulation possibilities

##### Security Layer
- Certificate Authority integration
- SSL/TLS handling
- Trust chain management

##### Interceptor Chain
- Request modification points
- Response volatility handling
- Content manipulation capabilities

Special Considerations:

##### Dual-nature of the proxy
- Client-facing interface
- Server-facing interface

##### Certificate management system
- CA certificate generation
- Certificate distribution
- Trust establishment

##### Features
- HTTP/HTTPS support
- Message manipulation capabilities
- Content encoding/decoding

Implementation Details to Include:

##### Core Classes
- ProxyServer
- RequestInterceptor
- ResponseInterceptor
- CertificateCreator

##### Support Systems
- ThreadPool management
- Connection handling
- Resource management

- Message flow directions
- Interception points
- Security boundaries
- Component types
- Integration points

Level of Detail:
- Keep high-level architecture visible
- Major components and their interactions
- Integration points
- Security boundaries
- Extension points for interceptors

Remember to include notes about the security implications and proper usage contexts, as emphasized in the README's warning section.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Client["Client Layer"]
        C[Client]
    end

    subgraph Proxy["MITM Proxy Server"]
        direction TB
        PS["Proxy Server"]:::core
        click PS "https://github.com/tkohegyi/mitmJavaProxy/blob/master/src/main/java/website/magyar/mitm/proxy/ProxyServer.java"

        subgraph Security["Security Layer"]
            direction TB
            SSL["SSL/TLS Handler"]:::security
            click SSL "https://github.com/tkohegyi/mitmJavaProxy/blob/master/src/main/java/net/lightbody/bmp/proxy/http/TrustingSSLSocketFactory.java"
            CERT["Certificate Management"]:::security
            click CERT "https://github.com/tkohegyi/mitmJavaProxy/blob/master/src/main/java/net/lightbody/bmp/proxy/selenium/CertificateCreator.java"
        end

        subgraph Interceptors["Interceptor Layer"]
            direction TB
            REQ["Request Interceptor"]:::interceptor
            click REQ "https://github.com/tkohegyi/mitmJavaProxy/blob/master/src/main/java/website/magyar/mitm/proxy/RequestInterceptor.java"
            RESP["Response Interceptor"]:::interceptor
            click RESP "https://github.com/tkohegyi/mitmJavaProxy/blob/master/src/main/java/website/magyar/mitm/proxy/ResponseInterceptor.java"
        end

        subgraph HTTP["HTTP Processing Layer"]
            direction TB
            HANDLER["HTTP Handler"]:::http
            click HANDLER "https://github.com/tkohegyi/mitmJavaProxy/blob/master/src/main/java/net/lightbody/bmp/proxy/jetty/http/HttpHandler.java"
            CONN["HTTP Connection"]:::http
            click CONN "https://github.com/tkohegyi/mitmJavaProxy/blob/master/src/main/java/net/lightbody/bmp/proxy/jetty/http/HttpConnection.java"
            HDR["Header Management"]:::http
            click HDR "https://github.com/tkohegyi/mitmJavaProxy/tree/master/src/main/java/website/magyar/mitm/proxy/header"
        end

        subgraph Bootstrap["Bootstrap Layer"]
            direction TB
            BOOT["Bootstrap"]:::bootstrap
            click BOOT "https://github.com/tkohegyi/mitmJavaProxy/blob/master/src/main/java/website/magyar/mitm/standalone/Bootstrap.java"
            STANDALONE["Standalone Proxy"]:::bootstrap
            click STANDALONE "https://github.com/tkohegyi/mitmJavaProxy/blob/master/src/main/java/website/magyar/mitm/standalone/StandaloneProxy.java"
        end
    end

    subgraph Server["Server Layer"]
        S[Target Server]
    end

    C --> PS
    PS --> Security
    Security --> Interceptors
    Interceptors --> HTTP
    HTTP --> S
    S --> HTTP
    HTTP --> Interceptors
    Interceptors --> Security
    Security --> PS
    PS --> C

    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef security fill:#4CAF50,stroke:#2E7D32,color:white
    classDef interceptor fill:#FFC107,stroke:#FFA000,color:black
    classDef http fill:#9E9E9E,stroke:#616161,color:white
    classDef bootstrap fill:#795548,stroke:#5D4037,color:white

    %% Legend
    subgraph Legend
        L1[Core Components]:::core
        L2[Security Components]:::security
        L3[Interceptor Components]:::interceptor
        L4[HTTP Components]:::http
        L5[Bootstrap Components]:::bootstrap
    end
```
