Reference Architecture · Java / Applied AI
Open SourceAI Learn
A Java/Spring Boot reference application that treats AI conversations as durable backend workflows instead of transient model calls.
Problem
What problem existed before the work
A basic LLM request/response flow does not handle reconnects, long-running execution, cancellation, replay or multi-node delivery well.
Constraints
What the system had to respect
Conversation state and execution state must survive process boundaries, events need bounded replay, and delivery must work across more than one application node.
Challenge
Why the problem was difficult
The system needs to combine persistent application state with live streaming without making the transport layer the source of truth.
Approach
How I approached it
Persist conversations and runs in MySQL, use a transactional outbox, Redis Streams for bounded replay, Redis Pub/Sub for live multi-node fanout, and expose WebSocket/SSE delivery paths.
Architecture
How the system was shaped
MySQL is authoritative for conversations, messages and runs. Outbox events bridge committed state to Redis. Streams provide replay and Pub/Sub handles low-latency live delivery.
Key decisions
Decisions and reasoning
Keep the database authoritative, give runs and events stable identifiers, and design reconnect/cancellation semantics explicitly rather than assuming a permanent client connection.
Trade-offs
What was deliberately accepted or rejected
The additional persistence and event plumbing is heavier than a simple streaming endpoint, but it makes execution behavior explicit and recoverable.
Implementation
How the design moved into production
Implemented with Java 25, Spring Boot 4.1, JPA/Hibernate, LangChain4j, MySQL, Redis, WebSockets, SSE, Flyway and automated tests.
Reliability & security
How correctness and failure were handled
Idempotency keys, reply/run identifiers, replay cursors and explicit cancellation make duplicate and disconnected operations easier to reason about.
Impact
What changed
Provides public evidence of Java backend architecture around durable, streaming AI workflows.
Lessons learned
What the work reinforced
Durability and live streaming are separate concerns; keeping authoritative state independent from delivery makes the system easier to recover.
Case studies involving employer or client systems intentionally describe architecture and outcomes at a high level. They do not expose confidential source code, credentials, internal endpoints or restricted operational details.