# brenesrm/devsecops-nyit-van architecture

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

- Interactive diagram: https://gitdiagram.com/brenesrm/devsecops-nyit-van
- Repository: https://github.com/brenesrm/devsecops-nyit-van

## Overview

##### Main Components
- Application Code: Highlight the Flask-based Python web application (app.py) along with the vulnerable variant (app_vulnerable.py) to illustrate secure coding contrasts.
- Frontend Assets: Include the static directory (for CSS) and templates directory (HTML) which comprise the user interface.
- Containerization: Represent the Docker components – the primary Dockerfile and the Dockerfile-hardened variant – used for containerizing the application.
- Infrastructure as Code: Emphasize the Kubernetes (k8s folder) configurations including both standard and hardened cluster definitions, and the Argo CD setup from the argo folder for GitOps-based deployment.
- CI/CD Pipeline and Security Workflows: Show the GitHub workflows within the .github directory and note additional test scripts from the Documentation/tests directory along with security scanning configurations (e.g., CodeQL, Dependabot, Trivy, secret analysis).

##### Relationships and Interactions
- CI/CD process feeding into the Containerization stage, where the Docker images are built.
- Deployment flows from Docker images into the Kubernetes clusters. Connect these clusters to the Argo CD configurations that manage and monitor deployments.
- Interaction between the web application container and the database (init_db.py and test.db) as a backend service.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Clearly separate the frontend (static assets, HTML templates) from the backend logic (Flask in app.py) and database management.
- CI/CD and GitOps: Emphasize the role of automated workflows (located in .github and Documentation/old-workflows) and the use of Argo CD for deploying in Kubernetes.
- Security Integration: Illustrate embedded security practices at every stage—code analysis, container hardening, and runtime security—demonstrating the DevSecOps approach.

##### With Relevant Technologies and Tools
- Mention Flask as the web framework.
- Docker for containerization, alongside dedicated Docker hardening strategies.
- Kubernetes as the orchestrator, with Argo CD for deployment management.
- GitHub Actions for CI/CD automation, supported by tools like CodeQL, Dependabot, and Trivy for security scanning.
- Use of LaTeX (project.tex) for generating documentation and reports.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Source Code Repository Subgraph
    subgraph "Source Code Repository"
        A1["Flask App (app.py)"]:::app
        A2["Flask App Vulnerable (app_vulnerable.py)"]:::app
        F1["CSS (static/css/style.css)"]:::frontend
        F2["HTML Templates (templates/index.html)"]:::frontend
        D1["Database File (test.db)"]:::database
        D2["DB Initialization (init_db.py)"]:::database
        C1["Dockerfile"]:::container
        C2["Dockerfile Hardened"]:::container
        I1["Kubernetes Configs (k8s)"]:::infra
        I2["Argo CD Configs (argo)"]:::infra
        Doc1["LaTeX Docs (project.tex)"]:::documentation
        Doc2["Other Docs (Documentation)"]:::documentation
    end

    %% CI/CD Pipeline & Security Subgraph
    subgraph "CI/CD Pipeline & Security"
        S1["GitHub Actions (CICD.yml)"]:::cicd
        S2["Dependabot (dependabot.yml)"]:::cicd
        S3["Security & Test Docs (Documentation/tests)"]:::security
        S4["Old Workflows (Documentation/old-workflows)"]:::cicd
    end

    %% Process Flow Nodes
    SRC["Source Code"]:::source
    CICD["CI/CD Pipeline"]:::cicd
    BUILD["Container Build (Docker)"]:::container
    DEPLOY["Deployment (Kubernetes & Argo CD)"]:::infra
    RUN["Running Application"]:::app

    %% Connections from aggregated components to Process Flow
    A1 --- SRC
    A2 --- SRC
    F1 --- SRC
    F2 --- SRC
    D1 --- SRC
    D2 --- SRC
    C1 --- SRC
    C2 --- SRC
    I1 --- SRC
    I2 --- SRC
    Doc1 --- SRC
    Doc2 --- SRC

    %% Process Flow Connections
    SRC -->|"triggers"| CICD
    CICD -->|"builds image"| BUILD
    BUILD -->|"deploys to"| DEPLOY
    DEPLOY -->|"runs"| RUN
    RUN -->|"DBconnection"| D1
    RUN -->|"DBinit"| D2
    RUN -->|"uses"| F1
    RUN -->|"renders"| F2
    RUN -- "SecurityScan" --> CICD

    %% Link containerization and infra components to corresponding stages
    C1 --> BUILD
    C2 --> BUILD
    I1 --> DEPLOY
    I2 --> DEPLOY
    S1 --- CICD
    S2 --- CICD
    S3 --- CICD
    S4 --- CICD

    %% Styles
    classDef source fill:#f9f,stroke:#333,stroke-width:2px;
    classDef cicd fill:#ccf,stroke:#333,stroke-width:2px;
    classDef container fill:#cfc,stroke:#333,stroke-width:2px;
    classDef infra fill:#fc9,stroke:#333,stroke-width:2px;
    classDef app fill:#cff,stroke:#333,stroke-width:2px;
    classDef database fill:#f99,stroke:#333,stroke-width:2px;
    classDef frontend fill:#9fc,stroke:#333,stroke-width:2px;
    classDef documentation fill:#ffc,stroke:#333,stroke-width:2px;
    classDef security fill:#f6c,stroke:#333,stroke-width:2px;

    %% Click Events for Component Mapping
    click A1 "https://github.com/brenesrm/devsecops-nyit-van/blob/main/app.py"
    click A2 "https://github.com/brenesrm/devsecops-nyit-van/blob/main/app_vulnerable.py"
    click F1 "https://github.com/brenesrm/devsecops-nyit-van/blob/main/static/css/style.css"
    click F2 "https://github.com/brenesrm/devsecops-nyit-van/blob/main/templates/index.html"
    click D1 "https://github.com/brenesrm/devsecops-nyit-van/blob/main/test.db"
    click D2 "https://github.com/brenesrm/devsecops-nyit-van/blob/main/init_db.py"
    click C1 "https://github.com/brenesrm/devsecops-nyit-van/tree/main/Dockerfile"
    click C2 "https://github.com/brenesrm/devsecops-nyit-van/tree/main/dockerfile-hardened"
    click I1 "https://github.com/brenesrm/devsecops-nyit-van/tree/main/k8s"
    click I2 "https://github.com/brenesrm/devsecops-nyit-van/tree/main/argo"
    click S1 "https://github.com/brenesrm/devsecops-nyit-van/blob/main/.github/workflows/CICD.yml"
    click S2 "https://github.com/brenesrm/devsecops-nyit-van/blob/main/.github/dependabot/dependabot.yml"
    click S3 "https://github.com/brenesrm/devsecops-nyit-van/blob/main/Documentation/tests/appSecure.txt"
    click S4 "https://github.com/brenesrm/devsecops-nyit-van/blob/main/Documentation/old-workflows/CodeQL.yml"
    click Doc1 "https://github.com/brenesrm/devsecops-nyit-van/blob/main/project.tex"
    click Doc2 "https://github.com/brenesrm/devsecops-nyit-van/tree/main/Documentation"
```
