# samirbekjs/jprq architecture

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

- Interactive diagram: https://gitdiagram.com/samirbekjs/jprq
- Repository: https://github.com/samirbekjs/jprq

## Overview

JPRQ exposes a user’s local HTTP or arbitrary TCP service through a public tunnel. The CLI stores credentials, requests a tunnel, then relays incoming connections between the remote server and the local service; optional HTTP debugging observes relayed traffic. On the hosted side, the server authenticates and authorizes requests, provisions protocol-specific tunnels, and routes public traffic. The website handles browser-based GitHub token acquisition. README capabilities also include static-file serving, custom subdomains/CNAMEs, and debugger support. Some server internals were not excerpted, so relationships without direct evidence are omitted.

Main entry points: [`cli/jprqc.go`](https://github.com/samirbekjs/jprq/blob/master/cli/jprqc.go) (Tunnel client), [`server/jprq.go`](https://github.com/samirbekjs/jprq/blob/master/server/jprq.go) (Tunnel coordinator), [`cli/main.go`](https://github.com/samirbekjs/jprq/blob/master/cli/main.go) (Command entry), [`server/github/github.go`](https://github.com/samirbekjs/jprq/blob/master/server/github/github.go) (GitHub auth)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI and client"]
  node_cli["Command entry<br/>[main.go]"]
  node_client["Tunnel client<br/>[jprqc.go]"]
  node_config["Client config<br/>[config.go]"]
  node_staticserve["Static file server<br/>[main.go]"]
end

subgraph group_tunnel["Tunnel service"]
  node_servermain["Server entry<br/>[main.go]"]
  node_control["Tunnel coordinator<br/>[jprq.go]"]
  node_tcpserver["TCP listeners<br/>[tcpserver.go]"]
  node_events["Tunnel events<br/>[events.go]"]
  node_tcptunnel["TCP tunnel<br/>[tcp_tunnel.go]"]
  node_httptunnel["HTTP tunnel<br/>[http_tunnel.go]"]
  node_relay["Connection relay<br/>[tunnel.go]"]
end

subgraph group_identity["Identity and access"]
  node_githubauth["GitHub auth<br/>[github.go]"]
  node_accessconfig["Server config<br/>[config.go]"]
  node_allowlist["User allow-list<br/>[jprq.go]"]
end

subgraph group_web["Auth website"]
  node_website["Auth website<br/>[main.go]"]
end

subgraph group_debug["HTTP debugging"]
  node_debugger["Debugger server<br/>[server.go]"]
  node_parser["HTTP parser<br/>[parser.go]"]
  node_debugui["Debugger UI<br/>[script.js]"]
end

node_user(("CLI user"))
node_localservice(("Local service"))
node_github["GitHub OAuth"]
node_authservice["Access validation"]

node_user -->|"runs command"| node_cli
node_cli -->|"loads config"| node_config
node_cli -->|"writes token"| node_config
node_cli -->|"starts serving"| node_staticserve
node_cli -->|"starts tunnel"| node_client
node_client -->|"reads credentials"| node_config
node_client -->|"sends request"| node_events
node_client -->|"reads events"| node_events
node_client -->|"dials service"| node_localservice
node_client -->|"relays traffic"| node_relay
node_servermain -->|"loads config"| node_accessconfig
node_servermain -->|"creates authenticator"| node_githubauth
node_servermain -->|"initializes and starts"| node_control
node_control -->|"uses settings"| node_accessconfig
node_control -->|"authenticates users"| node_githubauth
node_control -->|"reads and writes"| node_events
node_control -->|"starts listeners"| node_tcpserver
node_control -->|"creates TCP tunnel"| node_tcptunnel
node_control -->|"creates HTTP tunnel"| node_httptunnel
node_control -->|"refreshes users"| node_allowlist
node_tcptunnel -->|"initializes listeners"| node_tcpserver
node_tcptunnel -.->|"inherits relay handling"| node_relay
node_httptunnel -.->|"uses shared relay"| node_relay
node_githubauth -->|"requests profile and token"| node_github
node_githubauth -->|"checks access"| node_authservice
node_website -->|"uses OAuth client"| node_githubauth
node_website -->|"redirects for OAuth"| node_github
node_client -->|"starts optional debugger"| node_debugger
node_client -->|"provides traffic streams"| node_debugger
node_debugger -->|"parses streams"| node_parser
node_debugui -.->|"subscribes to events"| node_debugger

click node_cli "https://github.com/samirbekjs/jprq/blob/master/cli/main.go"
click node_client "https://github.com/samirbekjs/jprq/blob/master/cli/jprqc.go"
click node_config "https://github.com/samirbekjs/jprq/blob/master/cli/config.go"
click node_staticserve "https://github.com/samirbekjs/jprq/blob/master/cli/main.go"
click node_servermain "https://github.com/samirbekjs/jprq/blob/master/server/main.go"
click node_control "https://github.com/samirbekjs/jprq/blob/master/server/jprq.go"
click node_tcpserver "https://github.com/samirbekjs/jprq/blob/master/server/server/tcpserver.go"
click node_events "https://github.com/samirbekjs/jprq/blob/master/server/events/events.go"
click node_tcptunnel "https://github.com/samirbekjs/jprq/blob/master/server/tunnel/tcp_tunnel.go"
click node_httptunnel "https://github.com/samirbekjs/jprq/blob/master/server/tunnel/http_tunnel.go"
click node_relay "https://github.com/samirbekjs/jprq/blob/master/server/tunnel/tunnel.go"
click node_githubauth "https://github.com/samirbekjs/jprq/blob/master/server/github/github.go"
click node_accessconfig "https://github.com/samirbekjs/jprq/blob/master/server/config/config.go"
click node_allowlist "https://github.com/samirbekjs/jprq/blob/master/server/jprq.go"
click node_website "https://github.com/samirbekjs/jprq/blob/master/website/main.go"
click node_debugger "https://github.com/samirbekjs/jprq/blob/master/cli/debugger/server.go"
click node_parser "https://github.com/samirbekjs/jprq/blob/master/cli/debugger/parser.go"
click node_debugui "https://github.com/samirbekjs/jprq/blob/master/cli/debugger/static/script.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_cli,node_client,node_config,node_staticserve,node_user toneBlue
class node_servermain,node_control,node_tcpserver,node_events,node_tcptunnel,node_httptunnel,node_relay toneAmber
class node_githubauth,node_accessconfig,node_allowlist toneMint
class node_website toneRose
class node_debugger,node_parser,node_debugui,node_localservice,node_github,node_authservice toneIndigo
```

## Components

### CLI and client

- [Command entry](https://github.com/samirbekjs/jprq/blob/master/cli/main.go): `cli/main.go`
- [Tunnel client](https://github.com/samirbekjs/jprq/blob/master/cli/jprqc.go): `cli/jprqc.go`
- [Client config](https://github.com/samirbekjs/jprq/blob/master/cli/config.go): `cli/config.go`
- [Static file server](https://github.com/samirbekjs/jprq/blob/master/cli/main.go): `cli/main.go`

### Tunnel service

- [Server entry](https://github.com/samirbekjs/jprq/blob/master/server/main.go): `server/main.go`
- [Tunnel coordinator](https://github.com/samirbekjs/jprq/blob/master/server/jprq.go): `server/jprq.go`
- [TCP listeners](https://github.com/samirbekjs/jprq/blob/master/server/server/tcpserver.go): `server/server/tcpserver.go`
- [Tunnel events](https://github.com/samirbekjs/jprq/blob/master/server/events/events.go): `server/events/events.go`
- [TCP tunnel](https://github.com/samirbekjs/jprq/blob/master/server/tunnel/tcp_tunnel.go): `server/tunnel/tcp_tunnel.go`
- [HTTP tunnel](https://github.com/samirbekjs/jprq/blob/master/server/tunnel/http_tunnel.go): `server/tunnel/http_tunnel.go`
- [Connection relay](https://github.com/samirbekjs/jprq/blob/master/server/tunnel/tunnel.go): `server/tunnel/tunnel.go`

### Identity and access

- [GitHub auth](https://github.com/samirbekjs/jprq/blob/master/server/github/github.go): `server/github/github.go`
- [Server config](https://github.com/samirbekjs/jprq/blob/master/server/config/config.go): `server/config/config.go`
- [User allow-list](https://github.com/samirbekjs/jprq/blob/master/server/jprq.go): `server/jprq.go`

### Auth website

- [Auth website](https://github.com/samirbekjs/jprq/blob/master/website/main.go): `website/main.go`

### HTTP debugging

- [Debugger server](https://github.com/samirbekjs/jprq/blob/master/cli/debugger/server.go): `cli/debugger/server.go`
- [HTTP parser](https://github.com/samirbekjs/jprq/blob/master/cli/debugger/parser.go): `cli/debugger/parser.go`
- [Debugger UI](https://github.com/samirbekjs/jprq/blob/master/cli/debugger/static/script.js): `cli/debugger/static/script.js`

### Other components

- **CLI user**
- **Local service**
- **GitHub OAuth**
- **Access validation**

## Connections

- CLI user → Command entry: runs command (evidence: `readme.md`)
- Command entry → Client config: loads config (evidence: `cli/main.go`)
- Command entry → Client config: writes token (evidence: `cli/main.go`)
- Command entry → Static file server: starts serving (evidence: `cli/main.go`)
- Command entry → Tunnel client: starts tunnel (evidence: `cli/main.go`)
- Tunnel client → Client config: reads credentials (evidence: `cli/jprqc.go`)
- Tunnel client → Tunnel events: sends request (evidence: `cli/jprqc.go`)
- Tunnel client → Tunnel events: reads events (evidence: `cli/jprqc.go`)
- Tunnel client → Local service: dials service (evidence: `cli/jprqc.go`)
- Tunnel client → Connection relay: relays traffic (evidence: `cli/jprqc.go`)
- Server entry → Server config: loads config (evidence: `server/main.go`)
- Server entry → GitHub auth: creates authenticator (evidence: `server/main.go`)
- Server entry → Tunnel coordinator: initializes and starts (evidence: `server/main.go`)
- Tunnel coordinator → Server config: uses settings (evidence: `server/jprq.go`)
- Tunnel coordinator → GitHub auth: authenticates users (evidence: `server/jprq.go`)
- Tunnel coordinator → Tunnel events: reads and writes (evidence: `server/jprq.go`)
- Tunnel coordinator → TCP listeners: starts listeners (evidence: `server/jprq.go`)
- Tunnel coordinator → TCP tunnel: creates TCP tunnel (evidence: `server/jprq.go`)
- Tunnel coordinator → HTTP tunnel: creates HTTP tunnel (evidence: `server/jprq.go`)
- Tunnel coordinator → User allow-list: refreshes users (evidence: `server/jprq.go`)
- TCP tunnel → TCP listeners: initializes listeners (evidence: `server/tunnel/tcp_tunnel.go`)
- TCP tunnel → Connection relay: inherits relay handling
- HTTP tunnel → Connection relay: uses shared relay
- GitHub auth → GitHub OAuth: requests profile and token (evidence: `server/github/github.go`)
- GitHub auth → Access validation: checks access (evidence: `server/github/github.go`)
- Auth website → GitHub auth: uses OAuth client (evidence: `website/main.go`)
- Auth website → GitHub OAuth: redirects for OAuth (evidence: `website/main.go`)
- Tunnel client → Debugger server: starts optional debugger (evidence: `cli/jprqc.go`)
- Tunnel client → Debugger server: provides traffic streams (evidence: `cli/jprqc.go`)
- Debugger server → HTTP parser: parses streams (evidence: `cli/debugger/server.go`)
- Debugger UI → Debugger server: subscribes to events
