# redis-developer/redis-om-spring-skeleton-app architecture

> Architecture diagram of the GitHub repository redis-developer/redis-om-spring-skeleton-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/redis-developer/redis-om-spring-skeleton-app
- Repository: https://github.com/redis-developer/redis-om-spring-skeleton-app

## Overview

##### Project Type and Purpose
- This is a Spring Boot application that demonstrates using Redis OM Spring for mapping Java objects (annotated with @Document) to RedisJSON documents.
- Its purpose is to showcase repository abstractions, custom object-mapping, and the ability to perform CRUD operations and complex queries via Redis. The README emphasizes working with CRUD operations, full-text search, and the use of entity streams backed by Redis.

##### Analyzing the File Structure
- The project uses Maven (see pom.xml and the mvnw files) with a standard Java package layout. The core application is in src/main/java under the package structure com.redis.om.skeleton.
- There are clear architectural separations:
– Controllers (in src/main/java/com/redis/om/skeleton/controllers): Expose different API endpoints (PeopleControllerV1 and PeopleControllerV2).
– Models (in src/main/java/com/redis/om/skeleton/models): Define entities like Person and Address that are stored as Redis JSON documents.
– Repositories (in src/main/java/com/redis/om/skeleton/repositories): Interfaces extending RedisDocumentRepository which handle data access.
– Services (in src/main/java/com/redis/om/skeleton/services): Contain business logic, for example, the PeopleService that uses Entity Stream for querying.
– The main application class (SkeletonApplication.java) bootstraps the Spring Boot application and sets up the Redis OM repositories.
- Additionally, configuration files (src/main/resources/application.properties) and deployment scripts (docker-compose.yml) indicate the app’s dependency on a Redis Stack instance (including RedisJSON and RediSearch modules).

##### Reading the README for Additional Insights
- The README outlines the data model, mapping details via annotations such as @Document, and explains the repository abstraction as well as the usage of Entity Streams.
- It also describes how the application integrates with external services like Docker-managed Redis, and provides instructions to launch the container for Redis and interact with the API (e.g., via Swagger or Curl).

a. Main Components to Include:
- Client / API Consumer: Represents external clients (e.g., using curl, Swagger UI) that send HTTP requests.
- REST Controllers: Two controllers (PeopleControllerV1 and PeopleControllerV2) that handle API requests.
- Service Layer: The PeopleService that contains business logic and makes use of Entity Stream for querying data.
- Repository Layer: PeopleRepository which abstracts the data access logic and communicates with Redis.
- Data Layer: Redis database (Redis Stack) hosting RedisJSON documents and RediSearch indexes.
- Supporting Infrastructure: Docker Compose environment launching the Redis instance and optionally RedisInsight for monitoring.
- The Spring Boot Application (SkeletonApplication) that boots the entire system and enables scanning for Redis Document Repositories.

b. Relationships and Interactions:
- How Docker Compose orchestrates the deployment of Redis, and annotate the network link between the Spring Boot app (which could be containerized or run locally) and the Redis container.

c. Architectural Patterns and Design Principles:
- The application follows layered (n-tier) architecture: Presentation (controllers), Business Logic (services), and Data Access (repositories).
- It utilizes Spring Data and dependency injection to reduce boilerplate code.
- The use of Redis OM Spring separates the domain model from its persistence representation.
- That the project leverages RESTful API design and embraces loose coupling between components.

d. Technologies & Frameworks:
- Spring Boot (application runner and dependency injection).
- Spring Data Redis and Redis OM Spring (repository and mapping abstractions).
- Redis (as the NoSQL data store enhanced with RedisJSON and RediSearch).
- Maven (build and dependency management).
- Docker Compose (deployment of the Redis Stack environment).

## Diagram (Mermaid)

```mermaid
graph TD
    %% Global Nodes
    Client["Client / API Consumer"] 
    Service["PeopleService"]
    Repo["PeopleRepository"]
    AppBoot["SkeletonApplication"]

    %% Subgraph: Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        PCV1["PeopleControllerV1"]
        PCV2["PeopleControllerV2"]
    end

    %% Subgraph: Data Layer
    subgraph "Data Layer"
        direction TB
        RedisDB["Redis DB (Stack: RedisJSON & RediSearch)"]
        Person["Person"]
        Address["Address"]
    end

    %% Subgraph: Infrastructure
    subgraph "Infrastructure"
        direction TB
        DockerCompose["Docker Compose (Redis)"]
        AppProps["Application Properties"]
    end

    %% Connections
    AppBoot --> PCV1
    AppBoot --> PCV2

    Client --> PCV1
    Client --> PCV2

    PCV1 --> Service
    PCV2 --> Service

    Service -->|"CRUD"| Repo

    Repo -->|"queries"| RedisDB
    RedisDB -->|"responses"| Repo

    Repo -->|"maps"| Person
    Repo -->|"maps"| Address

    DockerCompose --> RedisDB
    AppProps --> AppBoot

    %% Click Events
    click PCV1 "https://github.com/redis-developer/redis-om-spring-skeleton-app/blob/main/src/main/java/com/redis/om/skeleton/controllers/PeopleControllerV1.java"
    click PCV2 "https://github.com/redis-developer/redis-om-spring-skeleton-app/blob/main/src/main/java/com/redis/om/skeleton/controllers/PeopleControllerV2.java"
    click Service "https://github.com/redis-developer/redis-om-spring-skeleton-app/blob/main/src/main/java/com/redis/om/skeleton/services/PeopleService.java"
    click Repo "https://github.com/redis-developer/redis-om-spring-skeleton-app/blob/main/src/main/java/com/redis/om/skeleton/repositories/PeopleRepository.java"
    click Person "https://github.com/redis-developer/redis-om-spring-skeleton-app/blob/main/src/main/java/com/redis/om/skeleton/models/Person.java"
    click Address "https://github.com/redis-developer/redis-om-spring-skeleton-app/blob/main/src/main/java/com/redis/om/skeleton/models/Address.java"
    click AppBoot "https://github.com/redis-developer/redis-om-spring-skeleton-app/blob/main/src/main/java/com/redis/om/skeleton/SkeletonApplication.java"
    click DockerCompose "https://github.com/redis-developer/redis-om-spring-skeleton-app/blob/main/docker-compose.yml"
    click AppProps "https://github.com/redis-developer/redis-om-spring-skeleton-app/blob/main/src/main/resources/application.properties"

    %% Style Definitions
    classDef client fill:#e1f5fe,stroke:#0277bd,stroke-width:2px;
    classDef controller fill:#fff9c4,stroke:#f57f17,stroke-width:2px;
    classDef service fill:#c8e6c9,stroke:#388e3c,stroke-width:2px;
    classDef repository fill:#ffccbc,stroke:#d84315,stroke-width:2px;
    classDef database fill:#d1c4e9,stroke:#6a1b9a,stroke-width:2px;
    classDef model fill:#fce4ec,stroke:#ad1457,stroke-width:2px;
    classDef bootstrap fill:#ffe0b2,stroke:#ef6c00,stroke-width:2px;
    classDef infra fill:#b2ebf2,stroke:#00838f,stroke-width:2px;

    class Client client;
    class PCV1,PCV2 controller;
    class Service service;
    class Repo repository;
    class RedisDB database;
    class Person,Address model;
    class AppBoot bootstrap;
    class DockerCompose,AppProps infra;
```
