A RESTful CRUD API built with Spring Boot 4 and Redis, demonstrating in-memory data persistence using Redis Hash operations via RedisTemplate. Designed to showcase backend engineering skills with a focus on performance-oriented data storage.
| Layer | Technology |
|---|---|
| Framework | Spring Boot 4 (Spring MVC) |
| Data Store | Redis (via Lettuce client) |
| Serialization | Jackson (JSON) |
| Boilerplate Reduction | Lombok |
| Build Tool | Maven |
| Language | Java 17 |
Client
│
▼
UserController ← REST layer (@RestController)
│
▼
UserDao ← Data access layer (@Repository)
│
▼
RedisTemplate ← Spring Data Redis abstraction
│
▼
Redis (Hash) ← Persistent key-value store (Hash key: "USER")
- RedisConfig — Configures
LettuceConnectionFactoryand a customRedisTemplatewithStringRedisSerializerfor keys andJackson2JsonRedisSerializerfor values. - UserDao — Encapsulates all Redis Hash operations (
opsForHash), keeping Redis logic out of the controller. - UserController — Thin REST layer that delegates to the DAO and handles HTTP semantics.
- UserModel — Serializable POJO with Lombok annotations, stored as JSON in Redis.
Base URL: http://localhost:8080
| Method | Endpoint | Description |
|---|---|---|
POST |
/users |
Create a new user |
GET |
/users/{userId} |
Retrieve a user by ID |
GET |
/users |
Retrieve all users |
PUT |
/users |
Update an existing user |
DELETE |
/users/{userId} |
Delete a user by ID |
{
"userId": "auto-generated (UUID)",
"name": "John Doe",
"email": "john@example.com",
"phone": "123-456-7890"
}- Java 17+
- Maven 3.8+
- Redis running locally on port
6379
Start Redis (if using Docker):
docker run -d -p 6379:6379 redis./mvnw spring-boot:runsrc/main/resources/application.properties
spring.data.redis.host=localhost
spring.data.redis.port=6379- UUID generation is handled server-side in the controller, ensuring clients never need to supply an ID on creation.
- Redis Hash (
opsForHash) is used to store all users under a single hash key (USER), enabling O(1) lookups byuserId. - Jackson2JsonRedisSerializer ensures objects are stored as human-readable JSON in Redis rather than binary blobs.
- Lettuce is used as the Redis client (non-blocking, thread-safe, built into Spring Data Redis).
- Serializable model ensures compatibility with Java serialization if needed alongside JSON serialization.
src/main/java/com/Redis/Implement/
├── Config/
│ └── RedisConfig.java # Redis connection & template configuration
├── Controller/
│ └── UserController.java # REST endpoints
├── Dao/
│ └── UserDao.java # Redis Hash CRUD operations
├── Model/
│ └── UserModel.java # User entity (Lombok + Serializable)
└── ImplementApplication.java # Spring Boot entry point
Create a user:
curl -X POST http://localhost:8080/users \
-H "Content-Type: application/json" \
-d '{"name":"Jane Doe","email":"jane@example.com","phone":"555-0100"}'Get all users:
curl http://localhost:8080/usersDelete a user:
curl -X DELETE http://localhost:8080/users/{userId}