{"id":50787702,"url":"https://github.com/silent-brad/hyperdream","last_synced_at":"2026-06-12T09:03:02.443Z","repository":{"id":351638837,"uuid":"1211743033","full_name":"silent-brad/hyperdream","owner":"silent-brad","description":"MirageOS/Datastar web framework for server-driven real-time applications","archived":false,"fork":false,"pushed_at":"2026-04-15T20:35:36.000Z","size":56,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-04-15T22:24:09.922Z","etag":null,"topics":["datastar","mirageos","nix","nushell","ocaml","sse","web-framework"],"latest_commit_sha":null,"homepage":"","language":"OCaml","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/silent-brad.png","metadata":{"files":{"readme":"README.org","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-15T17:47:31.000Z","updated_at":"2026-04-15T20:35:40.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/silent-brad/hyperdream","commit_stats":null,"previous_names":["silent-brad/hyperdream"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/silent-brad/hyperdream","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silent-brad%2Fhyperdream","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silent-brad%2Fhyperdream/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silent-brad%2Fhyperdream/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silent-brad%2Fhyperdream/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/silent-brad","download_url":"https://codeload.github.com/silent-brad/hyperdream/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/silent-brad%2Fhyperdream/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34236552,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-12T02:00:06.859Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["datastar","mirageos","nix","nushell","ocaml","sse","web-framework"],"created_at":"2026-06-12T09:03:01.615Z","updated_at":"2026-06-12T09:03:02.431Z","avatar_url":"https://github.com/silent-brad.png","language":"OCaml","funding_links":[],"categories":[],"sub_categories":[],"readme":"#+TITLE: Hyperdream\n#+DESCRIPTION: MirageOS/Datastar web framework for server-driven real-time applications in OCaml\n\n* Hyperdream\n\nA web framework for building server-driven, real-time applications as MirageOS unikernels using [[https://data-star.dev][Datastar]] for hypermedia exchange over SSE.\n\n** Philosophy\n\n- *Server-driven*: All rendering happens on the server. No client-side JS framework.\n- *Real-time*: Every view is a live SSE stream. State changes push instantly to all connected clients.\n- *Unikernel-ready*: Same code runs on Unix (dev) and as a MirageOS unikernel (prod). Zero filesystem access at runtime.\n- *Minimal*: Simple map-based router, no middleware chains to debug, no magic.\n\n** Core Concepts\n\n*** Two-Route Page Model\n\nEvery page registers two HTTP routes:\n\n- =GET /path= → serves a lightweight HTML shell (the \"shim\") that boots Datastar and opens the SSE connection\n- =POST /path= → opens a persistent SSE stream that pushes rendered HTML on every state change\n\n#+BEGIN_SRC ocaml\nlet _view = View.define ~datastar_js hub \"/\" (fun _req -\u003e\n  Lwt.return (Template.render_string tpl ~models:[(\"count\", string_of_int !counter)]))\n#+END_SRC\n\n*** Actions\n\nActions are POST handlers with content-addressed paths (SHA256 of the name). When an action returns =No_content=, the framework automatically broadcasts a refresh to all SSE clients.\n\n#+BEGIN_SRC ocaml\nlet inc_path = Action.define hub \"counter/inc\" (fun _req -\u003e\n  incr counter;\n  Lwt.return Action.no_content)\n#+END_SRC\n\nUse the path directly in Datastar attributes:\n\n#+BEGIN_SRC html\n\u003cbutton data-on:click=\"@post('{{ inc_path }}')\"\u003e+1\u003c/button\u003e\n#+END_SRC\n\n*** SSE Broadcast Hub\n\nThe hub manages connected clients with =Lwt_condition= fan-out. Hash deduplication skips sending when rendered HTML hasn't changed.\n\n*** Irmin Store\n\nOptional persistent state via Irmin. Connect a store to a hub and state changes automatically trigger SSE broadcasts:\n\n#+BEGIN_SRC ocaml\nlet* store = Store.create () in\nStore.connect_hub store hub;\n(* Any Store.set call now triggers Sse.notify_all *)\n#+END_SRC\n\n*** Asset Embedding\n\nStatic files are compiled into the binary at build time via Nushell codegen — required for unikernel targets with no filesystem. Assets get content-addressed URLs with immutable cache headers.\n\n** Quick Start\n\n#+BEGIN_SRC shell\nnix develop\ndune exec examples/counter/main.exe\n# Open http://localhost:8080\n#+END_SRC\n\n** Examples\n\n| Example       | Port | Description                              |\n|---------------+------+------------------------------------------|\n| =counter=     | 8080 | Minimal: single counter with SSE push    |\n| =game-of-life=| 8081 | Conway's GoL with continuous game loop    |\n| =todo=        | 8082 | CRUD: Irmin-backed todo list             |\n| =chat=        | 8083 | Multi-user real-time chat room           |\n\n** Dependencies\n\n| Library      | Role                                    |\n|--------------+-----------------------------------------|\n| =h1=         | HTTP/1.1 protocol                       |\n| =paf=        | MirageOS HTTP server (Protocol-Agnostic Fibers) |\n| =datastar=   | Datastar SSE SDK ([[https://github.com/silent-brad/datastar-sdk-ocaml][datastar-sdk-ocaml]]) |\n| =jingoo=     | Jinja2-compatible templating            |\n| =irmin=      | Git-like database for persistent state  |\n| =lwt=        | Cooperative concurrency                 |\n| =digestif=   | SHA256 for content addressing           |\n| =yojson=     | JSON serialization                      |\n\n** License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilent-brad%2Fhyperdream","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsilent-brad%2Fhyperdream","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsilent-brad%2Fhyperdream/lists"}