$ show javahongxi/whatsmars
This repository is a comprehensive multi-module Maven project that serves as a learning and demonstration resource for the Java ecosystem, specifically focusing on Spring Boot, microservices, middleware, and AI integration. It contains over 20 independent modules, each showcasing a specific technology or pattern: from core Spring features (AOP, events, lifecycle) to advanced distributed systems (Dubbo, gRPC, Netty, RocketMQ, Kafka, Redis, Elasticsearch, ShardingSphere, Sentinel, Nacos, Curator) and modern AI capabilities (LangChain4j-based RAG, agentic workflows, guardrails, MCP client, image generation, TTS). The architecture is a modular monolith where each module is independently runnable via its own Spring Boot application class, sharing a common utility library (whatsmars-common) for serialization, caching, consistent hashing, encryption, and logging. The AI module is particularly notable for implementing advanced patterns such as query compression, smart routing, re-ranking, structured output, and configurable agentic workflows (sequential, parallel, conditional, loop, supervisor). While the repository is not a single deployable product, it provides high-quality, well-documented examples that demonstrate non-obvious craftsmanship in areas like custom gRPC load balancing, consistent hashing with virtual nodes, and programmatic logger creation. The codebase is professionally written with good separation of concerns, though testing coverage is limited to utility classes. Overall, it is a valuable reference for Java developers exploring modern frameworks and AI integration patterns.
The LLM identified 3 files worth highlighting for reuse:
A generic, reusable consistent hashing router implementation with virtual nodes support. It uses an MD5-based hash function (default) and maintains a sorted map of hash circle positions. The router supports adding/removing nodes dynamically and is designed to be thread-safe for concurrent reads. This pattern is commonly used in distributed caching, load balancing, and key-based routing. The implementation is clean, well-tested, and can be extracted for use in other projects with minimal adaptation.
A utility class that bridges LangChain4j's TokenStream (reactive streaming of AI responses) to Spring's SseEmitter for Server-Sent Events. It handles token emission, completion, error propagation, and tool execution output. This pattern is essential for building real-time AI chat interfaces and is reusable across any Spring Boot project that uses LangChain4j for streaming responses.
A Runnable wrapper that copies the current thread's MDC context to the executing thread, solves the common problem of lost diagnostic context in asynchronous logging. It is generic and can be used with any ExecutorService. The pattern is simple but critical for observability, and the implementation is clean and reusable.