# redis/jedis architecture

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

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

## Overview

##### Main Components (Core Architecture)

a) Client Interface Layer
- Jedis (single-node client)
- JedisPooled (connection pooling)
- JedisCluster (cluster client)
- UnifiedJedis (unified interface)

b) Connection Management Layer
- Components:
- ConnectionPool
- ConnectionFactory
- Various ConnectionProviders (PooledConnectionProvider, ClusterConnectionProvider, etc.)
- Connection (handles actual Redis protocol communication)

c) Command Layer
- Command hierarchy:
- CommandObjects (command implementations)
- Protocol (Redis protocol handling)
- Various command interfaces (StringCommands, HashCommands, etc.)

##### Module Support Components
- RedisJSON
- RediSearch
- RedisBloom
- RedisTimeSeries
- RedisGraph

##### Connection Patterns
Different connection scenarios:
- Single node connection
- Sentinel-based connection
- Cluster connection
- SSL/TLS connection

##### Key Features to Highlight

a) Connection Pooling
- Pool management
- Resource allocation/deallocation

b) Failover Mechanism
- Primary/Replica failover
- Cluster node failover
- Sentinel-based failover

c) Pipeline & Transaction Support
- Pipeline execution flow
- Transaction handling

##### Specific details

a) Version Compatibility:
- Supported Redis versions (5.0-7.4)
- JDK compatibility (8, 11, 17, 21)

b) Security Features:
- SSL/TLS support
- Authentication mechanisms
- ACL support

## Diagram (Mermaid)

```mermaid
graph TB
    %% Client Interface Layer
    subgraph ClientLayer["Client Interface Layer"]
        Jedis["Jedis (Single Node)"]:::client
        JedisPooled["JedisPooled"]:::client
        JedisCluster["JedisCluster"]:::client
        UnifiedJedis["UnifiedJedis"]:::client
    end

    %% Connection Management Layer
    subgraph ConnectionLayer["Connection Management Layer"]
        ConnPool["Connection Pool"]:::conn
        ConnFactory["Connection Factory"]:::conn
        Connection["Connection"]:::conn
        
        subgraph Providers["Connection Providers"]
            ClusterProvider["Cluster Provider"]:::provider
            PooledProvider["Pooled Provider"]:::provider
            SentinelProvider["Sentinel Provider"]:::provider
        end
    end

    %% Command Layer
    subgraph CommandLayer["Command Layer"]
        CmdObjects["Command Objects"]:::cmd
        Protocol["Protocol"]:::cmd
        
        subgraph CmdInterfaces["Command Interfaces"]
            StringCmd["String Commands"]:::cmdint
            HashCmd["Hash Commands"]:::cmdint
            ListCmd["List Commands"]:::cmdint
        end
    end

    %% Module Support
    subgraph ModuleSupport["Redis Module Support"]
        RedisJSON["RedisJSON"]:::module
        RediSearch["RediSearch"]:::module
        RedisBloom["RedisBloom"]:::module
        RedisTimeSeries["RedisTimeSeries"]:::module
        RedisGraph["RedisGraph"]:::module
    end

    %% Pipeline & Transaction
    subgraph PipelineTx["Pipeline & Transaction"]
        Pipeline["Pipeline"]:::tx
        Transaction["Transaction"]:::tx
    end

    %% Relationships
    ClientLayer --> ConnectionLayer
    ConnectionLayer --> CommandLayer
    CommandLayer --> ModuleSupport
    CommandLayer --> PipelineTx
    
    %% Connection Management Details
    ConnFactory --> Connection
    ConnFactory --> ConnPool
    ConnPool --> Providers
    
    %% Command Layer Details
    CmdObjects --> Protocol
    Protocol --> Connection

    %% Style Definitions
    classDef client fill:#2374ab
    classDef conn fill:#ff7f50
    classDef provider fill:#ffa07a
    classDef cmd fill:#4caf50
    classDef cmdint fill:#81c784
    classDef module fill:#9c27b0
    classDef tx fill:#ff9800

    %% Click Events
    click Jedis "https://github.com/redis/jedis/blob/master/src/main/java/redis/clients/jedis/Jedis.java"
    click JedisPooled "https://github.com/redis/jedis/blob/master/src/main/java/redis/clients/jedis/JedisPooled.java"
    click JedisCluster "https://github.com/redis/jedis/blob/master/src/main/java/redis/clients/jedis/JedisCluster.java"
    click UnifiedJedis "https://github.com/redis/jedis/blob/master/src/main/java/redis/clients/jedis/UnifiedJedis.java"
    click ConnPool "https://github.com/redis/jedis/blob/master/src/main/java/redis/clients/jedis/ConnectionPool.java"
    click ConnFactory "https://github.com/redis/jedis/blob/master/src/main/java/redis/clients/jedis/ConnectionFactory.java"
    click Connection "https://github.com/redis/jedis/blob/master/src/main/java/redis/clients/jedis/Connection.java"
    click ClusterProvider "https://github.com/redis/jedis/blob/master/src/main/java/redis/clients/jedis/providers/ClusterConnectionProvider.java"
    click PooledProvider "https://github.com/redis/jedis/blob/master/src/main/java/redis/clients/jedis/providers/PooledConnectionProvider.java"
    click SentinelProvider "https://github.com/redis/jedis/blob/master/src/main/java/redis/clients/jedis/providers/SentineledConnectionProvider.java"
    click CmdObjects "https://github.com/redis/jedis/blob/master/src/main/java/redis/clients/jedis/CommandObject.java"
    click Protocol "https://github.com/redis/jedis/blob/master/src/main/java/redis/clients/jedis/Protocol.java"
    click StringCmd "https://github.com/redis/jedis/blob/master/src/main/java/redis/clients/jedis/commands/StringCommands.java"
    click HashCmd "https://github.com/redis/jedis/blob/master/src/main/java/redis/clients/jedis/commands/HashCommands.java"
    click ListCmd "https://github.com/redis/jedis/blob/master/src/main/java/redis/clients/jedis/commands/ListCommands.java"
    click RedisJSON "https://github.com/redis/jedis/tree/master/src/main/java/redis/clients/jedis/json"
    click RediSearch "https://github.com/redis/jedis/tree/master/src/main/java/redis/clients/jedis/search"
    click RedisBloom "https://github.com/redis/jedis/tree/master/src/main/java/redis/clients/jedis/bloom"
    click RedisTimeSeries "https://github.com/redis/jedis/tree/master/src/main/java/redis/clients/jedis/timeseries"
    click RedisGraph "https://github.com/redis/jedis/tree/master/src/main/java/redis/clients/jedis/graph"
    click Pipeline "https://github.com/redis/jedis/blob/master/src/main/java/redis/clients/jedis/Pipeline.java"
    click Transaction "https://github.com/redis/jedis/blob/master/src/main/java/redis/clients/jedis/Transaction.java"
```
