# amirmohammaddsht-dev/backpack-railway architecture

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

- Interactive diagram: https://gitdiagram.com/amirmohammaddsht-dev/backpack-railway
- Repository: https://github.com/amirmohammaddsht-dev/backpack-railway

## Overview

Backpack-Railway packages a BackPack tunnel and a 3x-ui panel for deployment on Railway or Fly.io. The main workflow is to create a tunnel on the Iran server, provide its setup link and panel credentials as deployment variables, then use the tunnel to deliver traffic to a 3x-ui inbound. The container also exposes a secret-path BackPack status/log panel and a watchdog for tunnel recovery. Relationships below follow the README; source excerpts were not provided, so internal script-level calls are not inferred.

Main entry points: [`entrypoint.sh`](https://github.com/amirmohammaddsht-dev/backpack-railway/blob/main/entrypoint.sh) (Application container), [`apply-link.sh`](https://github.com/amirmohammaddsht-dev/backpack-railway/blob/main/apply-link.sh) (Setup-link application), [`supervisord.conf`](https://github.com/amirmohammaddsht-dev/backpack-railway/blob/main/supervisord.conf) (Process supervisor)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_deployment["Deployment and startup"]
  node_container["Application container<br/>[entrypoint.sh]"]
  node_supervisor["Process supervisor<br/>[supervisord.conf]"]
end

subgraph group_tunnel["Tunnel connectivity"]
  node_link_setup["Setup-link application<br/>[apply-link.sh]"]
  node_backpack["BackPack tunnel"]
end

subgraph group_panels["Panels and traffic"]
  node_xui["3x-ui panel and inbounds"]
  node_panel_config["Panel configuration<br/>[panel-config.sh]"]
  node_web_panel["BackPack web panel"]
end

subgraph group_reliability["Tunnel reliability"]
  node_watchdog["Tunnel watchdog"]
  node_fake_systemctl["Systemctl shim<br/>[fake_systemctl.sh]"]
  node_fake_journalctl["Journal shim<br/>[fake_journalctl.sh]"]
end

node_user(("Operator"))
node_platform{{"Railway / Fly.io"}}
node_iran{{"Iran server"}}

node_user -->|"creates tunnel"| node_iran
node_iran -->|"provides setup link"| node_user
node_user -->|"deploys and configures"| node_platform
node_platform -->|"runs deployment"| node_container
node_user -->|"supplies setup link"| node_container
node_container -->|"dials out"| node_iran
node_container -.->|"applies link"| node_link_setup
node_link_setup -.->|"configures tunnel"| node_backpack
node_backpack -->|"delivers traffic"| node_xui
node_user -->|"creates inbounds"| node_xui
node_user -->|"checks status and logs"| node_web_panel
node_watchdog -->|"restarts tunnel"| node_backpack
node_supervisor -.->|"keeps running"| node_watchdog

click node_container "https://github.com/amirmohammaddsht-dev/backpack-railway/blob/main/entrypoint.sh"
click node_supervisor "https://github.com/amirmohammaddsht-dev/backpack-railway/blob/main/supervisord.conf"
click node_link_setup "https://github.com/amirmohammaddsht-dev/backpack-railway/blob/main/apply-link.sh"
click node_panel_config "https://github.com/amirmohammaddsht-dev/backpack-railway/blob/main/panel-config.sh"
click node_fake_systemctl "https://github.com/amirmohammaddsht-dev/backpack-railway/blob/main/fake_systemctl.sh"
click node_fake_journalctl "https://github.com/amirmohammaddsht-dev/backpack-railway/blob/main/fake_journalctl.sh"

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_container,node_supervisor toneBlue
class node_link_setup,node_backpack toneAmber
class node_xui,node_panel_config,node_web_panel,node_iran toneMint
class node_watchdog,node_fake_systemctl,node_fake_journalctl toneRose
class node_user,node_platform toneIndigo
```

## Components

### Deployment and startup

- [Application container](https://github.com/amirmohammaddsht-dev/backpack-railway/blob/main/entrypoint.sh): `entrypoint.sh`
- [Process supervisor](https://github.com/amirmohammaddsht-dev/backpack-railway/blob/main/supervisord.conf): `supervisord.conf`

### Tunnel connectivity

- [Setup-link application](https://github.com/amirmohammaddsht-dev/backpack-railway/blob/main/apply-link.sh): `apply-link.sh`
- **BackPack tunnel**

### Panels and traffic

- **3x-ui panel and inbounds**
- [Panel configuration](https://github.com/amirmohammaddsht-dev/backpack-railway/blob/main/panel-config.sh): `panel-config.sh`
- **BackPack web panel**

### Tunnel reliability

- **Tunnel watchdog**
- [Systemctl shim](https://github.com/amirmohammaddsht-dev/backpack-railway/blob/main/fake_systemctl.sh): `fake_systemctl.sh`
- [Journal shim](https://github.com/amirmohammaddsht-dev/backpack-railway/blob/main/fake_journalctl.sh): `fake_journalctl.sh`

### Other components

- **Operator**
- **Railway / Fly.io**
- **Iran server**

## Connections

- Operator → Iran server: creates tunnel (evidence: `README.md`)
- Iran server → Operator: provides setup link (evidence: `README.md`)
- Operator → Railway / Fly.io: deploys and configures (evidence: `README.md`)
- Railway / Fly.io → Application container: runs deployment (evidence: `README.md`)
- Operator → Application container: supplies setup link (evidence: `README.md`)
- Application container → Iran server: dials out (evidence: `README.md`)
- Application container → Setup-link application: applies link
- Setup-link application → BackPack tunnel: configures tunnel
- BackPack tunnel → 3x-ui panel and inbounds: delivers traffic (evidence: `README.md`)
- Operator → 3x-ui panel and inbounds: creates inbounds (evidence: `README.md`)
- Operator → BackPack web panel: checks status and logs (evidence: `README.md`)
- Tunnel watchdog → BackPack tunnel: restarts tunnel (evidence: `README.md`)
- Process supervisor → Tunnel watchdog: keeps running
