# kameshpudi/devsecops-demo architecture

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

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

## Overview

##### Project Type and Purpose
- This is a single-page web application (SPA) built with React & TypeScript that implements a Tic Tac Toe game, complete with score tracking and game history.
- It includes a full DevSecOps pipeline: Docker containerization, GitHub Actions CI/CD, and Kubernetes deployment manifests.

##### Main Components
a. Developer Workspace & Source Code
- Code repository (GitHub) containing:
- src/ (React components, gameLogic utils)
- Configuration files (tsconfig, eslint, tailwind, Vite)
- README, Dockerfile, Kubernetes manifests, GitHub Actions workflows.
b. CI/CD Pipeline (GitHub Actions)
- Steps: checkout → install deps → lint/tests → build Docker image → push to container registry → deploy to Kubernetes cluster.
c. Container Registry
- Docker Hub or GitHub Container Registry (holds the built image).
d. Kubernetes Cluster
- Ingress Controller (manages HTTP/S routing)
- Service (ClusterIP service for the tic-tac-toe pods)
- Deployment (Pod template running the Docker image)
e. End-User Browser
- The user’s browser accessing the application via the Ingress endpoint.

##### Relationships and Data Flows
- Developer → Git push → triggers GitHub Actions.
- GitHub Actions → builds Docker image → pushes to registry → applies Kubernetes manifests (kubectl).
- Kubernetes Ingress → routes HTTP requests from the user’s browser to the Service.
- Service → load-balances traffic to Pods running the React app.

##### Architectural Patterns & Design Principles
- SPA Architecture: clear separation of UI (components/Board, Square, ScoreBoard, GameHistory) and logic (utils/gameLogic).
- Infrastructure as Code: Dockerfile + Kubernetes YAML in kubernetes/*.yaml.
- GitOps/CICD: declarative workflows in .github/workflows/ci-cd.yml.
- Container-based/Immutable infrastructure for repeatable deployments.

- Layer 1: Developer Onboarding
- GitHub Repo
- src/, Dockerfile, kubernetes/, workflows.
- Layer 2: CI/CD (GitHub Actions)
- Step 1: Checkout & Install
- Step 2: ESLint + unit tests (gameLogic.test.ts)
- Step 3: Build app (Vite → dist/)
- Step 4: Docker build & push
- Step 5: kubectl apply to Kubernetes
- Layer 3: Container Registry
- Image: devsecops-demo:latest
- Layer 4: Kubernetes Deployment
- Deployment → ReplicaSet → Pods (running built image)
- Service (ClusterIP)
- Ingress (Hostname routing)
- Layer 5: End User
- Browser GET / → Ingress → Service → Pod → static assets → Browser displays React app

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% Developer Workspace
  subgraph "Developer Workspace" 
    direction TB
    Repo["GitHub Repo\n/"]:::dev
    subgraph "Source Code" 
      direction TB
      Board["Board.tsx"]:::dev
      Square["Square.tsx"]:::dev
      ScoreBoard["ScoreBoard.tsx"]:::dev
      GameHistory["GameHistory.tsx"]:::dev
      GameLogic["gameLogic.ts"]:::dev
      Tests["gameLogic.test.ts"]:::dev
      Main["main.tsx"]:::dev
      App["App.tsx"]:::dev
      Index["index.html"]:::dev
    end
    subgraph "Configuration Files" 
      direction TB
      TSConfig["tsconfig.json"]:::dev
      TSConfigApp["tsconfig.app.json"]:::dev
      TSConfigNode["tsconfig.node.json"]:::dev
      ESLint["eslint.config.js"]:::dev
      Tailwind["tailwind.config.js"]:::dev
      PostCSS["postcss.config.js"]:::dev
      Vite["vite.config.ts"]:::dev
      Package["package.json"]:::dev
      Lock["package-lock.json"]:::dev
      GitIgnore[".gitignore"]:::dev
      Dockerfile["Dockerfile"]:::dev
      DockerIgnore[".dockerignore"]:::dev
      KubeREADME["kubernetes/README.md"]:::dev
      ProjectREADME["README.md"]:::dev
    end
  end

  %% CI/CD Pipeline
  subgraph "CI/CD Pipeline (GitHub Actions)" 
    direction TB
    Checkout["Checkout"]:::ci
    Install["Install Deps"]:::ci
    LintTest["ESLint & Unit Tests"]:::ci
    BuildApp["Vite Build (dist/)"]:::ci
    DockerBuild["Docker Build"]:::ci
    DockerPush["Push to Registry"]:::ci
    KubeDeploy["kubectl apply"]:::ci
  end

  %% Container Registry
  Registry["Container Registry\n(devsecops-demo:latest)"]:::registry

  %% Kubernetes Cluster
  subgraph "Kubernetes Cluster" 
    direction TB
    Ingress["Ingress"]:::runtime
    Service["Service (ClusterIP)"]:::runtime
    Deployment["Deployment → ReplicaSet"]:::runtime
    Pod["Pod (React App)"]:::runtime
  end

  %% End User
  Browser["End-User Browser"]:::user

  %% Connections Developer -> CI
  Repo -->|push| Checkout
  Checkout -->|npm install| Install
  Install -->|npm run lint & test| LintTest
  LintTest -->|vite build| BuildApp
  BuildApp -->|docker build| DockerBuild
  DockerBuild -->|docker push| DockerPush
  DockerPush -->|kubectl apply| KubeDeploy

  %% CI -> Registry & Cluster
  DockerPush --> Registry
  KubeDeploy --> Ingress

  %% User Traffic
  Browser -->|HTTP Request| Ingress
  Ingress --> Service
  Service --> Pod
  Pod -->|serves static| Browser

  %% Click Events Developer
  click Repo "https://github.com/kameshpudi/devsecops-demo/tree/main//"
  click Board "https://github.com/kameshpudi/devsecops-demo/blob/main//src/components/Board.tsx"
  click Square "https://github.com/kameshpudi/devsecops-demo/blob/main//src/components/Square.tsx"
  click ScoreBoard "https://github.com/kameshpudi/devsecops-demo/blob/main//src/components/ScoreBoard.tsx"
  click GameHistory "https://github.com/kameshpudi/devsecops-demo/blob/main//src/components/GameHistory.tsx"
  click GameLogic "https://github.com/kameshpudi/devsecops-demo/blob/main//src/utils/gameLogic.ts"
  click Tests "https://github.com/kameshpudi/devsecops-demo/blob/main//src/__tests__/gameLogic.test.ts"
  click Main "https://github.com/kameshpudi/devsecops-demo/blob/main//src/main.tsx"
  click App "https://github.com/kameshpudi/devsecops-demo/blob/main//src/App.tsx"
  click Index "https://github.com/kameshpudi/devsecops-demo/blob/main//index.html"
  click TSConfig "https://github.com/kameshpudi/devsecops-demo/blob/main//tsconfig.json"
  click TSConfigApp "https://github.com/kameshpudi/devsecops-demo/blob/main//tsconfig.app.json"
  click TSConfigNode "https://github.com/kameshpudi/devsecops-demo/blob/main//tsconfig.node.json"
  click ESLint "https://github.com/kameshpudi/devsecops-demo/blob/main//eslint.config.js"
  click Tailwind "https://github.com/kameshpudi/devsecops-demo/blob/main//tailwind.config.js"
  click PostCSS "https://github.com/kameshpudi/devsecops-demo/blob/main//postcss.config.js"
  click Vite "https://github.com/kameshpudi/devsecops-demo/blob/main//vite.config.ts"
  click Package "https://github.com/kameshpudi/devsecops-demo/blob/main//package.json"
  click Lock "https://github.com/kameshpudi/devsecops-demo/blob/main//package-lock.json"
  click GitIgnore "https://github.com/kameshpudi/devsecops-demo/blob/main//.gitignore"
  click Dockerfile "https://github.com/kameshpudi/devsecops-demo/tree/main//Dockerfile"
  click DockerIgnore "https://github.com/kameshpudi/devsecops-demo/blob/main//.dockerignore"
  click KubeREADME "https://github.com/kameshpudi/devsecops-demo/blob/main//kubernetes/README.md"
  click ProjectREADME "https://github.com/kameshpudi/devsecops-demo/blob/main//README.md"

  %% Click Events CI
  click Checkout "https://github.com/kameshpudi/devsecops-demo/blob/main//.github/workflows/ci-cd.yml"
  click LintTest "https://github.com/kameshpudi/devsecops-demo/blob/main//.github/workflows/ci-cd.yml"
  click BuildApp "https://github.com/kameshpudi/devsecops-demo/blob/main//.github/workflows/ci-cd.yml"
  click DockerBuild "https://github.com/kameshpudi/devsecops-demo/blob/main//.github/workflows/ci-cd.yml"
  click DockerPush "https://github.com/kameshpudi/devsecops-demo/blob/main//.github/workflows/ci-cd.yml"
  click KubeDeploy "https://github.com/kameshpudi/devsecops-demo/blob/main//.github/workflows/ci-cd.yml"
  click Checkout "https://github.com/kameshpudi/devsecops-demo/blob/main//.github/workflows/README.md"

  %% Click Events Kubernetes Manifests
  click KubeREADME "https://github.com/kameshpudi/devsecops-demo/blob/main//kubernetes/README.md"
  click Ingress "https://github.com/kameshpudi/devsecops-demo/blob/main//kubernetes/ingress.yaml"
  click Service "https://github.com/kameshpudi/devsecops-demo/blob/main//kubernetes/service.yaml"
  click Deployment "https://github.com/kameshpudi/devsecops-demo/blob/main//kubernetes/deployment.yaml"

  %% Styles
  classDef dev fill:#D0E8FF,stroke:#0366D6,color:#0366D6;
  classDef ci fill:#FFE0B2,stroke:#FF9800,color:#BF360C;
  classDef registry fill:#E0E0E0,stroke:#9E9E9E,color:#424242;
  classDef runtime fill:#C8E6C9,stroke:#4CAF50,color:#1B5E20;
  classDef user fill:#F3E5F5,stroke:#9C27B0,color:#4A148C;
```
