# vapor/redis architecture

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

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

## Overview

##### Project type and purpose
- This is a Swift‐based Redis driver & integration library for the Vapor web framework. It wraps and re-exports functionality from the RediStack driver, adds convenience methods for caching, sessions, pub/sub, concurrency, and provides a Vapor Application extension for easy use.

##### File structure
- Top‐level files:
- Package.swift → Swift Package manifest
- README.md, LICENSE, CI/workflow configs → docs & automation
- Sources/Redis:
- Application+Redis.swift, Application.Redis+*.swift → Vapor integration extensions and PubSub/configuration setups
- Redis+*.swift → feature‐specific command sets (Cache, Concurrency, Sessions)
- RedisClient+Codable.swift → encoding/decoding support
- RedisConfiguration.swift, RedisID.swift, RedisStorage.swift → core configuration & protocol definitions
- Tests/RedisTests: unit and integration tests covering core functionality.

##### README for additional insights
- Confirms it’s a wrapper around RediStack, intended for Vapor 4, with full API documented in upstream RediStack docs.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Vapor Application"
        App["Vapor Application"]:::frontend
    end

    subgraph "RedisLibrary Module"
        subgraph "Configuration & Storage"
            Config["RedisConfiguration"]:::core
            ID["RedisID"]:::core
            Storage["RedisStorage"]:::core
        end
        subgraph "Core Client"
            Exports["Exports (RediStack wrapper)"]:::core
            Request["Request+Redis"]:::core
        end
        subgraph "Command Extensions"
            Cache["Redis+Cache"]:::ext
            Sessions["Redis+Sessions"]:::ext
            PubSub["Application.Redis+PubSub"]:::ext
            Concurrency["Redis+Concurrency"]:::ext
            Codable["RedisClient+Codable"]:::ext
        end
        subgraph "Documentation"
            Docs["Docs.docc"]:::docs
            Index["index.md"]:::docs
        end
    end

    Redis["Redis Server"]:::external

    subgraph "Test Harness"
        T1["RedisTests.swift"]:::tests
        T2["MultipleRedisTests.swift"]:::tests
    end

    App -->|"initializes"| Config
    App -->|"imports core client"| Exports
    App -->|"uses pub/sub setup"| PubSub
    App -->|"executes commands"| Request

    Cache -->|"calls"| Request
    Sessions -->|"calls"| Request
    Concurrency -->|"calls"| Request
    Codable -->|"decodes responses via"| Request

    Request -->|"TCP/RESP"| Redis
    Redis -->|"RESP responses"| Request

    T1 -->|"runs tests on"| App
    T1 -->|"connects to"| Redis
    T2 -->|"runs tests on"| App
    T2 -->|"connects to"| Redis

    click App "https://github.com/vapor/redis/blob/main/Sources/Redis/Application+Redis.swift"
    click Config "https://github.com/vapor/redis/blob/main/Sources/Redis/RedisConfiguration.swift"
    click ID "https://github.com/vapor/redis/blob/main/Sources/Redis/RedisID.swift"
    click Storage "https://github.com/vapor/redis/blob/main/Sources/Redis/RedisStorage.swift"
    click Exports "https://github.com/vapor/redis/blob/main/Sources/Redis/Exports.swift"
    click Request "https://github.com/vapor/redis/blob/main/Sources/Redis/Request+Redis.swift"
    click Cache "https://github.com/vapor/redis/blob/main/Sources/Redis/Redis+Cache.swift"
    click Sessions "https://github.com/vapor/redis/blob/main/Sources/Redis/Redis+Sessions.swift"
    click PubSub "https://github.com/vapor/redis/blob/main/Sources/Redis/Application.Redis+PubSub.swift"
    click Concurrency "https://github.com/vapor/redis/blob/main/Sources/Redis/Redis+Concurrency.swift"
    click Codable "https://github.com/vapor/redis/blob/main/Sources/Redis/RedisClient+Codable.swift"
    click Docs "https://github.com/vapor/redis/blob/main/Sources/Redis/Docs.docc"
    click Index "https://github.com/vapor/redis/blob/main/Sources/Redis/Docs.docc/index.md"
    click T1 "https://github.com/vapor/redis/blob/main/Tests/RedisTests/RedisTests.swift"
    click T2 "https://github.com/vapor/redis/blob/main/Tests/RedisTests/MultipleRedisTests.swift"

    classDef core fill:#ADD8E6,stroke:#000
    classDef ext fill:#90EE90,stroke:#000
    classDef external fill:#FFA500,stroke:#000
    classDef tests fill:#D3D3D3,stroke:#000,stroke-dasharray: 5 5
    classDef docs fill:#E6E6FA,stroke:#000
    classDef frontend fill:#f0f8ff,stroke:#000
```
