Backend-only repository for the Reality VPN control plane.
This package contains:
api/- Go control API for auth, subscriptions, server catalog, connect-session issuance, and Telegram integrationdeploy/- PostgreSQL + API Docker Compose stackscripts/- local Windows/Laragon helper scripts for DB init, API start, smoke checks, and Telegram webhook/poller flows
- Go API backed by PostgreSQL
- JWT-based access tokens
- short-lived connect session issuance for Xray client runtime
- server catalog filtered by subscription plan
- admin API endpoints for users, servers, and app settings
- Telegram auth session flow
- Telegram Stars payment order handling
- audit logging for auth, admin mutations, and connect sessions
- basic in-memory rate limiting for login and Telegram webhook endpoints
server-release/
api/
deploy/
scripts/
.env.example
.gitignore
README.md
Core API:
API_PORT=8080API_BASE_URL=http://localhost:8080JWT_SECRET=<required, non-default>DEV_AUTH_ENABLED=false
PostgreSQL:
POSTGRES_DB=reality_vpnPOSTGRES_USER=reality_vpnPOSTGRES_PASSWORD=change-mePOSTGRES_HOST=localhostPOSTGRES_PORT=5432POSTGRES_SSLMODE=disablePOSTGRES_SUPERUSER=postgresPOSTGRES_SUPER_DB=postgres
Telegram:
TELEGRAM_BOT_TOKEN=TELEGRAM_BOT_USERNAME=TELEGRAM_WEBHOOK_SECRET=TELEGRAM_SUPPORT_HANDLE=@support
If Telegram integration is enabled, TELEGRAM_WEBHOOK_SECRET is required.
The temporary email + code login flow is disabled by default.
To enable it for local development only:
- set
DEV_AUTH_ENABLED=true - set a non-default
JWT_SECRET
Then you can log in with code 0000 against the local API.
Seeded development accounts:
- admin:
starter@admin.local - user:
user@demo.local
From deploy/:
docker compose upThis starts:
- PostgreSQL
- Go API on
http://localhost:8080
This machine already has usable toolchains inside C:\laragon:
- Go:
C:\laragon\bin\go\go1.24.1\bin\go.exe - Node:
C:\laragon\bin\nodejs\node-v22\node.exe - NPM:
C:\laragon\bin\nodejs\node-v22\npm.cmd
Helper scripts:
powershell -ExecutionPolicy Bypass -File .\scripts\start-db.ps1powershell -ExecutionPolicy Bypass -File .\scripts\init-db.ps1powershell -ExecutionPolicy Bypass -File .\scripts\start-api.ps1powershell -ExecutionPolicy Bypass -File .\scripts\smoke-api.ps1powershell -ExecutionPolicy Bypass -File .\scripts\check.ps1powershell -ExecutionPolicy Bypass -File .\scripts\set-telegram-webhook.ps1powershell -ExecutionPolicy Bypass -File .\scripts\start-telegram-poller.ps1
Current flow:
- Client calls
POST /api/v1/auth/telegram/start - API creates a short Telegram auth session and returns a deep link to the bot
- User presses
Startin Telegram, bot confirms the session - Client polls
GET /api/v1/auth/telegram/sessions/:iduntil it receives the access token - User buys a plan with
/buy basic,/buy premium, or/buy maximum - Bot receives
successful_payment, activates or extends the subscription
Webhook setup:
- expose your API publicly over HTTPS
- fill
TELEGRAM_BOT_TOKEN,TELEGRAM_BOT_USERNAME, andTELEGRAM_WEBHOOK_SECRET - run
powershell -ExecutionPolicy Bypass -File .\scripts\set-telegram-webhook.ps1 -ApiBaseUrl https://your-domain.example
For local development you can skip public webhook delivery and use polling instead:
- start the API on
127.0.0.1:8080 - run
powershell -ExecutionPolicy Bypass -File .\scripts\start-telegram-poller.ps1 - talk to the bot in Telegram, and the poller will forward updates into the local API
Run:
powershell -ExecutionPolicy Bypass -File .\scripts\check.ps1This will:
- initialize PostgreSQL
- run
go test ./... - run the API smoke check