Phoenix (Elixir) Primer
Phoenix is a productive web framework built on Elixir and the Erlang VM. It scales to millions of connections with LiveView, channels, and OTP supervision trees. This primer walks through the mental model, a minimal app, and how Meridian routes requests through a Phoenix endpoint.
1. Install & Bootstrap
Install Erlang, Elixir, and the Phoenix project generator. Then scaffold a new app with LiveView enabled. The generator wires Ecto, Tailwind, esbuild, and a default PostgreSQL repo for you.
mix archive.install hex phx_new
mix phx.new meridian_demo --live
cd meridian_demo
mix ecto.create
mix phx.server2. Routes, Controllers, LiveView
Phoenix routes live in lib/app_web/router.ex. Controllers handle classic request/response, while LiveView keeps a persistent process per connection for sub-millisecond UI updates. Pipelines apply plugs (auth, CSRF, session) before the action runs.
- Routes map verbs and paths to controllers or live modules.
- Plugs compose like middleware but are just functions.
- LiveView diffs render output and pushes minimal patches over WebSocket.
3. Calling Meridian From Elixir
Use Req or Finch to hit the Meridian gateway. The endpoint is OpenAI-compatible, so any existing Elixir LLM library works by overriding the base URL. Stream tokens directly into a LiveView assign for instant UI updates.
Req.post!("https://llm.getnimbus.net/v1/chat/completions",
headers: [{"authorization", "Bearer #{key}"}],
json: %{
model: "azure/model-router",
messages: [%{role: "user", content: "hello"}]
}
)