Runnable demo applications, ordered from simplest to most complete. Each entry lists the entry-point class, the port the server binds to, and the concepts the example introduces.
Run any example with Maven. First build the project once from the repository root, then run from the examples/ directory:
mvn install -DskipTests # one-time, from the repository root
cd examples
mvn exec:java -Dexec.mainClass=<fully.qualified.MainClass>Or from your IDE, by running the main method of the entry-point class.
- Entry point: Counter.java
- URL: http://localhost:8080
- Demonstrates: the smallest possible app — a single
InitialStateComponent<Integer>, aComponentViewlambda, and a click handler that callsnewState.setState(...).
- Entry point: PlainForm.java
- URL: http://localhost:8080
- Demonstrates: branching the initial state on the HTTP method, sealed interface state (
EmptyName/FullName), and posting a classic HTML<form>whose query parameters drive the next render.
- Entry point: JettyTodos.java
- URL: http://localhost:8080
- Demonstrates: list rendering with
of(stream...), anElementRefto read the text input'svalueon submit,on("submit", true, ...), and updating immutable state arrays.
- Entry point: Life.java
- URL: http://localhost:8082
- Demonstrates: large grid rendering, click-to-toggle cells, control buttons (Start / Stop / Clear / Random), and the
onUpdated/onUnmountedlifecycle hooks driving aScheduledExecutorServiceto advance generations. Also shows serving CSS viaStaticResources.
- Entry point: Counters.java
- URL: http://localhost:8085/16/-1?c4=27
- Demonstrates: a tree of components coordinated by CountersMainComponent, extending
AddressBarSyncComponentto map path elements and query parameters to context keys:- ContextCounterComponent —
ContextStateComponent<Integer>synced to a URL path element or query parameter. - CachedCounterComponent —
StoredStateComponent<Integer>whose state survives unmount via a sharedConcurrentHashMap. - HideableCounterComponent — conditional rendering with
when(state, ...)toggled by a checkbox. - CountersView — a single reusable view shared by all three counter types.
- CountersAppComponent — top-level routing between the counters page and a 404 page.
- ContextCounterComponent —
-
Entry point: CrudApp.java
-
Demonstrates the end-to-end
compositionsstack:- Routing —
Routermapping/posts,/posts/new,/posts/:id,/comments,/comments/:idto contracts. - Contracts + views — list (PostsListContract, CommentsListContract) and edit/create forms (PostEditContract, PostCreateContract, CommentEditContract, CommentCreateContract) bound through
DefaultListView/DefaultEditView. - Groups — nested
Group("Admin") → Group("Posts") / Group("Comments"); the tree drives the ExplorerContract sidebar menu. - Layout —
DefaultLayoutwith left sidebar (Explorer), right sidebar (Prompt), header, and a placement policy mapping forms inline and approvals to modals. - Auth — a separate
Compositionfor/auth/loginusingSimpleAuthProvider+SimpleLoginComponent;AuthComponentredirects anonymous requests. - AI agent — PromptContract talks to an
AgentService, selectable via-Dai.agent=regex|claude|ollama. Backed by ABAC authorization (AccessPolicy,Authorization) and human-in-the-loop approvals viaApprovalSpawner+DelegationApprovalContract. - Domain — PostService, CommentService, RegexAgentService, entities in entities/.
Selecting the agent backend (run from
examples/after the one-timemvn install):# default — deterministic regex stub, no external calls mvn exec:java -Dexec.mainClass=rsp.app.posts.CrudApp # Claude (requires ANTHROPIC_API_KEY) mvn exec:java -Dexec.mainClass=rsp.app.posts.CrudApp -Dai.agent=claude # local Ollama mvn exec:java -Dexec.mainClass=rsp.app.posts.CrudApp -Dai.agent=ollama
- Routing —
| Concept | Counter | PlainForm | JettyTodos | Life | Counters | CrudApp |
|---|---|---|---|---|---|---|
InitialStateComponent |
+ | + | ||||
Custom Component<S> subclass |
+ | + | + | + | ||
| Sealed-interface state | + | + | ||||
ElementRef / form submit |
+ | + | ||||
| HTTP method / query-param branching | + | |||||
Lifecycle hooks (onUpdated / onUnmounted) |
+ | + | ||||
URL ↔ state sync (AddressBarSyncComponent) |
+ | |||||
Persistent state across unmount (StoredStateComponent) |
+ | |||||
Conditional rendering (when(...)) |
+ | + | + | + | ||
Static resources (StaticResources) |
+ | + | + | |||
Routing (Router + contracts) |
+ | |||||
| Layout + composition + groups | + | |||||
| Auth composition | + | |||||
| AI agent + ABAC + HITL approval | + |