# apingale2026/aws_devops_pipeline_simple_manual_aws_project_1 architecture

> Architecture diagram of the GitHub repository apingale2026/aws_devops_pipeline_simple_manual_aws_project_1, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/apingale2026/aws_devops_pipeline_simple_manual_aws_project_1
- Repository: https://github.com/apingale2026/aws_devops_pipeline_simple_manual_aws_project_1

## Overview

1. **Repository purpose**
   - This repo is a small AWS DevOps pipeline for a **containerized Flask To-Do application**.
   - The main architectural idea is: **GitHub source → Docker image build → ECR registry → EC2 runtime deployment**, fully automated by AWS CI/CD services.

2. **Application boundary**
   - `app.py` contains the actual **Flask web app** and is the application layer you would diagram as the runtime service.
   - The app provides **CRUD behavior for a To-Do list**, so the external interface is the HTTP web endpoint exposed by the container.

3. **Containerization boundary**
   - `Dockerfile` defines how the Flask app is packaged into a container image.
   - This is the boundary between application code and deployment/runtime infrastructure: the app runs inside a Docker container rather than directly on EC2.

4. **Artifact registry**
   - The built image is pushed to **Amazon ECR**.
   - ECR is the durable handoff point between build and deploy stages, and it is where the deploy target pulls the exact image version from.

5. **CI build subsystem**
   - `buildspec.yml` is the CodeBuild definition.
   - Its role is to build the Docker image, authenticate to ECR, and publish the image artifact so downstream deployment can reference the correct version.

6. **Deployment orchestration**
   - `appspec.yml` is the **CodeDeploy** deployment manifest.
   - It tells CodeDeploy how to place files and run deployment hooks on the EC2 instance, making it the bridge between pipeline artifacts and server-side execution.

7. **EC2 runtime subsystem**
   - The app ultimately runs on an **Amazon EC2 instance**.
   - The instance is not just a compute host; it is the target deployment node that pulls the container image from ECR and launches the containerized Flask service.

8. **Host provisioning and lifecycle scripts**
   - `userdatascript` is used to bootstrap the EC2 instance, likely installing **Docker, AWS CLI, and the CodeDeploy agent**.
   - `scripts/pull_and_run.sh` and `scripts/cleanup.sh` look like deployment lifecycle helpers: one to fetch and start the new container, and one to stop/remove old containers or cleanup prior state.

9. **Pipeline flow**
   - The end-to-end flow described in the README is:
     - developer pushes code to GitHub,
     - CodePipeline detects the change,
     - CodeBuild builds and pushes the container image to ECR,
     - CodeDeploy updates the EC2 host using the deployment spec and scripts.
   - This is a classic **source-controlled immutable image deployment** pattern.

10. **AWS service roles and boundaries**
   - The architecture depends on three AWS services with distinct responsibilities:
     - **CodePipeline** for orchestration,
     - **CodeBuild** for image creation and registry publish,
     - **CodeDeploy** for host-side rollout.
   - ECR is the artifact store, and EC2 is the execution environment.

11. **Operational characteristics**
   - Deployments are **push-triggered via GitHub webhook integration**, so each new commit can launch the pipeline automatically.
   - Because the app is containerized, the deployment unit is the **image version**, not a mutable server filesystem state.

12. **What to draw in an architecture diagram**
   - Draw four main zones:
     - **Source control**: GitHub repo containing `app.py`, Dockerfile, and pipeline files.
     - **Build/registry**: CodeBuild building a Docker image and pushing to ECR.
     - **Deployment control plane**: CodePipeline and CodeDeploy.
     - **Runtime**: EC2 instance with Docker and the CodeDeploy agent running the Flask container.
   - The central data flow is **source code → build artifact/image → registry → deployed container on EC2**.

Main entry points: [`scripts/pull_and_run.sh`](https://github.com/apingale2026/aws_devops_pipeline_simple_manual_aws_project_1/blob/main/scripts/pull_and_run.sh) (Pull and run), [`Dockerfile`](https://github.com/apingale2026/aws_devops_pipeline_simple_manual_aws_project_1/tree/main/Dockerfile) (Container spec), [`app.py`](https://github.com/apingale2026/aws_devops_pipeline_simple_manual_aws_project_1/blob/main/app.py) (Flask app), [`requirements.txt`](https://github.com/apingale2026/aws_devops_pipeline_simple_manual_aws_project_1/blob/main/requirements.txt) (Deps)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_source["Source control"]
  node_github(("GitHub<br/>source trigger"))
  node_app_py["Flask app<br/>web app<br/>[app.py]"]
  node_dockerfile["Container spec<br/>image build"]
  node_requirements["Deps<br/>[requirements.txt]"]
end

subgraph group_build["Build and registry"]
  node_buildspec["CodeBuild spec<br/>build config<br/>[buildspec.yml]"]
  node_codebuild{{"CodeBuild<br/>builder"}}
  node_ecr[("ECR<br/>registry")]
end

subgraph group_control["Deployment control"]
  node_codepipeline{{"CodePipeline<br/>orchestrator"}}
  node_appspec["AppSpec<br/>deploy manifest<br/>[appspec.yml]"]
  node_codedeploy{{"CodeDeploy<br/>deployer"}}
end

subgraph group_runtime["Runtime host"]
  node_ec2[("EC2 host<br/>compute target")]
  node_userdata["Bootstrap<br/>host init"]
  node_scripts["Deploy scripts<br/>lifecycle helpers"]
  node_pull_run["Pull and run<br/>deploy hook<br/>[pull_and_run.sh]"]
  node_cleanup["Cleanup<br/>deploy hook<br/>[cleanup.sh]"]
  node_container["Flask container<br/>runtime service"]
end

node_github -->|"push trigger"| node_codepipeline
node_app_py -->|"packaged by"| node_dockerfile
node_requirements -->|"install deps"| node_dockerfile
node_codepipeline -->|"build stage"| node_codebuild
node_buildspec -->|"configures"| node_codebuild
node_codebuild -->|"push image"| node_ecr
node_codepipeline -->|"deploy stage"| node_codedeploy
node_appspec -->|"configures"| node_codedeploy
node_codedeploy -->|"roll out"| node_ec2
node_userdata -->|"bootstrap"| node_ec2
node_ec2 -->|"runs hooks"| node_scripts
node_scripts -->|"pre-stop"| node_cleanup
node_scripts -->|"start"| node_pull_run
node_pull_run -->|"pull image"| node_ecr
node_pull_run -->|"launches"| node_container
node_container -->|"serves on"| node_ec2

click node_app_py "https://github.com/apingale2026/aws_devops_pipeline_simple_manual_aws_project_1/blob/main/app.py"
click node_dockerfile "https://github.com/apingale2026/aws_devops_pipeline_simple_manual_aws_project_1/tree/main/Dockerfile"
click node_requirements "https://github.com/apingale2026/aws_devops_pipeline_simple_manual_aws_project_1/blob/main/requirements.txt"
click node_buildspec "https://github.com/apingale2026/aws_devops_pipeline_simple_manual_aws_project_1/blob/main/buildspec.yml"
click node_appspec "https://github.com/apingale2026/aws_devops_pipeline_simple_manual_aws_project_1/blob/main/appspec.yml"
click node_userdata "https://github.com/apingale2026/aws_devops_pipeline_simple_manual_aws_project_1/tree/main/userdatascript"
click node_pull_run "https://github.com/apingale2026/aws_devops_pipeline_simple_manual_aws_project_1/blob/main/scripts/pull_and_run.sh"
click node_cleanup "https://github.com/apingale2026/aws_devops_pipeline_simple_manual_aws_project_1/blob/main/scripts/cleanup.sh"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_github,node_app_py,node_dockerfile,node_requirements toneBlue
class node_buildspec,node_codebuild,node_ecr toneAmber
class node_codepipeline,node_appspec,node_codedeploy toneMint
class node_ec2,node_userdata,node_scripts,node_pull_run,node_cleanup,node_container toneRose
```

## Components

### Source control

Repository content and application code

- **GitHub**: source trigger · Pushes commits and starts the delivery flow
- [Flask app](https://github.com/apingale2026/aws_devops_pipeline_simple_manual_aws_project_1/blob/main/app.py): web app · CRUD To-Do application entrypoint · `app.py`
- [Container spec](https://github.com/apingale2026/aws_devops_pipeline_simple_manual_aws_project_1/tree/main/Dockerfile): image build · Packages the Flask app into a Docker image · `Dockerfile`
- [Deps](https://github.com/apingale2026/aws_devops_pipeline_simple_manual_aws_project_1/blob/main/requirements.txt): python deps · Python package dependencies for the app · `requirements.txt`

### Build and registry

Container image creation and artifact storage

- [CodeBuild spec](https://github.com/apingale2026/aws_devops_pipeline_simple_manual_aws_project_1/blob/main/buildspec.yml): build config · Builds the Docker image and publishes it to ECR · `buildspec.yml`
- **CodeBuild**: builder · Executes image build and registry publish steps
- **ECR**: registry · Stores the immutable container image artifact

### Deployment control

Pipeline and deployment orchestration

- **CodePipeline**: orchestrator · Coordinates source, build, and deploy stages
- [AppSpec](https://github.com/apingale2026/aws_devops_pipeline_simple_manual_aws_project_1/blob/main/appspec.yml): deploy manifest · Describes how CodeDeploy places files and runs hooks · `appspec.yml`
- **CodeDeploy**: deployer · Rolls out the new image to the target host

### Runtime host

EC2 target and container launch environment

- **EC2 host**: compute target · Runs the deployed containerized Flask service
- [Bootstrap](https://github.com/apingale2026/aws_devops_pipeline_simple_manual_aws_project_1/tree/main/userdatascript): host init · Installs Docker, AWS CLI, and the CodeDeploy agent · `userdatascript`
- **Deploy scripts**: lifecycle helpers · Starts and stops the container during deployment
- [Pull and run](https://github.com/apingale2026/aws_devops_pipeline_simple_manual_aws_project_1/blob/main/scripts/pull_and_run.sh): deploy hook · Fetches the image and launches the Flask container · `scripts/pull_and_run.sh`
- [Cleanup](https://github.com/apingale2026/aws_devops_pipeline_simple_manual_aws_project_1/blob/main/scripts/cleanup.sh): deploy hook · Stops old containers and clears prior state · `scripts/cleanup.sh`
- **Flask container**: runtime service · Containerized To-Do web application serving HTTP requests

## Connections

- GitHub → CodePipeline: push trigger · Commit events start the delivery pipeline
- Flask app → Container spec: packaged by · Application code is assembled into the image
- Deps → Container spec: install deps · Dependencies are included in the container image
- CodePipeline → CodeBuild: build stage · Pipeline hands off to image build
- CodeBuild spec → CodeBuild: configures · Build instructions define the build actions
- CodeBuild → ECR: push image · Built image is published to the registry
- CodePipeline → CodeDeploy: deploy stage · Pipeline triggers host rollout after build
- AppSpec → CodeDeploy: configures · Deployment manifest defines rollout behavior
- CodeDeploy → EC2 host: roll out · Deployment updates the target instance
- Bootstrap → EC2 host: bootstrap · User data prepares the instance for deployment
- EC2 host → Deploy scripts: runs hooks · Deployment invokes lifecycle helper scripts
- Deploy scripts → Cleanup: pre-stop · Cleanup removes previous container state
- Deploy scripts → Pull and run: start · Pull and run script launches the new container
- Pull and run → ECR: pull image · Instance retrieves the immutable image version
- Pull and run → Flask container: launches · Container is started on the EC2 host
- Flask container → EC2 host: serves on · Runtime service executes on the compute host
