A comprehensive Spring Boot learning project covering JPA, REST, Validation, Caching, Kafka, Async, and more.
- About the Project
- Tech Stack
- Project Structure
- Getting Started
- Feature Highlights
- API Endpoints & cURL
- Configuration
- Database & Caching
- Testing
- Roadmap
- Contributions & License
This project serves as a reference architecture for a modern Spring Boot application. It simulates an e-commerce + loan management system with realistic concerns:
- Entity relationships with validation
- Database persistence (MySQL)
- Performance tuning via Redis caching
- Async and concurrent workflows
- Distributed communication using Kafka
- Robust configuration across environments
- Developer productivity with Dockerized infrastructure
The intent is educational depth - so learners see not only how things work, but how they interlock in a production-like environment.
- Language: Java 11+
- Framework: Spring Boot (Web, Data JPA, Validation, Cache, Actuator)
- Database: MySQL
- Cache: Redis
- Messaging: Apache Kafka
- Build Tool: Maven
- Containerization: Docker & Docker Compose
- Logging: Log4j + reload4j
- Testing: JUnit 5, Spring Boot Test
src/
main/java/com/example/ecommercesystem/
config/ # Redis, Kafka, Logging, Security
controller/ # REST endpoints
service/ # Business logic, caching, async
repository/ # Spring Data JPA repositories
model/ # Entities, validation, serialization
kafka/ # Producer & Consumer services
main/resources/
application.properties
application-dev.properties
log4j.properties
reload4j.properties
amit/ # Infrastructure scripts
mysqldockercompose/ # MySQL docker-compose
redis_docker_compose/ # Redis docker-compose
kafka_docker_compose/ # Kafka docker-compose
test/
java/ # JUnit 5 tests
- Java 11+ (Java 17 compatible)
- Maven (or use
./mvnw) - Docker & Docker Compose
- Start dependencies (run in separate terminals):
docker-compose -f amit/mysqldockercompose/docker-compose.yaml up
docker-compose -f amit/redis_docker_compose/docker-compose.yaml up
docker-compose -f amit/kafka_docker_compose/docker-compose.yaml up- Build and run the app:
./mvnw clean install
./mvnw spring-boot:run- Access the app:
- Entity modeling with advanced javax.validation constraints
- REST API design with validation and unified error handling
- Repository layer powered by Spring Data JPA (custom queries, pagination, sorting)
- Service layer with Redis caching (
@Cacheable,@CacheEvict) - Async workflows using ExecutorService, Futures, and CompletableFuture
- Kafka messaging with producer/consumer scaffolding
- Observability with Spring Actuator, console + file logging
Products
# Get all products
curl -X GET http://localhost:8080/api/products
# Get paged products
curl -X GET "http://localhost:8080/api/products/pagelist?page=0&size=12"
# Get by ID
curl -X GET http://localhost:8080/api/products/1
# Search
curl -X GET "http://localhost:8080/api/products/search?name=Laptop&description=gaming"
# Create product
curl -X POST http://localhost:8080/api/products \
-H "Content-Type: application/json" \
-d '{ "name":"Laptop","description":"Gaming","price":1299.99,"contactEmail":"support@example.com","quantityAvailable":10 }'Async
curl -X POST http://localhost:8080/api/products/process
curl -X POST http://localhost:8080/api/products/process-async-with-futures
curl -X POST http://localhost:8080/api/products/process-async-with-cfKafka
curl -X POST http://localhost:8080/api/products/send-test-message \
-H "Content-Type: application/json" \
-d '{ "message":"hello" }'- MySQL:
jdbc:mysql://0.0.0.0:3306/loan_management(user:mysqluser, pass:mysqlpass) - Redis: host
localhost, port6379 - Kafka:
localhost:9092, consumer groupmyGroup - Profiles:
devby default; switch viaSPRING_PROFILES_ACTIVE - Logging: Console +
./logs/app.log
Environment override example (PowerShell):
$env:SPRING_PROFILES_ACTIVE = "dev"
$env:SPRING_DATASOURCE_URL = "jdbc:mysql://localhost:3306/loan_management"
$env:SPRING_DATASOURCE_USERNAME = "mysqluser"
$env:SPRING_DATASOURCE_PASSWORD = "mysqlpass"
./mvnw spring-boot:run- Entities:
Product,Category,Loan - Relationships: One-to-Many, Many-to-One with cascading
- Indexes:
product(name),product(price),category(name) - Batching: Consider effects of
GenerationType.IDENTITY - Caching (Redis):
- Cache names:
products,product - Keys:
product::id,products::SimpleKey[] - Eviction: Auto on save/update
- Serialization: JSON with
GenericJackson2JsonRedisSerializer
- Cache names:
Run all tests:
./mvnw testRun a specific test:
./mvnw -Dtest=ProductTest testSkip tests during build:
./mvnw -DskipTests clean install- Redis caching
- Kafka producer/consumer
- REST endpoints & pagination
- Async workflows
- Dockerized infrastructure
- JUnit scaffolding
- Dev profile configs
Planned:
- WebSocket integration
- Security (roles & JWT auth)
- MongoDB integration
- Connection pooling improvements
- Decorator patterns
- DB migrations instead of Hibernate DDL
Contributions are welcome. Please fork and submit pull requests for improvements.
License: MIT (add a LICENSE file if missing)
Happy learning - may this repository be your forge of architectural mastery.