Files
spring-state-machine-renderer/README.md
2026-06-17 07:30:08 +02:00

1.3 KiB

Spring State Machine Explorer

Static analysis tool to extract and visualize Spring State Machines with deep code traceability.

Core Modules

  • state_machine_exporter: Java AST analyzer. Scans source code, resolves local Maven/Gradle dependencies, and extracts logic (Lambdas, Actions, Guards) into JSON/PUML.
  • state_machine_exporter_html: Generates an interactive HTML portal with SVG diagrams and rich tooltips.

Usage

1. Extract Metadata (JSON)

./gradlew :state_machine_exporter:run --args="-i ./my-project -o ./out -f json"

2. Generate Interactive Portal (HTML)

./gradlew :state_machine_exporter_html:run --args="-i ./my-project -o ./out_html"

Supports --profiles prod to resolve Spring property placeholders.

Business Flows

Define sequence of events in src/main/resources/flows.json:

[
  {
    "name": "Order Success",
    "description": "Happy path for order placement",
    "steps": ["PAY", "CHECK_AVAILABILITY->PENDING", "SHIP"]
  }
]

JSON Structure

  • metadata.entryPoints: REST, WebFlux, and JMS entry points.
  • metadata.callChains: Trace from API call to machine trigger (sendEvent).
  • transitions.actions[].internalLogic: Extracted source code/lambdas.
  • metadata.properties: Dictionary of all detected Spring profiles.