# moduscreateorg/devops-infra-demo architecture

> Architecture diagram of the GitHub repository moduscreateorg/devops-infra-demo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/moduscreateorg/devops-infra-demo
- Repository: https://github.com/moduscreateorg/devops-infra-demo

## Overview

##### Main Components
- Infrastructure Provisioning:
- Terraform modules (files in the terraform directory) that set up core AWS components such as VPC, subnets, security groups, Auto Scaling Groups, ELB, IAM roles/policies, and Route 53.
- Use of S3 and DynamoDB for Terraform state management and locking.
- Image Building & Configuration Management:
- Packer (in the “packer” directory and related bin scripts) which creates AMIs.
- Application Deployment & Code Packaging:
- CodeDeploy integration (files under “codedeploy” and scripts in “bin/codedeploy”) used for packaging and deploying the demo application.
- That the application itself exists in the “application” folder (static assets) and the Python application code is found in “src” (with endpoints like /api/spin).
- CI/CD Orchestration:
- Jenkins pipeline (Jenkinsfile) which orchestrates Packer runs, Terraform updates, CodeDeploy packaging, and even performance testing via JMeter.
- Auxiliary scripts (scripts in “bin”) that drive these processes, including scanning (Gauntlt, OpenSCAP) and deployment automation.
- Testing & Validation:
- JMeter (folder “jmeter”) for load testing and the use of containerized execution.
- Gauntlt (folder “gauntlt”) for security assessment and compliance testing.

##### Relationships and Interactions
- Packer builds AMIs using configuration scripts from the Ansible playbooks; these AMIs are then used by the Auto Scaling Group.
- CodeDeploy picks up application packages (from CodeDeploy folder and the packaging scripts) and deploys them onto instances.
- Jenkins (CI/CD server) triggers the entire pipeline: it initiates Packer builds, runs Terraform to provision/update infrastructure, packages applications, and may trigger load or security tests (JMeter and Gauntlt).
- Google Cloud Storage is touched for hosting application images and possibly assets referenced within the application.
- External services:
- Monitoring implementations (using New Relic and Cloudwatch from the corresponding Terraform and Ansible roles) which feed back into the pipeline.
- Vagrant is also available (via the Vagrantfile) for local staging and testing of Ansible playbooks.

##### Architectural Patterns & Design Principles
- Infrastructure layer (cloud resources, networking, security)
- Platform/Executable image layer (Packer + Ansible)
- Application layer (web static assets and Python API, CodeDeploy, load balancer)
- Testing and CI/CD orchestration (Jenkins, automated testing components)
- Clearly separated concerns:
- Infrastructure management (Terraform)
- Image building and configuration (Packer + Ansible)
- Deployment and application runtime (CodeDeploy, Auto Scaling, ELB)
- Continuous integration and testing (Jenkins, JMeter, Gauntlt/OpenSCAP)

##### Relevant Technologies & Frameworks
- AWS services – EC2, Auto Scaling Groups, ELB, S3, DynamoDB, and CodeDeploy.
- Google Cloud Storage (for application assets).
- Packer for AMI creation.
- Ansible as a configuration management engine.
- Terraform for infrastructure provisioning.
- Jenkins as the CI orchestrator.
- JMeter for load testing.
- Gauntlt and OpenSCAP for security compliance scanning.
- Docker is used for some tooling and containerized testing.

## Diagram (Mermaid)

```mermaid
graph TD
    %% CI/CD Orchestration
    subgraph "CI/CD Orchestration"
        Jenkins["Jenkins - CI/CD Pipeline"]:::cicd
        Automation["Automation Scripts"]:::cicd
    end

    %% Infrastructure Layer
    subgraph "Infrastructure Layer"
        Terraform["Terraform Infrastructure"]:::infra
        Cloud["AWS Cloud Resources (EC2,ELB,VPC,S3, etc)"]:::infra
        Monitoring["Monitoring (Cloudwatch/NewRelic)"]:::infra
    end

    %% Image Build & Configuration
    subgraph "Image Build & Configuration"
        Packer["Packer Image Build"]:::build
        Ansible["Ansible Configuration"]:::build
        Cloudwatch["Cloudwatch Agent Config"]:::build
    end

    %% Application Deployment
    subgraph "Application Deployment"
        CodeDeploy["CodeDeploy Application Package"]:::deploy
        DeployScripts["Deploy Scripts (CodeDeploy)"]:::deploy
        AutoScaling["Auto Scaling Group/EC2 Instances"]:::deploy
        AppAssets["Application Assets (Static)"]:::app
        PythonAPI["Python API (src)"]:::app
        GCloud["Google Cloud Storage"]:::app
    end

    %% Testing & Validation
    subgraph "Testing & Validation"
        JMeter["JMeter Testing"]:::test
        Gauntlt["Gauntlt Testing"]:::test
    end

    %% Local Staging/Testing
    Local["Vagrant (Local Testing)"]:::local

    %% Connections: CI/CD triggers builds and infra provisioning
    Jenkins -->|"triggers"| Packer
    Jenkins -->|"triggers"| Terraform
    Jenkins -->|"triggers"| Automation
    Automation -->|"executesInfra"| Terraform

    %% Image Build & Configuration flows
    Ansible -->|"configures"| Packer
    Cloudwatch -->|"feeds"| Monitoring
    Packer -->|"buildsAMI"| AutoScaling

    %% Infrastructure provisioning
    Terraform -->|"provisions"| Cloud
    Cloud -->|"hosts"| AutoScaling
    Monitoring -->|"monitors"| Cloud

    %% Application Deployment flows
    CodeDeploy -->|"deploys"| AutoScaling
    DeployScripts -->|"triggersDeployment"| CodeDeploy
    AutoScaling -->|"runsAssets"| AppAssets
    AutoScaling -->|"runsAPI"| PythonAPI
    AppAssets -->|"hostedOn"| GCloud

    %% CI/CD Testing triggers
    Jenkins -->|"triggersTesting"| JMeter
    Jenkins -->|"triggersTesting"| Gauntlt

    %% Click Events
    click Terraform "https://github.com/moduscreateorg/devops-infra-demo/blob/master/terraform/aws.tf"
    click Packer "https://github.com/moduscreateorg/devops-infra-demo/blob/master/packer/machines/web-server.json"
    click Ansible "https://github.com/moduscreateorg/devops-infra-demo/tree/master/ansible/roles/app-AfterInstall"
    click Cloudwatch "https://github.com/moduscreateorg/devops-infra-demo/tree/master/ansible/roles/cloudwatch-agent"
    click CodeDeploy "https://github.com/moduscreateorg/devops-infra-demo/blob/master/codedeploy/appspec.yml"
    click DeployScripts "https://github.com/moduscreateorg/devops-infra-demo/tree/master/bin/codedeploy"
    click Jenkins "https://github.com/moduscreateorg/devops-infra-demo/tree/master/Jenkinsfile"
    click Automation "https://github.com/moduscreateorg/devops-infra-demo/blob/master/bin/terraform.sh"
    click JMeter "https://github.com/moduscreateorg/devops-infra-demo/blob/master/jmeter/api-spin.jmx"
    click Gauntlt "https://github.com/moduscreateorg/devops-infra-demo/blob/master/gauntlt/nmap.attack"
    click AppAssets "https://github.com/moduscreateorg/devops-infra-demo/tree/master/application"
    click PythonAPI "https://github.com/moduscreateorg/devops-infra-demo/tree/master/src"
    click Local "https://github.com/moduscreateorg/devops-infra-demo/tree/master/Vagrantfile"

    %% Class Styles
    classDef cicd fill:#f9c,stroke:#333,stroke-width:2px;
    classDef infra fill:#ccf,stroke:#333,stroke-width:2px;
    classDef build fill:#cfc,stroke:#333,stroke-width:2px;
    classDef deploy fill:#fcf,stroke:#333,stroke-width:2px;
    classDef app fill:#cff,stroke:#333,stroke-width:2px;
    classDef test fill:#ffc,stroke:#333,stroke-width:2px;
    classDef local fill:#eee,stroke:#333,stroke-width:2px;
```
