LeanTEA — the book

A Lean 4 framework for writing the entire web app in Lean, on both ends of the wire, with one mental model: the Elm-style triple (Model / Msg / update / view).

Read in order

Skim by question

If you want to …Start at
Decide whether LeanTEA fitsOverview
Add an interactive pageFrontend
Add a route or stateless APIBackend
Store something across restartsPersist
Share an endpoint between Lean and JSRPC
Generate browser JS from LeanLeanJs
Build a static HTML shellTemplate
Drive a browser / Chrome / desktop from an LLMMCP servers
Understand the whole systemArchitecture overview
Test a LeanTEA app (and what not to test)Testing

What ships

AppBinarySource
Counter (TUI demo)lake exe counterexamples/Counter/
Quiz (TUI demo)lake exe quizexamples/Quiz/
Counter (browser demo)lake exe counter_webexamples/CounterWeb/
Sheet (functional spreadsheet + MCP)lake exe sheet_serveexamples/Sheet/
Reversi (server SPA)lake exe reversi_serveexamples/Reversi/
Chrome-CDP MCPlake exe chrome_cdp_mcp_serveexamples/ChromeCdpMcp/
Playwright Browser MCPlake exe browser_mcp_serveexamples/BrowserMcp/
ComfyUI MCPlake exe comfyui_mcp_serveexamples/ComfyuiMcp/
Desktop MCP (macOS Quartz)lake exe desktop_mcp_serveexamples/DesktopMcp/
Image MCP (HTML→PNG)lake exe image_mcp_serveexamples/ImageMcp/
Browser agent (LLM driver)lake exe browser_agentexamples/BrowserAgent/
UI script runnerlake exe ui_scriptexamples/UiScript/
UI HTML reportlake exe ui_reportexamples/UiReport/
LeanJs CLI triolake exe leanjs_{compile,interp,run}examples/Tools/
Spec runnerlake exe leanjs_specexamples/Tests/

Everything in the book quotes code from one of these — nothing is pseudocode. Where a chapter shows a snippet, the same shape exists in the corresponding example.