Authentication & sessions
Sessions, CSRF protection, login flows, API tokens and rate limiting compose as plugs into your request pipelines — the security posture of every route is readable in one place, not scattered across handlers.
OCaml 5 · Eio · effects, not callbacks
araara is a web framework for OCaml 5: authentication, a database layer, type-safe HTML, real-time sync, background jobs and clustering — the building blocks of a production web application, with the conventions to compose them.
(* The smallest araara service: one route, one typed view, one server.
Run with: dune exec examples/hcs_hello/main.exe *)
let hello_page =
let open Pure_html in
let open HTML in
html
[ lang "en" ]
[
head [] [ title [] "Hello from araara" ];
body [] [ h1 [] [ txt "Hello, araara!" ] ];
]
let hello _params _req =
Hcs.Server.respond_html (Pure_html.to_string hello_page)
let () =
Eio_main.run @@ fun env ->
Eio.Switch.run @@ fun sw ->
let routes =
Hcs.Router.(compile_scopes [ scope "/" [ Route.get "/" hello ] ])
in
let handler =
Hcs.Endpoint.(
create default_config |> Fun.flip router routes |> to_handler)
in
Hcs.Server.run ~sw
~net:(Eio.Stdenv.net env)
~clock:(Eio.Stdenv.clock env)
handler
Features
araara is for building web applications in OCaml: the capabilities a real app needs, with the conventions to wire them together.
Sessions, CSRF protection, login flows, API tokens and rate limiting compose as plugs into your request pipelines — the security posture of every route is readable in one place, not scattered across handlers.
Typed schemas, changesets that validate input before it ever reaches the database, and a composable query DSL with no raw SQL. One set of models runs against every supported dialect, through repodb.
Render pages as ordinary OCaml functions — escaped by default, htmx attributes built in, no template language and no build step between you and the browser.
Share a live document between server and browser with JSON CRDTs that merge concurrent edits deterministically — wire-compatible with json-joy, so an OCaml backend and a JavaScript client speak the same protocol.
Run work off the request path as supervised workers with typed mailboxes, schedulers and one-shot tasks — and when one node is not enough, scale out with gossip-based membership and replicated state, the same worker code across more machines.
Swap server-rendered fragments with htmx and push updates over Server-Sent Events. Reach for JSON when there is a real API consumer — every web action has a matching endpoint over the same logic.
Decode request bodies into typed values and encode responses at SIMD speed, with a zero-copy path for the endpoints that need it.
Server, migrations, CLI and background workers compile to a single native binary. Ship it as one small Docker image — like this very site — or wrap it as a desktop app.
Performance
hcs — araara's HTTP layer — is built for throughput: it leads its local benchmark sweep on WebSocket echo, the HTTP/2 baseline and static files, and stays competitive across the rest. The full numbers, measured side by side with reference servers on one machine, are on the table — caveats included.
Conventions
Every feature flows through the same layers — model, context, controller or API, view, router — so every araara codebase reads the same way. Illegal states are unrepresentable, errors are typed values, and side effects live at the edges.
See it running
A clustered trading-floor demo: two visible browser clients connect to different nodes while one thousand simulated traders place buy and sell orders, post chat messages, and drive realtime dashboard, portfolio and leaderboard updates over one multiplexed WebSocket per client. The trading book and chat log converge across the cluster with hive replicated state.
Read the source 1000 simulated traders
A complete araara application from the docs: login, roles, typed routes, SQLite models, server-rendered HTML, htmx form updates and an operator queue that receives new tickets over Server-Sent Events.
Read the walkthrough SSE + htmx
A complete email client: a curated inbox, a screener for unknown senders, full-text search, and a JSON API behind the same service layer as the HTML UI — shipped as web, CLI and desktop from one OCaml codebase.
Read the source docker pull qswarm/ahoj:latest
A multiplayer snake game on a hive cluster: every node runs identical code, simulates the snakes joined through it, and competes for singleton roles — the food spawner and the AI seats — that live on one node and migrate with membership.
Thank you
araara is a small thing standing on a large foundation. The features above are possible only because of the libraries, knowledge and know-how the OCaml community has written and given away.