# pamelia/gorp architecture

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

- Interactive diagram: https://gitdiagram.com/pamelia/gorp
- Repository: https://github.com/pamelia/gorp

## Overview

##### Main Components

a) Client Layer:
- External clients making HTTP/HTTPS requests
- Clients with TLS certificates (for client verification)

b) Proxy Layer (Core):
- HTTP/2 Listener component
- TLS 1.3 Handler
- Client Certificate Verification module
- Load Balancer (Round-robin implementation)

c) Backend Layer:
- Multiple HTTP/HTTPS backend servers
- Backend TLS verification component
- CA certificate verification system

##### Component Organization

**[Clients] -> [GORP Proxy] -> [Backend Servers]**

##### Detailed Component Breakdown

For the proxy core (based on the pkg directory structure):
- Config Component (pkg/config)
- PKI Management (pkg/pki)
- Proxy Handler (pkg/proxy)
- Logger System (pkg/logger)

##### Key Relationships to Highlight

- TLS handshake flow
- Load balancing distribution
- Certificate verification points
- Configuration loading paths

##### Implementation Details

- Command handling (cmd/ directory)
- Configuration management (example_config.yaml)
- Core proxy logic (pkg/proxy)
- Security components (pkg/pki)

##### Specific Elements

**[Client Layer]**
**↓ TLS 1.3**
**[TLS Termination] → [Client Cert Verification]**
**↓**
**[Proxy Core]**
- Config Manager
- Logger
- Load Balancer
**↓**
**[Backend TLS Verification] → [CA Cert Check]**
**↓**
**[Backend Servers Pool]**

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef external fill:#3498db,stroke:#2980b9,color:white
    classDef security fill:#2ecc71,stroke:#27ae60,color:white
    classDef core fill:#e67e22,stroke:#d35400,color:white
    classDef support fill:#95a5a6,stroke:#7f8c8d,color:white
    
    %% Client Layer
    subgraph Clients
        C1[Client 1]
        C2[Client 2]
        C3[Client 3]
    end
    class C1,C2,C3 external

    %% Security Layer
    TLS{{"TLS 1.3 Termination"}}
    CERT{{"Client Cert Verification"}}
    class TLS,CERT security

    %% Proxy Core
    subgraph ProxyCore
        CLI["Command Interface"]
        MAIN["Main Service"]
        CONFIG["Configuration Manager"]
        PKI["PKI Handler"]
        PROXY["Proxy Engine"]
        LOGGER["Logger System"]
        LB["Load Balancer<br/>(Round-Robin)"]
    end
    class CLI,MAIN,CONFIG,PKI,PROXY,LOGGER,LB core

    %% Backend Layer
    subgraph Backends
        B1["Backend Server 1"]
        B2["Backend Server 2"]
        B3["Backend Server 3"]
    end
    class B1,B2,B3 external

    %% Backend Security
    BTLS{{"Backend TLS<br/>Verification"}}
    class BTLS security

    %% Relationships
    C1 & C2 & C3 --> TLS
    TLS --> CERT
    CERT --> MAIN
    MAIN --> CLI
    MAIN --> CONFIG
    CONFIG --> PKI
    PKI --> PROXY
    PROXY --> LOGGER
    PROXY --> LB
    LB --> BTLS
    BTLS --> B1 & B2 & B3

    %% Click Events
    click CLI "https://github.com/pamelia/gorp/blob/main/cmd/serve.go"
    click MAIN "https://github.com/pamelia/gorp/blob/main/main.go"
    click CONFIG "https://github.com/pamelia/gorp/blob/main/pkg/config/config.go"
    click PKI "https://github.com/pamelia/gorp/blob/main/pkg/pki/pki.go"
    click PROXY "https://github.com/pamelia/gorp/blob/main/pkg/proxy/proxy.go"
    click LOGGER "https://github.com/pamelia/gorp/blob/main/pkg/logger/logger.go"

    %% Legend
    subgraph Legend
        E1[External Components]:::external
        S1[Security Components]:::security
        C4[Core Components]:::core
        SP1[Support Components]:::support
    end
```
