# roldophe/redis-caching architecture

> Architecture diagram of the GitHub repository roldophe/redis-caching, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/roldophe/redis-caching
- Repository: https://github.com/roldophe/redis-caching

## Overview

This Spring Boot demo exposes user CRUD over REST, with service-layer caching backed by Redis and user persistence in H2. The documented flow is client request → user API → service operations → cache or repository/database; create, update, delete, lookup-by-ID/email, and cache clearing are distinct capabilities. README examples document cache behavior and repository use, but Java sources were not sampled, so controller-to-service and configuration wiring are left unverified where necessary.

Main entry points: [`src/main/java/com/example/redis_caching/service/UserService.java`](https://github.com/roldophe/redis-caching/blob/main/src/main/java/com/example/redis_caching/service/UserService.java) (User Service), [`src/main/java/com/example/redis_caching/controller/UserController.java`](https://github.com/roldophe/redis-caching/blob/main/src/main/java/com/example/redis_caching/controller/UserController.java) (User Controller), [`src/main/java/com/example/redis_caching/repository/UserRepository.java`](https://github.com/roldophe/redis-caching/blob/main/src/main/java/com/example/redis_caching/repository/UserRepository.java) (User Repository), [`src/main/resources/application.yaml`](https://github.com/roldophe/redis-caching/blob/main/src/main/resources/application.yaml) (Application Settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["REST API"]
  node_controller["User Controller"]
end

subgraph group_domain["User Operations"]
  node_service["User Service<br/>[UserService.java]"]
  node_user["User Entity<br/>[User.java]"]
  node_initializer["Sample Data Loader"]
end

subgraph group_infra["Persistence and Cache"]
  node_repository["User Repository"]
  node_h2[("H2 Database")]
  node_redis[("Redis Cache")]
  node_redisconfig["Redis Configuration<br/>[RedisConfig.java]"]
  node_appconfig["Application Settings<br/>[application.yaml]"]
end

node_client(("API Client"))

node_client -->|"calls REST API"| node_controller
node_controller -.->|"delegates operations"| node_service
node_service -->|"queries and saves"| node_repository
node_repository -->|"persists users"| node_h2
node_service -->|"caches results"| node_redis
node_appconfig -->|"sets cache TTL"| node_redis

click node_controller "https://github.com/roldophe/redis-caching/blob/main/src/main/java/com/example/redis_caching/controller/UserController.java"
click node_service "https://github.com/roldophe/redis-caching/blob/main/src/main/java/com/example/redis_caching/service/UserService.java"
click node_user "https://github.com/roldophe/redis-caching/blob/main/src/main/java/com/example/redis_caching/entity/User.java"
click node_repository "https://github.com/roldophe/redis-caching/blob/main/src/main/java/com/example/redis_caching/repository/UserRepository.java"
click node_redisconfig "https://github.com/roldophe/redis-caching/blob/main/src/main/java/com/example/redis_caching/config/RedisConfig.java"
click node_appconfig "https://github.com/roldophe/redis-caching/blob/main/src/main/resources/application.yaml"
click node_initializer "https://github.com/roldophe/redis-caching/blob/main/src/main/java/com/example/redis_caching/config/DataInitializer.java"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_controller,node_client toneBlue
class node_service,node_user,node_initializer toneAmber
class node_repository,node_h2,node_redis,node_redisconfig,node_appconfig toneMint
```

## Components

### REST API

- [User Controller](https://github.com/roldophe/redis-caching/blob/main/src/main/java/com/example/redis_caching/controller/UserController.java): `src/main/java/com/example/redis_caching/controller/UserController.java`

### User Operations

- [User Service](https://github.com/roldophe/redis-caching/blob/main/src/main/java/com/example/redis_caching/service/UserService.java): `src/main/java/com/example/redis_caching/service/UserService.java`
- [User Entity](https://github.com/roldophe/redis-caching/blob/main/src/main/java/com/example/redis_caching/entity/User.java): `src/main/java/com/example/redis_caching/entity/User.java`
- [Sample Data Loader](https://github.com/roldophe/redis-caching/blob/main/src/main/java/com/example/redis_caching/config/DataInitializer.java): `src/main/java/com/example/redis_caching/config/DataInitializer.java`

### Persistence and Cache

- [User Repository](https://github.com/roldophe/redis-caching/blob/main/src/main/java/com/example/redis_caching/repository/UserRepository.java): `src/main/java/com/example/redis_caching/repository/UserRepository.java`
- **H2 Database**
- **Redis Cache**
- [Redis Configuration](https://github.com/roldophe/redis-caching/blob/main/src/main/java/com/example/redis_caching/config/RedisConfig.java): `src/main/java/com/example/redis_caching/config/RedisConfig.java`
- [Application Settings](https://github.com/roldophe/redis-caching/blob/main/src/main/resources/application.yaml): `src/main/resources/application.yaml`

### Other components

- **API Client**

## Connections

- API Client → User Controller: calls REST API (evidence: `README.md`)
- User Controller → User Service: delegates operations
- User Service → User Repository: queries and saves (evidence: `README.md`)
- User Repository → H2 Database: persists users (evidence: `README.md`)
- User Service → Redis Cache: caches results (evidence: `README.md`)
- Application Settings → Redis Cache: sets cache TTL (evidence: `README.md`)
