# night-days/edgetunnel architecture

> Architecture diagram of the GitHub repository night-days/edgetunnel, 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/night-days/edgetunnel
- Repository: https://github.com/night-days/edgetunnel

## Overview

edgetunnel is a Cloudflare Workers/Pages edge tunnel with an admin panel and client-facing proxy and subscription features. Users connect through the deployed worker; the README documents protocol handling, subscription generation, configurable proxy paths, and administration. The implementation is a single large `_worker.js`, so distinct product responsibilities share that path. The excerpts show KV-backed logging/configuration and optional Telegram notification behavior; other feature boundaries and dispatch details are documented but not visible in the sampled code.

Main entry points: [`_worker.js`](https://github.com/night-days/edgetunnel/blob/main/_worker.js) (Request handler)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Edge runtime"]
  node_worker["Request handler<br/>[_worker.js]"]
end

subgraph group_management["Management"]
  node_admin["Admin panel<br/>[_worker.js]"]
  node_config["Runtime configuration<br/>[_worker.js]"]
  node_logs["Logs and statistics<br/>[_worker.js]"]
  node_kv[("Cloudflare KV")]
  node_telegram["Telegram notifications"]
end

subgraph group_connectivity["Tunnel and connectivity"]
  node_protocols["Protocol ingress<br/>[_worker.js]"]
  node_tunnel["Traffic forwarding<br/>[_worker.js]"]
  node_proxy["Proxy selection<br/>[_worker.js]"]
  node_subscriptions["Subscription generator<br/>[_worker.js]"]
  node_cf["Cloudflare network"]
  node_externalproxies["External proxies"]
end

node_users(("Clients and admins"))

node_users -->|"send requests"| node_worker
node_worker -->|"handles protocols"| node_protocols
node_worker -->|"generates subscriptions"| node_subscriptions
node_worker -->|"serves admin"| node_admin
node_worker -->|"forwards traffic"| node_tunnel
node_worker -->|"selects proxy"| node_proxy
node_worker -->|"reads settings"| node_config
node_worker -->|"records activity"| node_logs
node_logs -->|"writes logs"| node_kv
node_config -->|"reads configuration"| node_kv
node_logs -->|"sends notifications"| node_telegram
node_proxy -->|"connects through"| node_externalproxies
node_tunnel -.->|"uses edge platform"| node_cf

click node_worker "https://github.com/night-days/edgetunnel/blob/main/_worker.js"
click node_protocols "https://github.com/night-days/edgetunnel/blob/main/_worker.js"
click node_tunnel "https://github.com/night-days/edgetunnel/blob/main/_worker.js"
click node_proxy "https://github.com/night-days/edgetunnel/blob/main/_worker.js"
click node_subscriptions "https://github.com/night-days/edgetunnel/blob/main/_worker.js"
click node_admin "https://github.com/night-days/edgetunnel/blob/main/_worker.js"
click node_config "https://github.com/night-days/edgetunnel/blob/main/_worker.js"
click node_logs "https://github.com/night-days/edgetunnel/blob/main/_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_worker,node_users toneBlue
class node_admin,node_config,node_logs,node_kv,node_telegram toneAmber
class node_protocols,node_tunnel,node_proxy,node_subscriptions,node_cf,node_externalproxies toneMint
```

## Components

### Edge runtime

- [Request handler](https://github.com/night-days/edgetunnel/blob/main/_worker.js): `_worker.js`

### Management

- [Admin panel](https://github.com/night-days/edgetunnel/blob/main/_worker.js): `_worker.js`
- [Runtime configuration](https://github.com/night-days/edgetunnel/blob/main/_worker.js): `_worker.js`
- [Logs and statistics](https://github.com/night-days/edgetunnel/blob/main/_worker.js): `_worker.js`
- **Cloudflare KV**
- **Telegram notifications**

### Tunnel and connectivity

- [Protocol ingress](https://github.com/night-days/edgetunnel/blob/main/_worker.js): `_worker.js`
- [Traffic forwarding](https://github.com/night-days/edgetunnel/blob/main/_worker.js): `_worker.js`
- [Proxy selection](https://github.com/night-days/edgetunnel/blob/main/_worker.js): `_worker.js`
- [Subscription generator](https://github.com/night-days/edgetunnel/blob/main/_worker.js): `_worker.js`
- **Cloudflare network**
- **External proxies**

### Other components

- **Clients and admins**

## Connections

- Clients and admins → Request handler: send requests (evidence: `README.md`)
- Request handler → Protocol ingress: handles protocols (evidence: `README.md`)
- Request handler → Subscription generator: generates subscriptions (evidence: `README.md`)
- Request handler → Admin panel: serves admin (evidence: `README.md`)
- Request handler → Traffic forwarding: forwards traffic (evidence: `README.md`)
- Request handler → Proxy selection: selects proxy (evidence: `README.md`)
- Request handler → Runtime configuration: reads settings (evidence: `README.md`)
- Request handler → Logs and statistics: records activity (evidence: `_worker.js`)
- Logs and statistics → Cloudflare KV: writes logs (evidence: `_worker.js`)
- Runtime configuration → Cloudflare KV: reads configuration (evidence: `_worker.js`)
- Logs and statistics → Telegram notifications: sends notifications (evidence: `_worker.js`)
- Proxy selection → External proxies: connects through (evidence: `README.md`)
- Traffic forwarding → Cloudflare network: uses edge platform (evidence: `README.md`)
