Fly.ioTutorial
Livebook is a secret weapon for documentation
Summary
The post presents Livebook as an interactive way to document the central logic of an Elixir or Phoenix application, helping new developers understand and explore code alongside existing documentation and tests. Using a TicTac example, it documents and executes the GameState module and struct, then describes and demonstrates a Horde-managed GenServer that runs the game state. Livebook connects to an existing project through a Mix standalone runtime, providing Elixir code completion, Markdown explanations, execution, and access to operations such as Ecto queries, context calls, and starting GenServers. The resulting notebooks are plain Markdown files, can be stored in source control, and support experimentation, reviewable diffs, and collaborative editing. The setup described requires Elixir 1.12: install Livebook with mix escript.install hex livebook, start livebook server, and connect through the locally generated token URL.
Context
New developers can struggle to understand the code implementing an application's central idea. The post notes that code documentation and tests are valuable, while proposing Livebook as another way to provide documentation, interactive exploration, and access to important application logic.
Approach / What changed
Install Livebook with Elixir 1.12, start its local server, create a project notebook, and connect it using the Mix standalone runtime. The notebook combines Markdown explanations with executable Elixir code, code completion, and access to the connected application's modules, queries, contexts, and GenServers.
Takeaways
Livebook can load an existing Elixir project and combine Markdown explanations with executable Elixir code, allowing documentation to show results interactively.
Notebook files use plain Markdown, so they can be checked into source control and diffed and merged as part of the project.
A connected Livebook runtime can execute Ecto queries, call contexts, start GenServers, and demonstrate application logic such as the GameState module and its Horde-managed server.
Source and freshness
- Source
- fly.io
- Published
- Added to Yomu
- Last updated
Summaries are generated from the original by a language model. Check the original before relying on it.
Keep reading
Related reading
The Good Stuff
Paid picks we use ourselves. Links carry a referral code — a subscription through one earns us a commission at no extra cost to you.
The best engineering reads, once a week
One useful email. Unsubscribe anytime.