Reaktor framework overview
Reaktor is a Kotlin Multiplatform framework for building a whole product, with its apps, servers and edge Workers, as one typed graph. Screens, routes, services, actors and stores are nodes. Each node declares what it provides and what it consumes through typed ports, and the graph connects them. The same graph code runs on Android, iOS, the JVM, the browser and Cloudflare Workers. Because the structure is data, tools can draw it, check it and change it, and an AI agent reads the same structure that the program runs.
BestBuds, a friendship app, is built on Reaktor and runs in production. The examples on this page come from its source.
The graph runtime, Surface UI, auth, typed services, actors, notifications, the Cloudflare bindings, telemetry, Hangar and the CLI are built and in use. Other parts are designs, and each design page says so in its first paragraph. Reaktor V2 (Deprecated), in the Theory section, is a deprecated historical design study — never build new work on V2; Reaktor moves directly from today's V1 graph runtime to Reaktor V3.
Read the picture from the top. A product runs in up to four places, and all of them compile from the same Kotlin. The apps call services, Workers and the server implement them, and both sides compile from one contract. Inside each place, the program is a graph of nodes joined by typed ports, and the framework modules add ready-made nodes for UI, sign-in, data, background work, push and telemetry. Because the graph is data, the tools on the right can read it: Hangar draws it, the CLI builds and runs it, and the MCP server answers coding agents' questions about it. All three go through one workspace kernel.
1. The idea#
Two choices define Reaktor.
Modules are full-stack. A module covers one capability from the screen to the server. reaktor-auth draws the "Sign in with Apple" button on iOS, and the same module verifies the resulting token inside a Cloudflare Worker and inside a JVM server. A service contract is declared once, and both the client that calls it and the server that implements it compile from that declaration.
The graph wires the modules. A node never reaches for a collaborator through a global or a singleton. It declares typed ports, and the graph connects each consumer to a provider. The structure of the application is therefore data that can be walked, serialized, drawn as a live diagram, validated and handed to a tool.
Every API is held to one design bar:
expressivity & composability ≫ simplicity ⋙ one-shot, bloated APIs
A small set of primitives that compose well is preferred over a large API that covers each case directly. Common cases should be short to write, and rare cases stay reachable through the lower-level primitives.
Unreal Engine is the closest model. Its engine programmers build durable systems such as rendering and physics, and designers compose many different games on top of them through Blueprints, a visual node graph. In Reaktor, the modules are the durable systems and products are composed on the graph. Hangar draws every graph in the Blueprint style.
2. The graph#
The graph runtime has three layers.
| Module | What it holds |
|---|---|
reaktor-graph-port | The port graph: nodes, typed ports, edges, graph documents and visitors. |
reaktor-graph-runtime | Graph, the node kinds, actors, navigation, dependency injection, lifecycle, and service contracts as nodes. |
reaktor-graph | Compose screens and containers that render a graph on Android, iOS, desktop and the web. |
2.1 Graphs and nodes#
A Graph is a scoped container. It owns its nodes, a dependency-injection scope, a lifecycle, a coroutine scope and a navigation stack. Graphs nest, so an app graph holds feature graphs, and those hold screens, services and actors.
| Node | Role |
|---|---|
BasicNode | A plain unit of behaviour with ports. |
ContractNode | A service contract, either served in-process or called over the network (§2.3). |
RouteNode | A route such as /chats/{id}, with its navigation edges. |
ControllerNode | A node that owns observable state. |
ActorNode | A node with one ordered mailbox and private state (§2.5). |
ContainerNode | A node that holds child graphs and activates the right one for the current route. |
ComposeNode, ComposeContainerNode | Screens and screen containers drawn with Compose. |
2.2 Ports and wiring#
A node declares what it offers with provides and what it needs with consumes. This is the chat media cache in BestBuds:
internal class ChatMediaCache(graph: Graph) : BasicNode(graph) {
override val label = "Chat media"
val cache by provides<ChatMediaCache>(this)
private val media by consumes<ChatMedia>()
}
The node never looks up a ChatMedia itself. The graph connects the consumer port to a provider of that type. autoWire() matches every unconnected consumer to a provider by type and key and falls back to the dependency-injection scope. requireFullyWired() fails when a consumer has no provider, so a wiring mistake shows up when the graph is built.
Graph explains the order in which autoWire() looks for a provider, wire() for a whole tree of graphs, and the rules that keep wiring safe, with playgrounds to try each one.
2.3 Services#
A service contract is a class that lists its operations. This is part of the BestBuds messaging contract:
open class MessagingApi : Service("bestbuds.messaging") {
override val access = ServiceAccess(Callers.SignedIn, ::sendBotMessage to WorkerServices)
open val getMessages by get<ChatPage, MessagingResponse.Messages>("/messages/{chatId}")
open val markRead by post<String, MessagingResponse.MarkedRead>("/messages/{chatId}/read")
}
The messaging Worker implements the contract by subclassing it. In the app, a graph places the contract as a node: serve(implementation) runs an implementation in the same process, and remote(MessagingApi() over link) calls a deployed one. A node can consume a whole service or one call of it, as the chat outbox does with consumes(MessagingApi().markReady). Services covers contracts, links, interceptors and access rules.
2.4 Capabilities and navigation#
Every graph has four capabilities.
| Capability | What it provides |
|---|---|
| Lifecycle | A guarded state machine: Created, Restoring, Attaching, Saving, Destroying. |
| Concurrency | A coroutine scope owned by the graph and cancelled when it closes. |
| Dependency | A dependency-injection scope chained to the parent graph, with Koin and Spring adapters. |
| Navigation | A back stack driven by Push, Replace, Pop and Return commands, including navigation into another graph. |
Navigation needs no separate library. A RouteNode holds a pattern such as /chats/{id}, navigation edges carry typed payloads, and Return hands a result back to the screen that opened the current one. On the web the back stack follows the browser URL.
2.5 Actors#
State that many events change at once belongs to an actor. An ActorNode is an ordinary node with one mailbox that it drains in order, so its state never needs a lock. BestBuds chat has two:
ChatOutboxowns every outgoing message. Queueing, uploads with progress, retries, discards and forwards all arrive as messages in its mailbox.ChatReadReceiptscollects read receipts per chat and sends them after a short delay.
Actors covers mailboxes, ask, supervision and the plan for actors that span machines.
2.6 Inspecting a graph#
Because the graph is data, other code can walk it. Graph.toJsonElement() serializes the nodes, ports and edges, including child graphs, and visitors in reaktor-graph-port run passes such as wiring checks over the same structure. Hangar's Graph pane draws a running app's graph this way, with live calls and wiring findings. The Reaktor MCP server gives agents the same view.
3. One codebase on every platform#
Reaktor code compiles for Android, iOS, the JVM (servers and desktop) and JavaScript (the browser and Node). Cloudflare Workers run the JavaScript build. Native C++ code is reached through FFI.
Feature slots keep platform code out of shared code. Shared code reads a slot such as Feature.Camera or Feature.Database, and each platform fills the slot when it starts, so a node never checks which platform it runs on. Core explains slots and adapters.
4. A worked example: BestBuds backends#
The BestBuds app declares every backend service as a typed port on one Backend graph:
abstract class Backend(parent: Graph, label: String, val user: User) : Graph(parent, label = label) {
abstract val messaging: Provides<MessagingApi>
abstract val circles: Provides<CirclesApi>
abstract val matching: Provides<MatchingApi>
}
Two graphs implement it. Remote calls the deployed Workers:
override val messaging by lazy { remote(MessagingApi() over userLink(Servers.MessagingServer, user)) }
Mocked serves in-process mocks over a simulated world of users:
override val messaging by lazy { serve(MessagingMock(world, user.id)) }
A third graph, Build, puts a Relay node in front of each service and points it at one of the two. A developer build can therefore run chat against the mock world while circles and matching use the real server. Screens only consume MessagingApi, so they behave the same either way. The messaging Worker implements the same contract again, so the client, the server and the mock all follow one declaration, and Hangar shows which backend each service is using.
5. Modules and planes#
reaktor is one Gradle build. The products include it as a composite build, so a framework change reaches them without publishing anything. Its modules sit in twelve planes, one folder each under reaktor/, and a plane may use only the planes before it in this table.
| Plane | What it holds | Start with |
|---|---|---|
| Origin | Runtime types, the graph, actors, services, I/O, binary data and calls between languages | Core, Graph, Services, Actors |
| Data | Storage and queries for graph nodes | Data layer |
| Surface | UI components, their Compose implementation, the UI kit and haptics | Surface textbook |
| Machines | The computers and devices that run Reaktor work | Capabilities, Cluster |
| Identity | Sign-in, access rules, secrets, cryptography, conversation encryption and app unlock | Auth, Secrets |
| Build | Source tools, compile-time code generation and Apple framework export | Its modules |
| Work | Durable workflows, plans and task graphs, and approval to run operations | Work |
| Cloud | An inventory of cloud resources, cloud clients and Cloudflare Workers bindings | Its modules |
| Views | Views for graphs, boards and code, and the canvas they share | Its modules |
| Observability | Tracing, analytics, performance measurement and live inspection | Observe and diagnose |
| Platform | Web views, media, location, health, notifications and Google services | WebView, Notifications |
| Agentic | Running coding agents, and tools over the graph | The agentic plane |
Reaktor planes shows which planes each one may use, each plane's Modules page lists its modules, and Contributing says where a change belongs.
6. Tools#
The tools read the same graph the program runs.
- Hangar is the desktop app. Its panes show a running app's graph, real phones side by side, the cloud resources a product runs on, its databases and its tests.
- The
reaktorCLI inspects builds, runs tasks under supervision and keeps a record of each run. - The Reaktor MCP server gives coding agents code queries, planned edits, checks and workspace operations. Hangar, the CLI and the MCP server share one workspace kernel.
- Conductor runs Claude Code and Codex from inside Reaktor with one shared conversation history.
- Shadow is the design for developing against a sanitized, moving copy of production.
7. What Reaktor improves#
| Usual approach | What goes wrong | Reaktor's approach |
|---|---|---|
| A separate codebase for each platform and tier, such as a Swift app, a Kotlin app and a TypeScript backend | The same models and API calls are written three times and drift apart. | One Kotlin codebase compiles for the apps, the browser, the JVM and Workers. A service contract is declared once, and the client, the server and the mock all compile from it. |
| An API shared through documentation or a generated OpenAPI client | Generated clients fall behind the server, and each side handles access rules and errors in its own way. | The Worker implements the contract by subclassing it, and the contract carries its access rules, so both sides follow one declaration. |
| One library per layer: a UI toolkit, a DI container, a navigation library, an auth SDK, an analytics SDK | Glue code joins libraries that each have their own lifecycle and their own idea of scope. | A module covers one capability from the screen to the server, and one graph wires every module with one lifecycle. |
| Developer tools that each see one process | The phone, the backend and the database are inspected in separate tools that know nothing of each other. | Hangar reads the graph of the apps, the Workers and the server, and its panes link a screen to its service, the Worker that serves it and the database it touches. |
| Coding agents that work from text search | An agent guesses the structure of the app from file names and misses the wiring that only exists at run time. | The MCP server answers from the same graph and build model the tools use, so an agent sees what Hangar shows. |
8. Limitations#
- Reaktor is Kotlin first. Swift, TypeScript and C++ code joins through FFI, web views or exported frameworks, and each crossing is extra work to build and test.
- Wiring is checked when a graph starts. The compiler cannot see an input without a provider.
requireFullyWired(), tests that build each graph and Hangar's checks find it instead. Graph lists the other wiring limits. - Products build the framework from source. BestBuds and Manna include
reaktoras a composite build, so a framework change reaches every product at once, and a breaking change has to be fixed in every product in the same change. - Workers keep the limits of the Workers runtime. A Worker runs the JavaScript build, so its code has the CPU time, memory and threading limits of any Cloudflare Worker.
- Parts are still designs. Each design page says so in its first paragraph, and Reaktor V2 (Deprecated) is deprecated and will not be built — Reaktor moves directly from today's V1 graph to Reaktor V3.
9. Where to read next#
- To build an app: Core, then Graph, Services, Actors and the Surface textbook.
- To store data or run background work: Data layer, starting with what exists today, and Work.
- To run a product in production: Deployment, then Observe and diagnose and Shadow.
- To work on the tools: Hangar, Kernel, Dependeasy and Agents.
- To see how the code is laid out: Reaktor planes and Contributing.
- To change the framework or these docs: Contributing and Writing docs.
- To learn by changing code: each playground is an editable box with a live picture. Wire a graph and watch autoWire() choose providers, nest graphs, edit and repair a graph the way Hangar does, send messages to an actor, ask whether someone may call an operation and see which checks a change selects.