# poojabhanudevops/redisdemo architecture

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

- Interactive diagram: https://gitdiagram.com/poojabhanudevops/redisdemo
- Repository: https://github.com/poojabhanudevops/redisdemo

## Overview

##### Project type and purpose
- This is an Infrastructure-as-Code (IaC) demo project (“Redisdemo”) that uses Terraform to provision AWS resources (VPC, subnets, security groups, EC2 instances, etc.) and Ansible to configure a Redis server on those EC2 instances. A Jenkinsfile suggests a CI/CD pipeline orchestrating Terraform & Ansible runs.

##### File structure
- Top-level:
- Jenkinsfile (CI/CD pipeline)
- ansible/ (configuration-management playbooks, handlers, templates, vars)
- playbook.yml & aws_ec2.yaml (entry points or inventory definitions)
- terraform/ (modules for VPC, subnets, security groups, instances, peering, backend.tf, provider.tf)
- Each terraform subdirectory defines a reusable module (variable.tf, main.tf, output.tf).
- ansible/templates/redis.conf.j2 holds the Redis configuration template.

##### README
- Minimal (“# Redisdemo”), so the key understanding comes from file names and structure.

a. Main components:
- CI/CD: Jenkins server
- IaC layer: Terraform modules
- Cloud provider: AWS (VPC, subnets, security groups, EC2)
- Configuration management: Ansible controller
- Redis service on EC2
b. Relationships & interactions:
1. Developer/PR triggers Jenkins pipeline.
2. Jenkins executes Terraform init/plan/apply against AWS (reading backend.tf, provider.tf).
3. Terraform provisions:
- VPC (terraform/vpc)
- Subnets (terraform/subnets)
- Security groups (terraform/security_group)
- VPC peering (terraform/vpc_peering)
- EC2 instances (terraform/instances)
4. Terraform outputs the inventory or host IPs (terraform/output.tf → Jenkin’s workspace).
5. Jenkins invokes Ansible (using ansible.cfg, playbook.yml or aws_ec2.yaml) to configure Redis server on the newly created EC2 host(s), applying the redis.conf.j2 template.
6. Redis is installed & configured, ready to serve.
c. Architectural patterns/design principles:
- Separation of concerns: Terraform for provisioning, Ansible for configuration.
- Modular Terraform (each AWS component in its own module).
- Declarative configuration.
- CI/CD orchestration with Jenkins.
d. Relevant technologies/frameworks:
- Terraform (HCL)
- AWS (EC2, VPC, subnets, security groups, peering)
- Ansible (YAML playbooks, Jinja2 templates)
- Jenkins pipeline

## Diagram (Mermaid)

```mermaid
flowchart TB
  subgraph "DevOps Orchestration"
    J["Jenkins (CI/CD)"]:::jenkins
  end

  subgraph "Provisioning - Terraform"
    subgraph "Terraform Root Configuration"
      PROV["provider.tf"]:::terraform
      BACK["backend.tf"]:::terraform
      VARF["variable.tf"]:::terraform
      OUTF["output.tf"]:::terraform
      MAIN["main.tf"]:::terraform
    end
    subgraph "Terraform Modules"
      VPC["vpc module"]:::terraform
      SUB["subnets module"]:::terraform
      SG["security_group module"]:::terraform
      VP["vpc_peering module"]:::terraform
      EC2M["instances module"]:::terraform
    end
  end

  subgraph "Cloud - AWS"
    AWSVPC["VPC"]:::aws
    AWSSUB["Subnets"]:::aws
    AWSSG["Security Groups"]:::aws
    AWSPEER["VPC Peering"]:::aws
    EC2["EC2 Instance (redis-node)"]:::aws
  end

  subgraph "Configuration - Ansible"
    ACFG["ansible.cfg"]:::ansible
    PLAY["playbook.yml"]:::ansible
    INV["aws_ec2.yaml"]:::ansible
    HAND["handlers/main.yml"]:::ansible
    TASK["tasks/main.yml"]:::ansible
    VARS["vars/main.yml"]:::ansible
    TPL["redis.conf.j2"]:::ansible
  end

  J -->|"trigger apply"| PROV
  J -->|"trigger apply"| BACK
  J -->|"trigger apply"| VARF
  J -->|"trigger apply"| OUTF
  J -->|"trigger apply"| MAIN

  PROV -->|provisions| VPC
  BACK -->|provisions| VPC
  VARF -->|provisions| VPC
  OUTF -->|provisions| VPC
  MAIN -->|provisions| VPC

  VPC -->|module apply| AWSVPC
  SUB -->|module apply| AWSSUB
  SG -->|module apply| AWSSG
  VP -->|module apply| AWSPEER
  EC2M -->|module apply| EC2

  J -->|"invoke playbook"| PLAY
  PLAY -->|"uses"| ACFG
  PLAY -->|"uses"| INV
  PLAY -->|"runs"| TASK
  PLAY -->|"calls"| HAND
  PLAY -->|"reads"| VARS
  PLAY -->|"templates"| TPL
  PLAY -->|"configures"| EC2

  classDef jenkins fill:#f2f2f2,stroke:#0b3d91,stroke-width:2px;
  classDef terraform fill:#e0f7fa,stroke:#00796b,stroke-width:2px;
  classDef aws fill:#fff3e0,stroke:#ef6c00,stroke-width:2px;
  classDef ansible fill:#e8f5e9,stroke:#2e7d32,stroke-width:2px;

  click J "https://github.com/poojabhanudevops/redisdemo/tree/main/Jenkinsfile"
  click PROV "https://github.com/poojabhanudevops/redisdemo/blob/main/terraform/provider.tf"
  click BACK "https://github.com/poojabhanudevops/redisdemo/blob/main/terraform/backend.tf"
  click VARF "https://github.com/poojabhanudevops/redisdemo/blob/main/terraform/variable.tf"
  click OUTF "https://github.com/poojabhanudevops/redisdemo/blob/main/terraform/output.tf"
  click MAIN "https://github.com/poojabhanudevops/redisdemo/blob/main/terraform/main.tf"
  click VPC "https://github.com/poojabhanudevops/redisdemo/blob/main/terraform/vpc/main.tf"
  click SUB "https://github.com/poojabhanudevops/redisdemo/blob/main/terraform/subnets/main.tf"
  click SG "https://github.com/poojabhanudevops/redisdemo/blob/main/terraform/security_group/main.tf"
  click VP "https://github.com/poojabhanudevops/redisdemo/blob/main/terraform/vpc_peering/main.tf"
  click EC2M "https://github.com/poojabhanudevops/redisdemo/blob/main/terraform/instances/main.tf"
  click ACFG "https://github.com/poojabhanudevops/redisdemo/blob/main/ansible.cfg"
  click PLAY "https://github.com/poojabhanudevops/redisdemo/blob/main/playbook.yml"
  click INV "https://github.com/poojabhanudevops/redisdemo/blob/main/aws_ec2.yaml"
  click HAND "https://github.com/poojabhanudevops/redisdemo/blob/main/ansible/handlers/main.yml"
  click TASK "https://github.com/poojabhanudevops/redisdemo/blob/main/ansible/tasks/main.yml"
  click VARS "https://github.com/poojabhanudevops/redisdemo/blob/main/ansible/vars/main.yml"
  click TPL "https://github.com/poojabhanudevops/redisdemo/blob/main/ansible/templates/redis.conf.j2"
```
