Files
server-26/README.md
T
Logan 2f0597c81b Initial commit — DRB server stack
Includes c2-core (FastAPI/MQTT/Firestore), discord-bot (slash commands),
frontend (Next.js admin UI), and mosquitto config.
2026-04-05 19:01:39 -04:00

3.5 KiB

DRB Server

The server-side stack for the Discord Radio Bot system. Handles command-and-control, Firestore sync, Discord slash commands, and the web frontend.

Services

Service Description Port
mosquitto MQTT broker — receives telemetry from edge nodes 1883
c2-core FastAPI C2 API — processes MQTT, writes to Firestore, manages nodes/systems/tokens 8888
discord-bot Discord bot — /join, /leave, /status slash commands
frontend Next.js admin UI — real-time dashboard, node management, call history 3000

Prerequisites

  • Docker + Docker Compose
  • A Firebase project with Firestore enabled (Native mode)
  • A GCP service account key with Firestore and Firebase Auth permissions
  • A Discord bot token (for the server bot that handles slash commands)
  • One or more Discord bot tokens in the token pool (for edge nodes to join voice channels)

Setup

# 1. Copy env files
make setup

# 2. Fill in secrets
#    drb-c2-core/.env       — MQTT, Firestore database name, GCS bucket
#    drb-server-discord-bot/.env — Discord bot token, C2 URL
#    drb-frontend/.env      — Firebase config (NEXT_PUBLIC_*), C2 URL

# 3. Place your GCP service account key
cp /path/to/your-key.json drb-c2-core/gcp-key.json

# 4. Build and start
make build
make up

Environment Variables

drb-c2-core/.env

Variable Description
MQTT_BROKER Hostname of the MQTT broker (default: mosquitto)
FIRESTORE_DATABASE Firestore database name (default: (default))
GCP_CREDENTIALS_PATH Path to the GCP key file inside the container
GCS_BUCKET GCS bucket name for audio uploads (optional)

drb-server-discord-bot/.env

Variable Description
DISCORD_TOKEN Bot token for the server-side command bot
C2_URL Internal URL of c2-core (default: http://c2-core:8000)
DEV_GUILD_ID Optional guild ID to sync slash commands instantly during dev

drb-frontend/.env

Variable Description
NEXT_PUBLIC_FIREBASE_* Firebase project config (from Firebase console)
NEXT_PUBLIC_FIRESTORE_DATABASE Firestore database name (must match c2-core)
NEXT_PUBLIC_C2_URL C2 API URL reachable from the browser

Admin Setup

After the stack is running, grant admin access to your Firebase user:

cd drb-c2-core
python scripts/set_admin.py grant your@email.com

Then sign out and back in to the frontend.

Makefile Targets

make setup    — copy .env.example files
make build    — docker compose build
make up       — docker compose up -d
make down     — docker compose down
make logs     — follow all logs
make logs-c2       — c2-core logs only
make logs-bot      — discord-bot logs only
make logs-frontend — frontend logs only

Architecture

Edge Node (client machine)
    │
    ├── MQTT checkin/status/metadata ──► mosquitto ──► c2-core ──► Firestore
    │
    └── MQTT commands ◄─────────────────────────────── c2-core
              │
              └── discord_join ──► edge node joins Discord voice + streams Icecast

Discord User
    │
    └── /join /leave /status ──► discord-bot ──► c2-core ──► MQTT ──► edge node

Browser (admin)
    └── frontend ──► Firestore (real-time reads)
                └── c2-core REST API (writes/commands)