Skip to content

rodolfodpk/spring-crablet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

395 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crablet: AI-Assisted Event-Sourced Spring Applications From Event Models

Java CI codecov Java License: MIT

Crablet helps Spring teams turn an event-modeled domain into a working event-sourced application. It uses AI-assisted generation to produce the structural code around commands, events, views, automations, outbox publishers, and tests, then runs that code on a small Java 25 Spring Boot runtime.

Why Crablet May Be Useful

  • Event-model-first workflow for DCB-style domains
  • AI-assisted generation for commands, events, handlers, views, automations, outbox publishers, and tests
  • Cross-entity consistency without forcing everything into one aggregate stream
  • Small Java runtime for consistency, persistence, polling, and operational behavior
  • Manual APIs available when generated code needs customization

Framework Path

Crablet can be used directly as a Java framework: EventStore, command handlers, and CommandExecutor are the typical write path; views, outbox, automations, and the optional HTTP command adapter layer on top. For a first project, start with the module reference, Create a new Crablet app manually, the Tutorial, the Commands and Event Store module READMEs, and the Wallet example for a full app shape.

AI-First Path

The only tool you interact with is Claude Code. You describe outcomes in plain language; Claude handles modeling, planning, generating, and repairing — entirely through conversation.

One-time setup

Prerequisites: Java 25, Claude Code CLI, ANTHROPIC_API_KEY

# 1. Build the codegen JAR (from this repo)
make install && make codegen-build

# 2. Copy the template and drop the JAR in place
cp -r templates/crablet-app ../my-service
cp embabel-codegen/target/embabel-codegen.jar ../my-service/tools/

Start Claude Code

cd ../my-service
export ANTHROPIC_API_KEY=sk-ant-...
claude

The template's .claude/settings.json wires embabel-codegen as an MCP server. You never call java -jar directly — Claude Code calls the tools on your behalf.

Describe one outcome

Add the first vertical slice: Submit Loan Application.

Outcome:
- a customer submits a loan application
- Crablet records LoanApplicationSubmitted
- reviewers can query pending applications

Use the Crablet feature-slice workflow.
Ask for missing facts before changing files.

Claude will:

  1. Ask for the missing business facts (entity identity, idempotency, required fields, read model columns)
  2. Run /event-modeling to update event-model.yaml
  3. Call embabel_plan and show you the planned artifact list
  4. Wait for your approval before calling embabel_generate
  5. Fix any compile errors and tell you when to run ./mvnw verify

Repeat for each new slice. Update event-model.yaml when something is structural; edit generated code only for behavior the model cannot express.

Codegen is optional. The stable runtime APIs (CommandHandler, ViewProjector, CommandExecutor) work independently — you can build a full Crablet application without the generator. The AI-first path is a productivity layer on top, not a requirement.

When Crablet Fits

Crablet is a good fit when command decisions depend on more than one entity stream, consistency is naturally query-based, and you want the code to make concurrency semantics explicit.

It is probably not the right tool if plain CRUD is enough, one aggregate per command already fits your domain, or your team is not ready to standardize on Java 25.

Learning And Deployment

  • Learning mode: run one application instance with commands, views, automations, and outbox together. See Learning Mode.
  • Command-only production: applications using only crablet-eventstore and crablet-commands can scale horizontally in the normal Spring Boot way. See Commands-First Adoption.
  • Poller-backed production: applications enabling views, outbox, or automations should default to one application instance per cluster for the simplest topology, or use one singleton worker service per poller-backed module for isolation. See Deployment Topology.

Why Java 25

Crablet intentionally targets Java 25. The framework leans on modern Java features such as records, sealed types, and pattern matching to keep the public API small and explicit.

DCB At A Glance

Traditional event sourcing ties consistency to a single aggregate stream. DCB lets you define consistency boundaries dynamically, so a command can check consistency across multiple entity types using a query.

Crablet maps that model onto three append methods. These are Crablet API terms, not DCB spec vocabulary:

Method Use case Concurrency check
appendIdempotent Entity creation and duplicate prevention Uniqueness/idempotency check
appendNonCommutative State-dependent operations Stream-position-based conflict detection
appendCommutative Order-independent operations None, optionally guarded by lifecycle checks

Read more in DCB And Crablet and Command Patterns.

Documentation

Documentation index — how user (docs/user/) and dev (docs/dev/) are organized.

Framework

Quickstart · Tutorial · Create a new Crablet app manually · Learning mode · Commands-first adoption · Module reference · Public API · Deployment topology · DCB and Crablet · Command patterns · Configuration · Build · Performance · Troubleshooting · Upgrade · Management API · Fault recovery · Leader election · Connection poolers · Observability · Wallet example

AI tooling

AI-first workflow · Feature slice workflow · Event modeling · Event model format · Templates · Crablet app template · Embabel codegen

Contributors: see Build, CLAUDE.md, and framework development docs (maintainer plans, reviews, doc verification).

License

MIT License - see LICENSE.

About

Event sourcing framework for Spring Boot with DCB optimistic concurrency and AI-first codegen from event models

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages