# shivik0505/reddis architecture

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

- Interactive diagram: https://gitdiagram.com/shivik0505/reddis
- Repository: https://github.com/shivik0505/reddis

## Overview

##### Project Type and Purpose
- This is an AWS infrastructure provisioning and CI/CD template for deploying a multi-AZ Redis cluster.
- It uses Terraform for infrastructure as code, Ansible for configuration management, and Jenkins for pipeline automation.

##### File Structure Analysis
- Top-level IaC and CI/CD artifacts:
- terraform/ (VPC, subnets, security groups, EC2 instances, VPC peering)
- ansible/ (roles/redis for configuring Redis on instances)
- Jenkinsfile (pipeline stages)
- Dockerfile, docker-compose.yml (if containerizing parts)
- create_dynamic_inventory.sh, create_clean_inventory.sh
- create_infrastructure_diagram.py, create_redis_infrastructure_diagram.py, view_diagrams.py
- Deployment glue:
- playbook.yml (Ansible playbook to install and configure Redis)
- deploy-infrastructure.sh, quick-setup.sh, cleanup-scripts

##### Key Architecture from README
- Custom VPC (10.0.0.0/16) spanning 3 AZs
- 1 Bastion Host in a public subnet
- 3 Redis Nodes in private subnets (one per AZ)
- NAT Gateway for outbound internet from private subnets
- Security groups locking down Redis port (6379) and SSH access
- Jenkins pipeline stages: Checkout → Validate → Terraform → Wait → Ansible → Guide generation

a. Main Components
- AWS Cloud boundary enclosing:
- Public Subnet (AZ-a): Bastion Host
- Private Subnet (AZ-a, b, c): Redis Node 1, 2, 3
- Internet Gateway & NAT Gateway
- Security Groups (Bastion SG, Redis SG)
- External services:
- Jenkins Server (could be outside AWS or in a separate management VPC)
- Git Repository (SCM)
- Admin workstation (developer laptop)
b. Relationships and Interactions
- Jenkins → SCM (polling webhooks)
- Jenkins → AWS APIs (Terraform apply)
- Jenkins → run Ansible playbook via SSH through Bastion
- Developer SSH → Bastion → Redis nodes (per connection guide)
- Redis nodes form a cluster (show intra-cluster communication on port 6379)
c. Architectural Patterns and Principles
- Infrastructure as Code (Terraform modules grouping VPC, subnets, instances)
- Configuration as Code (Ansible role for Redis)
- Bastion host as a secure jump server
- Multi-AZ high availability
- CI/CD pipeline with clear stages and gated deployment
d. Technologies and Frameworks
- Terraform (IaC)
- Ansible (configuration management)
- Jenkins (CI/CD)
- AWS Services: EC2, VPC, Subnets, IGW, NAT Gateway, Security Groups

## Diagram (Mermaid)

```mermaid
flowchart TD
    Jenkins["Jenkins Server"]:::ci
    SCM["Git Repository"]:::external
    Jenkins -->|"polls/webhooks"| SCM
    Jenkins -->|"terraform apply"| TF["Terraform Root"]:::iac
    click TF "https://github.com/shivik0505/reddis/blob/master/terraform/main.tf"

    subgraph "AWS Region: ap-south-1"
        subgraph "Network Components"
            IGW["Internet Gateway"]:::network
            NAT["NAT Gateway"]:::network
        end
        subgraph "VPC (CIDR 10.0.0.0/16)"
            VPC["VPC"]:::network
            subgraph "Public Subnet (ap-south-1a)"
                Bastion["Bastion Host"]:::compute
            end
            subgraph "Private Subnets"
                subgraph "ap-south-1a"
                    Redis1["Redis Node 1"]:::compute
                end
                subgraph "ap-south-1b"
                    Redis2["Redis Node 2"]:::compute
                end
                subgraph "ap-south-1c"
                    Redis3["Redis Node 3"]:::compute
                end
            end
        end
    end

    TF --> ModVPC["VPC Module"]:::iac
    click ModVPC "https://github.com/shivik0505/reddis/blob/master/terraform/vpc/main.tf"
    TF --> ModSub["Subnets Module"]:::iac
    click ModSub "https://github.com/shivik0505/reddis/blob/master/terraform/subnets/main.tf"
    TF --> ModSG["Security Groups"]:::iac
    click ModSG "https://github.com/shivik0505/reddis/blob/master/terraform/security_group/main.tf"
    TF --> ModInst["EC2 Instances"]:::iac
    click ModInst "https://github.com/shivik0505/reddis/blob/master/terraform/instances/main.tf"
    TF --> ModPeer["VPC Peering"]:::iac
    click ModPeer "https://github.com/shivik0505/reddis/blob/master/terraform/vpc_peering/main.tf"

    ModVPC --> VPC
    ModSub --> Bastion
    ModSub --> Redis1
    ModSub --> Redis2
    ModSub --> Redis3
    ModSG --> Bastion
    ModSG --> Redis1
    ModSG --> Redis2
    ModSG --> Redis3
    ModInst --> Bastion
    ModInst --> Redis1
    ModInst --> Redis2
    ModInst --> Redis3
    ModPeer --> VPC

    Jenkins -->|"run Ansible"| ANS["Ansible Playbook"]:::iac
    click ANS "https://github.com/shivik0505/reddis/blob/master/playbook.yml"
    ANS --> ANScfg["Ansible Config"]:::iac
    click ANScfg "https://github.com/shivik0505/reddis/blob/master/ansible.cfg"
    click ANScfg "https://github.com/shivik0505/reddis/blob/master/ansible_jenkins.cfg"
    ANS --> Role["Redis Role"]:::iac
    click Role "https://github.com/shivik0505/reddis/tree/master/ansible/roles/redis/"
    ANS --> Bastion
    Bastion -.->|"SSH"| Redis1
    Bastion -.->|"SSH"| Redis2
    Bastion -.->|"SSH"| Redis3

    Jenkins -->|"build container"| DOCKER["Docker Definitions"]:::ci
    click DOCKER "https://github.com/shivik0505/reddis/tree/master/Dockerfile"
    click DOCKER "https://github.com/shivik0505/reddis/blob/master/docker-compose.yml"

    Jenkins -->|"generate diagrams"| DIAG["Diagram Scripts"]:::iac
    click DIAG "https://github.com/shivik0505/reddis/blob/master/create_infrastructure_diagram.py"
    click DIAG "https://github.com/shivik0505/reddis/blob/master/create_redis_infrastructure_diagram.py"
    click DIAG "https://github.com/shivik0505/reddis/blob/master/view_diagrams.py"

    Jenkins -->|"cleanup"| CLEAN["Cleanup Scripts"]:::iac
    click CLEAN "https://github.com/shivik0505/reddis/blob/master/cleanup-aws-resources.sh"
    click CLEAN "https://github.com/shivik0505/reddis/blob/master/cleanup-duplicates.sh"
    click CLEAN "https://github.com/shivik0505/reddis/blob/master/quick-cleanup.sh"

    Developer["Admin Workstation"]:::external
    Developer -->|"SSH"| Bastion

    Redis1 -->|"6379"| Redis2
    Redis2 -->|"6379"| Redis3

    classDef network fill:#cce5ff,stroke:#004085,color:#004085
    classDef compute fill:#d4edda,stroke:#155724,color:#155724
    classDef ci fill:#ffeeba,stroke:#856404,color:#856404
    classDef external fill:#f8d7da,stroke:#721c24,color:#721c24
    classDef iac fill:#d1ecf1,stroke:#0c5460,color:#0c5460
```
