← docs.speechwave.live

Supervision tree

Defined in lib/speechwave/application.ex. Children start in order, top to bottom. Strategy: :one_for_one (restart only the crashed child).

Children (boot order)

ChildWhat it doesWhy this position
SpeechwaveWeb.Telemetry Collects metrics (request times, VM stats). Powers the /dev/dashboard LiveDashboard graphs. First: so it can observe everything that follows.
Speechwave.Repo Database connection pool (SQLite via Ecto). Must start before anything that queries the DB.
{DNSCluster, ...} Discovers other nodes via DNS for clustering. Disabled in dev (:ignore). Used in production for multi-node discovery.
{Phoenix.PubSub, ...} Publish/subscribe system. TalkLive subscribes to this for real-time emoji broadcasts. Must start before the Endpoint (which depends on it).
Speechwave.RateLimiter GenServer owning the ETS table for emoji tap rate limiting (a short cooldown). Before Endpoint: must be ready when LiveViews start handling taps.
Speechwave.AuthThrottle GenServer owning ETS tables for magic-link email and IP-based login throttling (escalating on repeated attempts). Before Endpoint: must be ready when login requests arrive.
SpeechwaveWeb.Endpoint The HTTP server (Bandit). Listens for connections, handles WebSocket upgrades for LiveView. Near the end: only accepts traffic when everything above is ready.
SpeechwaveWeb.Presence Tracks connected users per topic (built on PubSub). Used for audience counts. After Endpoint and PubSub are running.
Speechwave.DbBackup Periodic SQLite backup to S3 (5 min initial delay, then hourly). Conditional: only added once storage is configured (production only).

Supervision strategies

StrategyOn child crash
:one_for_oneRestart only the crashed child (Speechwave uses this)
:one_for_allRestart all children
:rest_for_oneRestart the crashed child and all children started after it

Child spec formats

# Module name: calls Module.start_link([])
Speechwave.RateLimiter

# Tuple: passes options to Module.start_link(opts)
{Phoenix.PubSub, name: Speechwave.PubSub}

# Conditional children
if condition, do: [Speechwave.DbBackup], else: []