rsp

Project Url: vadimv/rsp
Introduction: A Java library for building real-time user interfaces and UI components.
More: Author   ReportBugs   
Tags:

A realtime UI toolkit for admin panels, internal tools, and live web apps—featuring native Human-in-the-Loop AI flows.

Deliver internal tool UIs predictably in plain Java. Free from dependency fatigue.

Admin-UI-demo

Why?

For over a decade, web UI stacks have been confusing and unpredictable. Building a modern frontend usually means:

  • Adopting a Node-based stack with thousands of transitive npm dependencies (often with opaque ownership and non-existent support guarantees).
  • Maintaining REST/GraphQL endpoints just to serve your own frontend.
  • Setting up separate frontend build steps and CI pipelines, even when your core stack is Java.

What does this project suggest instead?

  • SSR Architecture: A Server-Side-Rendering architecture similar to Elixir Phoenix LiveView or Blazor Server, but built natively for Java.
  • Plain Modern Java: Write web UIs with zero annotations, zero "beans", and no implicit control flows. Constructors are the preferred way for dependency injection, and components can be tested in isolation.
  • Compact and All-Inclusive: The project's total code footprint is currently about 50K LOC (with plans to cap at ~100K LOC), including tests, examples, and documentation. It provides a full UI stack with a level of complexity kept well within the reach of a small team.
  • Auditable: Aims for zero third-party runtime dependencies (currently just one dependency outside the web server layer), making the UI stack auditable by design.
  • AI-Generation Friendly: The Java HTML DSL is linear and composable, making it incredibly easy for coding LLMs (like Claude or Codex) to generate valid DSL HTML and component trees.
  • Native AI Flows: At runtime, AI agents can natively understand the application's structure, navigate the UI, and queue up actions using Human-in-the-loop flows for user approval.

What does the essential code look like?

import rsp.component.ComponentView;
import rsp.component.definitions.InitialStateComponent;
import rsp.jetty.WebServer;

import static rsp.dsl.Html.*;

public final class Counter {
   static void main(final String[] args) {
      final ComponentView<Integer> view = newState -> state ->
              html(
                      body(
                              h1("Current count: " + state),
                              button(on("click", _ -> newState.setState(state + 1)),
                                     text("Increment"))
                      )
              );

      final var server = new WebServer(8080, _ -> new InitialStateComponent<>(0, view));
      server.start();
      server.join();
   }
}

This is a complete, runnable, interactive web application.

How it works:

  1. The server generates the initial HTML and sends it to the browser.
  2. A tiny JavaScript client opens a WebSocket connection to the server.
  3. When you click a button, the event is sent over the WebSocket.
  4. The Java server updates the state, recalculates the UI, and sends a tiny DOM diff back over the WebSocket.
  5. The browser patches the DOM.

Higher-level abstractions

Instead of magic annotations and complex lifecycles, this toolkit relies on a predictable mental model:

  • 📦 Components (The Building Blocks): Plain, generic Java classes strongly typed by their state. The framework natively manages state, while parent components pass configuration and services to their descendants via a keyed data context.
  • 🎨 Pure Views (The UI): View components handle pure presentation. They are agnostic to concrete data types, highly configurable via data schemas, and easily generated by LLMs.
  • 🤝 Contracts (The Services and AI Bridge): Contracts are special classes that provide the interface between your application, the external world, and AI agents. They are what allow the LLM to natively "understand" what actions it can take.
  • ⚡ Typed Events (The Glue): During application assembly, Contracts are bound to Views. They communicate with each other exclusively through strongly typed events, ensuring a safe, auditable flow of data.

Getting Started: Admin Panel + AI Flow bonus

Live Demo (might take up to 1 min for a cold start)

1. Prerequisites

  • Java 25+ (virtual threads, sealed interfaces, pattern matching)
  • Maven 3.9+

2. Clone the repository

git clone https://github.com/vadimv/server-components.git
cd server-components

Tip: Now is a great time to run your favorite LLM coding tool over the project to review the architecture and perform an initial audit!

3. Build the project

mvn clean install

4. Run the included admin example

mvn exec:java -pl examples -Dexec.mainClass="rsp.app.posts.CrudApp"

Open http://localhost:8085, click Sign in, and explore the Posts/Comments admin application.

5. Try a few AI Prompts

By default, CrudApp uses RegexAgentService, a deterministic regex-based agent stub included in the repository. It is meant for demos and local validation, allowing you to try the AI workflow without setting up Anthropic, Ollama, or any other external LLM backend.

Once inside the app, try typing these commands into the agent interface:

  • "open comments"
  • "go to page 2"
  • "open comments and go to page 2 and select all"

When you're ready to use real AI reasoning, you can run CrudApp with a real model backend:

mvn exec:java -pl examples -Dexec.mainClass="rsp.app.posts.CrudApp" -Dai.agent=claude
# or -Dai.agent=ollama

6. Build your own admin app via LLM

Once you've run the example, open your favorite AI coding assistant (Claude, GitHub Copilot, ChatGPT) in the project root and paste a prompt like this:

"Read examples/src/main/java/rsp/app/posts/CrudApp.java. Generate a similar realtime admin tool for managing Employees and Departments. Create mock services and a new EmployeeAdminApp.java using the same routing, composition, and AI-agent integration patterns."

Maintainable in the long run

Within a Life Cycle of an internal tool usually the boring "maintain" part is what takes a sheer size of efforts and risks over the years.

You built it—you should be able to maintain and repair it. You should be able to replace and fix almost every part of your stack by yourself. Of course, with great power comes great responsibility: to fix your tractor, you have to know how and have the necessary skills and tools in your garage.

Open Source software gives a promise that this would be possible yet in practice an NPM-style dependency management makes it almost impossible. That is the core idea this project aims to demonstrate: the entire UI stack is provided in a bundled, compact form, fully available for exploration and modification. Good luck doing that with the entangled dependency trees of modern JS frameworks!

The AI revolution removes the remaining friction. Spinning up a new component with one or two short prompts in this toolkit feels like magic. You remain in control: ride the edge of the AI frontier, or—once you tame the manageable complexity of this codebase—go completely off-grid, potentially with help of a local model.

The result? Simpler, predictable software that you can confidently maintain for the long haul.

Apps
About Me
GitHub: Trinea
Facebook: Dev Tools
AI Daily Digest