# sexlovr/g-relay-railway architecture

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

- Interactive diagram: https://gitdiagram.com/sexlovr/g-relay-railway
- Repository: https://github.com/sexlovr/g-relay-railway

## Overview

g-relay-railway is a minimal HTTP relay for allowlisted Google hosts. A client can request a liveness check or submit a target using the query, path, or header form; the server optionally authenticates the request, validates the target, and forwards it over HTTP(S). Request bodies and upstream responses stream through without buffering, supporting long-lived connections. The README also documents optional host and key configuration and Railway deployment. The runtime details are shown in server.js; deployment setup is not a separate runtime subsystem.

Main entry points: [`server.js`](https://github.com/sexlovr/g-relay-railway/blob/main/server.js) (HTTP server)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["HTTP entry"]
  node_server["HTTP server<br/>[server.js]"]
  node_health["Health response<br/>[server.js]"]
end

subgraph group_validation["Request validation"]
  node_auth["Optional key check<br/>[server.js]"]
  node_target["Target selection<br/>[server.js]"]
  node_allowlist["Host validation<br/>[server.js]"]
end

subgraph group_relay["Streaming relay"]
  node_transport["HTTP&#40;S&#41; transport<br/>[server.js]"]
  node_response["Relayed response<br/>[server.js]"]
end

node_client(("HTTP client"))
node_google(("Allowed upstream hosts"))

node_client -->|"sends request"| node_server
node_server -->|"answers health"| node_health
node_server -->|"checks key"| node_auth
node_server -->|"selects target"| node_target
node_server -->|"validates host"| node_allowlist
node_server -->|"dispatches request"| node_transport
node_transport -->|"forwards stream"| node_google
node_google -->|"returns response"| node_response
node_transport -->|"streams response"| node_response
node_response -->|"sends response"| node_client

click node_server "https://github.com/sexlovr/g-relay-railway/blob/main/server.js"
click node_health "https://github.com/sexlovr/g-relay-railway/blob/main/server.js"
click node_auth "https://github.com/sexlovr/g-relay-railway/blob/main/server.js"
click node_target "https://github.com/sexlovr/g-relay-railway/blob/main/server.js"
click node_allowlist "https://github.com/sexlovr/g-relay-railway/blob/main/server.js"
click node_transport "https://github.com/sexlovr/g-relay-railway/blob/main/server.js"
click node_response "https://github.com/sexlovr/g-relay-railway/blob/main/server.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_server,node_health,node_client toneBlue
class node_auth,node_target,node_allowlist toneAmber
class node_transport,node_response toneMint
class node_google toneIndigo
```

## Components

### HTTP entry

- [HTTP server](https://github.com/sexlovr/g-relay-railway/blob/main/server.js): `server.js`
- [Health response](https://github.com/sexlovr/g-relay-railway/blob/main/server.js): `server.js`

### Request validation

- [Optional key check](https://github.com/sexlovr/g-relay-railway/blob/main/server.js): `server.js`
- [Target selection](https://github.com/sexlovr/g-relay-railway/blob/main/server.js): `server.js`
- [Host validation](https://github.com/sexlovr/g-relay-railway/blob/main/server.js): `server.js`

### Streaming relay

- [HTTP(S) transport](https://github.com/sexlovr/g-relay-railway/blob/main/server.js): `server.js`
- [Relayed response](https://github.com/sexlovr/g-relay-railway/blob/main/server.js): `server.js`

### Other components

- **HTTP client**
- **Allowed upstream hosts**

## Connections

- HTTP client → HTTP server: sends request (evidence: `server.js`)
- HTTP server → Health response: answers health (evidence: `server.js`)
- HTTP server → Optional key check: checks key (evidence: `server.js`)
- HTTP server → Target selection: selects target (evidence: `server.js`)
- HTTP server → Host validation: validates host (evidence: `server.js`)
- HTTP server → HTTP(S) transport: dispatches request (evidence: `server.js`)
- HTTP(S) transport → Allowed upstream hosts: forwards stream (evidence: `server.js`)
- Allowed upstream hosts → Relayed response: returns response (evidence: `server.js`)
- HTTP(S) transport → Relayed response: streams response (evidence: `server.js`)
- Relayed response → HTTP client: sends response (evidence: `server.js`)
