# anuragstark/cloudpulse-automated-deployment-cicd architecture

> Architecture diagram of the GitHub repository anuragstark/cloudpulse-automated-deployment-cicd, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-12). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/anuragstark/cloudpulse-automated-deployment-cicd
- Repository: https://github.com/anuragstark/cloudpulse-automated-deployment-cicd

## Overview

##### Project type and purpose
- This is a containerized Flask web application (“DevOps Demo Application”) with a CI/CD pipeline managed by GitHub Actions, an image registry in AWS ECR, and deployment to AWS Elastic Beanstalk (EB). There is no separate database or microservices—just a single-container web app.

##### File structure
- Top-level:
- Dockerfile & docker-compose.yml → local container build and orchestration
- Dockerrun.aws.json & .ebextensions/ → AWS EB deployment config
- .github/workflows/cicd.yml → GitHub Actions CI/CD pipeline
- app/ → Flask application code (app.py, templates, static assets)
- tests/ → automated tests (test_app.py)
- requirements.txt → Python dependencies
- AWS deployment manifests (Dockerrun.aws.json) and AWS EB extensions indicate a PaaS deployment on EB.

##### README for additional insights
- CI/CD flow: push to GitHub → GitHub Actions builds Docker image → pushes to ECR → uploads Dockerrun to S3 → updates EB environment
- AWS resources: ECR repo, S3 bucket for artifacts, EB application/environment, IAM user for Actions

##### Main components and interactions
a. Developer Workstation
- Writes Flask code under app/
- Runs local tests (pytest via tests/) and docker-compose
- Commits/pushes code to GitHub
b. GitHub Repository & GitHub Actions
- Trigger: push to main branch
- Steps: run tests → build Docker image → tag & push to ECR → upload Dockerrun.aws.json to S3 → deploy/update EB
c. AWS ECR (Elastic Container Registry)
- Stores Docker image: devops-demo-app:latest
d. AWS S3 Bucket
- Hosts Dockerrun.aws.json (deployment descriptor)
e. AWS Elastic Beanstalk
- Load Balancer + Auto Scaling Group of EC2 instances running Docker container on port 5000 → mapped to port 80
- Uses IAM roles (aws-elasticbeanstalk-ec2-role)
f. End-User (Web Browser)
- Sends HTTP requests to EB Load Balancer → routes to container

##### Architectural patterns and design principles
- Containerization (Docker) for consistent environments
- PaaS deployment via Elastic Beanstalk (abstracts infra management)
- CI/CD pipeline (GitOps pattern)
- Separation of concerns: code, build/test, registry, deployment, runtime

##### Elements
- Clear component names (e.g., “GitHub Actions CI/CD,” “AWS ECR Registry,” “Elastic Beanstalk Environment”)
- Source code & tests
- CI/CD pipeline
- Container registry & artifact storage
- Deployment platform & runtime
- Client traffic

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% Developer & GitHub Zone
  subgraph "Developer & GitHub" 
    direction TB
    DevWorkstation["Developer Workstation"]:::external
    Code["Flask Application Code"]:::code
    Dockerfile["Dockerfile"]:::build
    DockerCompose["docker-compose.yml"]:::build
    TestsLocal["Automated Tests (pytest)"]:::test
    DevWorkstation -->|writes code & runs tests| Code
    DevWorkstation -->|runs local docker-compose| DockerCompose
    DevWorkstation -->|runs local Dockerfile build| Dockerfile
    DevWorkstation -->|runs tests| TestsLocal
    DevWorkstation -->|git push to main| GitHubRepo
    click Code "https://github.com/anuragstark/cloudpulse-automated-deployment-cicd/tree/main/app/"
    click Dockerfile "https://github.com/anuragstark/cloudpulse-automated-deployment-cicd/tree/main/Dockerfile"
    click DockerCompose "https://github.com/anuragstark/cloudpulse-automated-deployment-cicd/blob/main/docker-compose.yml"
    click TestsLocal "https://github.com/anuragstark/cloudpulse-automated-deployment-cicd/blob/main/tests/test_app.py"
  end

  GitHubRepo["GitHub Repository"]:::ci

  %% CI/CD & Registry Zone
  subgraph "CI/CD & Registry"
    direction TB
    GitHubRepo -->|trigger pipeline| GitHubActions
    GitHubActions["GitHub Actions CI/CD"]:::ci
    Requirements["Python Dependencies"]:::artifact
    BuildImage["Docker Build & Tag"]:::build
    ECR["AWS ECR Registry"]:::storage
    S3["AWS S3 Bucket"]:::storage
    Config["Deployment Config"]:::config
    GitHubActions -->|install deps| Requirements
    GitHubActions -->|run tests| TestsCI
    GitHubActions -->|build image| BuildImage
    GitHubActions -->|push image| ECR
    GitHubActions -->|upload manifest| S3
    GitHubActions -->|invoke EB deploy| EBAPI
    click GitHubActions "https://github.com/anuragstark/cloudpulse-automated-deployment-cicd/blob/main/.github/workflows/cicd.yml"
    click Requirements "https://github.com/anuragstark/cloudpulse-automated-deployment-cicd/blob/main/requirements.txt"
    click Config "https://github.com/anuragstark/cloudpulse-automated-deployment-cicd/blob/main/Dockerrun.aws.json"
  end

  TestsCI["Automated Tests"]:::test
  click TestsCI "https://github.com/anuragstark/cloudpulse-automated-deployment-cicd/blob/main/tests/test_app.py"

  %% AWS Deployment & Runtime Zone
  subgraph "AWS Deployment & Runtime"
    direction TB
    EBAPI["Elastic Beanstalk API"]:::aws
    subgraph "Elastic Beanstalk Environment" 
      direction TB
      LB["Load Balancer"]:::compute
      EC2["EC2 + Docker Container"]:::compute
      LB -->|routes to port 5000| EC2
    end
    EBAPI -->|update environment| LB
    ECR -->|serves image| EBAPI
    S3 -->|provides Dockerrun| EBAPI
    EndUser["End-User (Web Browser)"]:::external
    EndUser -->|HTTP GET/POST| LB
    click EBAPI "https://github.com/anuragstark/cloudpulse-automated-deployment-cicd/tree/main/.ebextensions/"
    click Config "https://github.com/anuragstark/cloudpulse-automated-deployment-cicd/blob/main/Dockerrun.aws.json"
  end

  %% Connections
  GitHubActions --> ECR
  GitHubActions --> S3

  %% Styles
  classDef code fill:#cce5ff,stroke:#333,stroke-width:1px
  classDef build fill:#e6ccff,stroke:#333,stroke-width:1px
  classDef ci fill:#d4f4dd,stroke:#333,stroke-width:1px
  classDef artifact fill:#fff4cc,stroke:#333,stroke-width:1px
  classDef test fill:#fdd,stroke:#333,stroke-width:1px
  classDef storage fill:#ffe6e6,stroke:#333,stroke-width:1px
  classDef compute fill:#ffd9b3,stroke:#333,stroke-width:1px
  classDef config fill:#e0e0e0,stroke:#333,stroke-width:1px
  classDef aws fill:#e0f7fa,stroke:#333,stroke-width:1px
  classDef external fill:#f0f0f0,stroke:#333,stroke-width:1px
```
