# wollomatic/socket-proxy architecture

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

- Interactive diagram: https://gitdiagram.com/wollomatic/socket-proxy
- Repository: https://github.com/wollomatic/socket-proxy

## Overview

##### Main Components Identification

a. Core Proxy Service
- Unix Socket Input (docker.sock or custom socket)
- TCP/Unix Socket Output
- Request Filter/Router
- Security Layer

b. Supporting Components
- Health Check Service
- Socket Watchdog
- Configuration Manager

**TOP LAYER: Client Applications**
**↓**
**MIDDLE LAYER: Socket-Proxy Components**
**↓**
**BOTTOM LAYER: Unix Socket (Docker daemon or other)**

##### Component Relationships

a. Input Flow:
- Client Applications → Socket-Proxy (TCP/Unix)
- Security Layer (IP/Hostname Verification)
- Request Filter (HTTP Method + Path Validation)
- Unix Socket Connection

b. Control Flow:
- Configuration Manager → All Components
- Watchdog → Socket Connection
- Health Check → Proxy Service

##### Specific Implementation Details

- Rectangles: Main processing components
- Diamonds: Decision points (security checks)
- Hexagons: Supporting services

- Blue: Core proxy functionality
- Red: Security components
- Green: Health/monitoring components
- Gray: External components (clients/socket)

**Security Layer:**
- IP/Hostname allowlist
- Default: 127.0.0.1/32

**Request Filter:**
- Method-specific regexp patterns
- Secure by default (deny-all)

**Configuration:**
- Command line parameters
- Environment variables
- Default values

##### Implementation Notes

a. Security-First Design:
- Multiple security checkpoints
- Default-deny approach
- Configuration validation

b. Monitoring Capabilities:
- Health check endpoint (optional)
- Socket watchdog
- Debug logging capability

c. Flexibility:
- Multiple input/output options
- Configurable security rules
- Various deployment scenarios

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Clients
        C1[Client Application 1]
        C2[Client Application 2]
    end

    subgraph "Socket-Proxy System"
        direction TB
        PS["Core Proxy Service"]:::core
        click PS "https://github.com/wollomatic/socket-proxy/blob/main/cmd/socket-proxy/main.go"
        
        subgraph "Security & Routing Layer"
            direction TB
            SL{IP/Hostname Verification}:::security
            RF["Request Filter/Router"]:::security
            click RF "https://github.com/wollomatic/socket-proxy/blob/main/cmd/socket-proxy/handlehttprequest.go"
        end
        
        subgraph "Management Layer"
            direction TB
            CM["Configuration Manager"]:::config
            click CM "https://github.com/wollomatic/socket-proxy/blob/main/internal/config/config.go"
            SCM["Socket Connection Manager"]:::monitor
            click SCM "https://github.com/wollomatic/socket-proxy/blob/main/cmd/socket-proxy/checksocketconnection.go"
            HC["Health Check Service"]:::monitor
            click HC "https://github.com/wollomatic/socket-proxy/blob/main/cmd/healthcheck/main.go"
        end

        EX["Example Implementations"]:::example
        click EX "https://github.com/wollomatic/socket-proxy/tree/main/examples/docker-compose/"
    end

    subgraph "Target Socket"
        US[("Unix Socket\n(docker.sock/custom)")]:::socket
    end

    %% Connections
    C1 --> PS
    C2 --> PS
    PS --> SL
    SL --> RF
    RF --> US
    
    CM --> PS
    CM --> RF
    CM --> SL
    
    SCM -.-> US
    HC -.-> PS

    %% Styles
    classDef core fill:#2374ab,stroke:#2374ab,color:white
    classDef security fill:#ff6b6b,stroke:#ff6b6b,color:white
    classDef config fill:#4ecdc4,stroke:#4ecdc4,color:white
    classDef monitor fill:#45b7d1,stroke:#45b7d1,color:white
    classDef socket fill:#666666,stroke:#666666,color:white
    classDef example fill:#95a5a6,stroke:#95a5a6,color:white

    %% Legend
    subgraph Legend
        L1[Core Service]:::core
        L2[Security Component]:::security
        L3[Configuration]:::config
        L4[Monitoring]:::monitor
        L5[Socket]:::socket
        L6[Example]:::example
    end
```
