A comprehensive multi-module Spring Boot application demonstrating modern microservices architecture, event-driven processing, and AI-powered categorization using cutting-edge technologies.
SpringBoot Playground is a multi-module Maven project that showcases a note-taking application with automatic categorization capabilities using keywords or AI (either OpenAI or AWS Bedrock). The project demonstrates real-world patterns including:
- Event-Driven Architecture using Apache Kafka
- Microservices communication via message streaming
- Outbox pattern when communicating with Apache Kafka
- AI-Powered Features using OpenAI and AWS Bedrock
- Stream Processing with Kafka Streams
- Multi-Database Support (PostgreSQL, MongoDB, OpenSearch)
- Docker Compose orchestration for full-stack deployment
The main REST API service for note management. Provides endpoints to create, read, update, and delete sticky notes with tag support.
Key Features:
- REST API for note operations
- PostgreSQL database and JPA / Hibernate for persistent storage
- Kafka producer (both JSON and Avro formats)
- Aspect-oriented programming for monitoring and event recording
- Spring Security for authentication/authorization
- Flyway database migrations
- OpenSearch integration for search capabilities
A Kafka Streams application that consumes sticky notes from Kafka topics and automatically categorizes them using AI models.
Key Features:
- Kafka Streams topology for real-time categorization
- Support for multiple categorization engines:
- OpenAI Integration via Spring AI
- AWS Bedrock Integration
- Keyword-based Categorization (fallback)
- Supported categories: Java, Spring, JPA, Kafka, Git, Docker, Cloud
Shared library containing common data models and Avro schemas.
Key Features:
- Avro schema definitions for type-safe serialization
- Code generation from Avro schemas
The easiest way to run the entire stack:
# Build and start all services using Docker Compose
./build-and-run-docker.shThis starts:
- PostgreSQL (port 5432): Database for notes
- MongoDB (port 27017): Optional document store
- Kafka Cluster (3 brokers): Message streaming
- kafka1: 29092
- kafka2: 29192
- kafka3: 29392
- Schema Registry (port 8081): Avro schema management
- Kafka Connect (port 8083): Data integration to send categorized notes to OpenSearch
- OpenSearch Cluster (2 nodes): Full-text search
- OpenSearch: 9200
- Dashboards: 5601
- Kafka REST Proxy (port 8082): HTTP API for Kafka
- springboot-note (port 8080): REST API for the main application
- springboot-note-categorizer: Kafka Streams application to categorize notes and produce categorized output
The Python script:
python tools/initial-data/create-sticky-notes-from-file.pycan be used to send sample sticky notes via REST API for testing. The script can be used multiple times.
The scripts:
./tools/kafka-connect/start-stickynote-sink-to-mongodb.sh
./tools/kafka-connect/start-stickynote-sink-to-opensearch.sh
./tools/kafka-connect/start-stickynotecategorized-sink-to-opensearch.shcan be used to start Kafka Connect connector to sink the data from Kafka topics:
- playground.stickynote.json into MongoDB
- playground.stickynote.json into OpenSearch
- playground.stickynote.json.categorized into OpenSearch
cd springboot-note
mvn spring-boot:runAPI available at: http://localhost:8080
cd springboot-note-categorizer
mvn spring-boot:runplayground.stickynote.json
- JSON-formatted sticky note events
- 9 partitions, replication factor 3
- Used for event streaming using JSON
playground.stickynote.avro
- Avro-serialized sticky note events
- Type-safe schema validation
- Used for event streaming using Avro and Schema Registry
playground.stickynote.json.categorized
- Categorized notes output from Kafka Streams
- Contains original note + assigned category
kafka-topics --bootstrap-server kafka1:29092 --create \
--topic playground.stickynote.json \
--partitions 9 --replication-factor 3
kafka-topics --bootstrap-server kafka1:29092 --create \
--topic playground.stickynote.avro \
--partitions 9 --replication-factor 3
kafka-topics --bootstrap-server kafka1:29092 --create \
--topic playground.stickynote.json.categorized \
--partitions 9 --replication-factor 3GET /notes- List all notesGET /notes/{id}- Get note by IDPOST /notes- Create new notePUT /notes/{id}- Update noteDELETE /notes/{id}- Delete note
GET /tags- List all tagsGET /tags/{id}- Get tag by IDPOST /tags- Create new tagPUT /tags/{id}- Update tagDELETE /tags/{id}- Delete tag
For springboot-note-categorizer:
KAFKA_BOOTSTRAP_SERVERS: Kafka broker addressesAWS_BEARER_TOKEN_BEDROCK: AWS credentials for BedrockOPENAI_API_KEY: OpenAI API key for ChatGPT access
- Spring Security enabled using basic authentication for REST API endpoints with credentials defined in the PostgreSQL database.
- OpenSearch database with authentication (username: admin, password: osPass@28g)
- PostgreSQL with SCRAM-SHA-256 authentication
- Default credentials are provided in compose.yaml (change in production)
AOP is used to track method execution time (threshold: 5ms by default)
The OpenSearch Dashboard is accessible at: http://localhost:5601 (after authentication)
Additional documentation is available in /docs:
Create Kafka topics.md- Kafka topic setup guideAccess Kafka topics.md- Consumer commandsOpenSearch sample queries.md- Search examples