Map of the server/ directory and its contents.
Project Tree
bedrud/
├── apps/
│ ├── web/ # React frontend (TanStack Start)
│ ├── site/ # Astro marketing/docs site
│ ├── desktop/ # Rust + Slint desktop app
│ ├── android/ # Native Android
│ └── ios/ # Native iOS
├── agents/ # Python LiveKit bots
├── packages/api-types/ # Shared TypeScript types
├── server/ # Go backend (module: bedrud)
│ ├── cmd/
│ │ ├── bedrud/ # Production CLI entrypoint
│ │ └── server/ # Dev API-only entrypoint (Air hot-reload)
│ ├── config/ # Config structs + Load() + livekit example
│ ├── internal/
│ │ ├── auth/ # JWT, passkeys, OAuth, sessions
│ │ ├── cli/ # Cobra commands (run, install, update, user, room, …)
│ │ ├── database/ # GORM init + migrations
│ │ ├── handlers/ # Fiber HTTP handlers
│ │ ├── install/ # bedrud install/update (systemd/OpenRC/SysV)
│ │ ├── livekit/ # Embedded LiveKit binary lifecycle
│ │ ├── lkutil/ # LiveKit client helpers
│ │ ├── middleware/ # Auth, RBAC, rate limits
│ │ ├── models/ # GORM models
│ │ ├── queue/ # Async jobs + email templates
│ │ ├── repository/ # Data access layer
│ │ ├── scheduler/ # Background cleanup (gocron)
│ │ ├── server/ # Bootstrap: Run() wires everything
│ │ ├── services/ # Room cleanup, recording service
│ │ ├── storage/ # Chat/avatar/recording storage
│ │ └── utils/ # TLS certs, net helpers, …
│ ├── frontend/ # Embedded built web assets (//go:embed)
│ └── docs/ # Generated Swagger (swag)
├── docs/server/ # Engineer-facing backend docs (repo)
└── Makefile # Build & dev automation (repo root)Directory Map
/cmd/bedrud
Production entrypoint: Cobra CLI (run, install, update/upgrade, user, room, config, …).
/cmd/server
Dev API process (Air). No full CLI surface; may differ slightly from prod route registration.
/config
config.go:Configstruct,Load(), env overrideslivekit.yaml.example: External LiveKit sample
/internal
| Package | Role |
|---|---|
auth | JWT, OAuth (Goth), passkeys, session store, email verification tokens |
cli | All management subcommands |
database | SQLite/Postgres connection, AutoMigrate |
handlers | HTTP: auth, rooms, admin, webhooks, LiveKit webhook, certs |
install | Linux installer, in-place update/upgrade |
livekit | Extract/run embedded livekit-server |
lkutil | Shared LiveKit API helpers |
middleware | Protected, RequireAccess, rate limiters, email-verified gate |
models | GORM schemas |
queue | Job worker + handlers (delete, suspend, webhook, email, …) |
repository | Data access |
scheduler | Idle rooms, job cleanup, cert renewal, recording retention |
server | Run() bootstrap and route table (production routes) |
services | Room cascade cleanup; recording service (planned routes) |
storage | Disk/S3/inline chat uploads, avatars |
utils | Self-signed TLS, safe IO, keys |
/docs (within server)
Swagger/OpenAPI generated by swag → UI at /api/swagger and Scalar at /api/scalar.
Technical Deep Dive
1. Binary Embedding
- Frontend: Built assets embedded via
server/ui.go(//go:embed all:frontend) - LiveKit: Binary under
internal/livekit/bin/; extracted at runtime and launched as a subprocess
2. LiveKit Reverse Proxy
When not livekit.external, requests under /livekit are reverse-proxied to the internal LiveKit host (install default often 127.0.0.1:7880; local multi-process dev often 7072).
3. Middleware Locals
Auth middleware stores claims in c.Locals("user"). Handlers read *auth.Claims.
4. Configuration Overrides
File + env (see Configuration). Runtime admin overrides live in SystemSettings (DB).
| Variable | Description |
|---|---|
SERVER_PORT | Main listener port |
SERVER_ENABLE_TLS | HTTPS |
SERVER_DOMAIN | Domain (ACME / passkey) |
DB_TYPE / DB_PATH | Database type / SQLite path |
LIVEKIT_HOST | Public LiveKit URL |
LIVEKIT_API_KEY | LiveKit key |
JWT_SECRET | Access token secret |
CONFIG_PATH / BEDRUD_CONFIG | Config file path |
Coding Standards
- Repository pattern — handlers call repos, not GORM directly
- Structured errors — Fiber status + JSON
- Zerolog —
log.Info/Error/Debug(notfmt.Println) - Naming — files
snake_case.go, exported types PascalCase
See also
- Configuration
- CLI Reference
- API Handlers
- Repo engineer docs:
docs/server/(not published to the site)