# jalallinux/relay architecture

> Architecture diagram of the GitHub repository jalallinux/relay, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jalallinux/relay
- Repository: https://github.com/jalallinux/relay

## Overview

Relay is a small anonymous HTTPS reverse proxy, offered as three independent runtimes: Go, Node.js, and Cloudflare Workers. The user sends an HTTP request to the relay; each runtime validates its configured upstream, appends the incoming path and query, forwards a restricted header set and streams the upstream response back without following redirects. Runtime-specific behavior includes server logging and configurable HTTP upstreams for Go/Node, while the Worker requires HTTPS. Edges are based on the README and sampled entrypoint implementations; each runtime is an alternative, not a shared pipeline.

Main entry points: [`go/main.go`](https://github.com/jalallinux/relay/blob/main/go/main.go) (Go relay handler), [`js/server.mjs`](https://github.com/jalallinux/relay/blob/main/js/server.mjs) (Node relay handler), [`cloudflare/worker.js`](https://github.com/jalallinux/relay/blob/main/cloudflare/worker.js) (Worker fetch handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_server["Self-hosted servers"]
  node_go_server["Go HTTP server<br/>[main.go]"]
  node_go_handler["Go relay handler<br/>[main.go]"]
  node_node_server["Node HTTP server<br/>[server.mjs]"]
  node_node_handler["Node relay handler<br/>[server.mjs]"]
end

subgraph group_edge["Edge worker"]
  node_worker_entry["Worker fetch handler<br/>[worker.js]"]
end

node_client(("API client"))
node_go_upstream{{"Configured upstream"}}
node_node_upstream{{"Configured upstream"}}
node_worker_upstream{{"Configured upstream"}}

node_client -->|"sends request"| node_go_server
node_go_server -->|"dispatches to"| node_go_handler
node_go_handler -->|"forwards request"| node_go_upstream
node_go_handler -->|"streams response"| node_go_server
node_client -->|"sends request"| node_node_server
node_node_server -->|"dispatches to"| node_node_handler
node_node_handler -->|"fetches request"| node_node_upstream
node_node_handler -->|"streams response"| node_node_server
node_client -->|"sends request"| node_worker_entry
node_worker_entry -->|"fetches request"| node_worker_upstream
node_worker_entry -->|"returns response"| node_client

click node_go_server "https://github.com/jalallinux/relay/blob/main/go/main.go"
click node_go_handler "https://github.com/jalallinux/relay/blob/main/go/main.go"
click node_node_server "https://github.com/jalallinux/relay/blob/main/js/server.mjs"
click node_node_handler "https://github.com/jalallinux/relay/blob/main/js/server.mjs"
click node_worker_entry "https://github.com/jalallinux/relay/blob/main/cloudflare/worker.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_go_server,node_go_handler,node_node_server,node_node_handler,node_client toneBlue
class node_worker_entry toneAmber
class node_go_upstream,node_node_upstream,node_worker_upstream toneIndigo
```

## Components

### Self-hosted servers

- [Go HTTP server](https://github.com/jalallinux/relay/blob/main/go/main.go): `go/main.go`
- [Go relay handler](https://github.com/jalallinux/relay/blob/main/go/main.go): `go/main.go`
- [Node HTTP server](https://github.com/jalallinux/relay/blob/main/js/server.mjs): `js/server.mjs`
- [Node relay handler](https://github.com/jalallinux/relay/blob/main/js/server.mjs): `js/server.mjs`

### Edge worker

- [Worker fetch handler](https://github.com/jalallinux/relay/blob/main/cloudflare/worker.js): `cloudflare/worker.js`

### Other components

- **API client**
- **Configured upstream**
- **Configured upstream**
- **Configured upstream**

## Connections

- API client → Go HTTP server: sends request (evidence: `README.md`)
- Go HTTP server → Go relay handler: dispatches to (evidence: `go/main.go`)
- Go relay handler → Configured upstream: forwards request (evidence: `go/main.go`)
- Go relay handler → Go HTTP server: streams response (evidence: `go/main.go`)
- API client → Node HTTP server: sends request (evidence: `README.md`)
- Node HTTP server → Node relay handler: dispatches to (evidence: `js/server.mjs`)
- Node relay handler → Configured upstream: fetches request (evidence: `js/server.mjs`)
- Node relay handler → Node HTTP server: streams response (evidence: `js/server.mjs`)
- API client → Worker fetch handler: sends request (evidence: `README.md`)
- Worker fetch handler → Configured upstream: fetches request (evidence: `cloudflare/worker.js`)
- Worker fetch handler → API client: returns response (evidence: `cloudflare/worker.js`)
