# rudranarayan94/devsecops architecture

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

- Interactive diagram: https://gitdiagram.com/rudranarayan94/devsecops
- Repository: https://github.com/rudranarayan94/devsecops

## Overview

##### Project Type and Purpose
- This is a frontend-only (React) application paired with Infrastructure-as-Code (Terraform) to provision AWS resources and a fully automated DevSecOps CI/CD pipeline.
- Purpose: convert currency rates in the browser, deployed on an EC2 instance via CodePipeline/CodeBuild/CodeDeploy. Terraform provisions VPC, EC2, S3, IAM roles, pipeline, etc.

##### File Structure
- Top level:
- README.md – project overview and setup
- .gitignore
- Terraform/ – Terraform modules and configs
- Key IaC files: Terraform/main.tf (resources), variables.tf (inputs), backend.tf (remote state), output.tf (outputs).
- Pipeline config: buildspec.yml (CodeBuild), appspec.yml (CodeDeploy), scripts/install.sh.

##### Extract Architecture Details from README
- Networking: VPC, public subnet, IGW, Security Group (HTTP/SSH).
- Compute: single EC2 (Amazon Linux), IAM instance profile.
- Artifact store: S3 bucket for Terraform state & CodePipeline artifacts.
- CI/CD: CodePipeline (Source→Build→Deploy), CodeBuild (build React), CodeDeploy (deploy to EC2).
- Source: GitHub repo, GitHub PAT.

##### Main Components & Their Relationships
a. Developer & GitHub
- Developer pushes code (React + Terraform + configs) to GitHub repo.
b. Terraform IaC
- terraform init/plan/apply creates:
- VPC, Subnet, Internet Gateway
- Security Group
- EC2 instance + IAM Role
- S3 bucket for remote state & pipeline artifacts
- CodePipeline, CodeBuild, CodeDeploy roles and resources
c. CI/CD Pipeline (AWS)
- Source stage: reads from GitHub → stores source in S3.
- Build stage: CodeBuild pulls source, runs buildspec.yml → outputs artifacts to S3.
- Deploy stage: CodeDeploy pulls artifact, uses appspec.yml & scripts/install.sh → deploys to EC2.
d. React Frontend
- Served by nginx/apache on EC2 (user data installs CodeDeploy agent & web server).
- End users (browsers) access EC2 public IP over HTTP (port 80).
e. AWS Services
- S3: holds Terraform state (backend.tf) & CodePipeline artifacts.
- IAM: roles/policies for least-privilege access.
- EC2: hosts the built React static site.
- VPC components ensure networking.

##### Architectural Patterns & Principles
- Infrastructure as Code: declarative provisioning with Terraform.
- DevSecOps pipeline: automated security-aware build and deployment.
- Cloud-native services: leverage managed services (CodePipeline et al).
- Least privilege: IAM roles on EC2 and pipeline components.
- Separation of concerns: React code vs. IaC code vs. deployment scripts.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer & Source Control
    subgraph "Developer & Source Control"
        Dev("Developer"):::external
        GitHub("GitHub Repo"):::external
    end
    Dev -->|"push code"| GitHub

    %% Terraform IaC
    subgraph "Terraform Infrastructure-as-Code"
        TF("Terraform"):::iac
        backend("backend.tf"):::iac
        main("main.tf"):::iac
        var("variables.tf"):::iac
        output("output.tf"):::iac
    end
    GitHub -->|"source with IaC"| TF
    TF -->|"provision resources"| VPC

    %% AWS Infrastructure
    subgraph "AWS Infrastructure"
        VPC("VPC"):::aws
        Subnet("Subnet"):::aws
        IGW("Internet Gateway"):::aws
        SG("Security Group"):::aws
        EC2("EC2 Instance"):::aws
        IAM("IAM Role"):::aws
        S3_state("S3 Bucket\n(State & Artifacts)"):::aws
    end
    VPC --> Subnet
    Subnet --> IGW
    VPC --> SG
    SG --> EC2
    IAM --> EC2
    S3_state -.-> EC2

    %% CI/CD Pipeline
    subgraph "CI/CD Pipeline"
        CodePipeline("CodePipeline"):::cicd
        CodeBuild("CodeBuild"):::cicd
        S3_artifact("S3 Artifacts"):::cicd
        CodeDeploy("CodeDeploy"):::cicd
    end
    GitHub -->|"Source stage"| CodePipeline
    CodePipeline -->|"Build stage"| CodeBuild
    CodeBuild -->|"buildspec.yml → artifact"| S3_artifact
    S3_artifact -->|"Deploy stage"| CodeDeploy
    CodeDeploy -->|"deploy appspec & scripts"| EC2

    %% End User
    subgraph "End User"
        Browser("Browser (HTTP Client)"):::external
    end
    Browser -->|"HTTP GET"| EC2

    %% Click Events
    click TF "https://github.com/rudranarayan94/devsecops/tree/main/Terraform/"
    click backend "https://github.com/rudranarayan94/devsecops/blob/main/Terraform/backend.tf"
    click main "https://github.com/rudranarayan94/devsecops/blob/main/Terraform/main.tf"
    click var "https://github.com/rudranarayan94/devsecops/blob/main/Terraform/variables.tf"
    click output "https://github.com/rudranarayan94/devsecops/blob/main/Terraform/output.tf"

    %% Styles
    classDef external fill:#f9f,stroke:#333,stroke-width:1px
    classDef iac fill:#ccf,stroke:#333,stroke-width:1px
    classDef aws fill:#cfc,stroke:#333,stroke-width:1px
    classDef cicd fill:#fcf,stroke:#333,stroke-width:1px
```
