# ragavendira1/aidevsecopsdemo architecture

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

- Interactive diagram: https://gitdiagram.com/ragavendira1/aidevsecopsdemo
- Repository: https://github.com/ragavendira1/aidevsecopsdemo

## Overview

##### Project type and purpose
- This is a full-stack Java Spring Boot web application (“Java Coffee Shop”) with an embedded Thymeleaf frontend, intentional vulnerabilities for training, and export/import features. It also includes build/deploy scripts (Maven, Docker, CodeQL) and a set of workshop exercises/tools in the `workshop` and `tools` directories.

##### File structure
Top-level components:
- Docker & CI: Dockerfile, docker-compose.yml, `.github/workflows/devsecopsworkflow.yml`
- Build: `pom.xml`, `mvnw`, `.mvn/wrapper`
- Application source (`src/main/java/org/workshop/coffee`):
– `config/`: security, resource, failure listener
– `controller/`: REST + Thymeleaf controllers (Login, Register, CRUD, Upload, ExploitableUpload)
– `service/`: business logic (OrderService, ProductService, PersonService, CustomUserDetailsService)
– `repository/`: data access (OrderRepository, PersonRepository, ProductRepository, search repos)
– `domain/`: JPA entities (Order, Person, Product, etc.)
– `export/` and `formatter/`: XML/YAML import-export, formatters
– `gadget/`: proof-of-concept classes for vulnerability workshops
– `exception/`: custom exceptions
- Web resources (`src/main/resources`):
– `templates/`: Thymeleaf HTML views
– `static/`: CSS, JS assets
– `application.properties`: DB config, security settings
- Vulnerability training: `src/CodeQL`, `tools/log4shellserver`
- Workshop content: `workshop/*`

##### README
- Confirms it’s an intentionally vulnerable Spring Boot application used for security training with Thymeleaf UI.

a. Main components
1. Client Browser (UI)
2. Spring Boot Web App
- Presentation Layer: Thymeleaf templates + static assets served by `HomeController`, `LoginController`, etc.
- Controller Layer: REST endpoints & MVC controllers for orders, products, users, upload.
- Service Layer: business rules (`OrderService`, `PersonService`, `ProductService`).
- Data Layer: Spring Data JPA repositories connecting to the relational database.
- Security Module: `SecurityConfig`, `ResourceConfig`, `AuthenticationFailureListener`.
- Import/Export Module: XML/ YAML parsers & exporters.
3. Database (e.g., H2, PostgreSQL configured in `application.properties`)
4. External Services
- CodeQL scanner (CI/CD)
- log4shellserver (vulnerability demo server)
- (Optional) Search engine if used by `ExploitableSearchRepository`

b. Relationships and interactions
- Browser → Spring Boot (HTTP requests to controllers)
- Controllers → Services (method calls)
- Services → Repositories (JPA operations → Database)
- Import/Export module ↔ File system (uploads/downloads)
- Security filters intercept Browser ↔ Controllers calls
- CI workflow triggers CodeQL scan → source code repo
- Workshop tools and log4shellserver are external demonstration targets

c. Architectural patterns & principles
- Layered architecture (Presentation, Controller, Service, Repository)
- MVC pattern via Spring MVC + Thymeleaf
- Dependency injection in configs & services
- Use of Spring Security for authentication/authorization
- Modular feature packages (export, gadget, exception)

d. Relevant technologies
- Java 17+, Spring Boot, Spring MVC, Spring Security, Spring Data JPA
- Thymeleaf (view templates)
- Maven (build), Docker, Docker Compose
- CodeQL (static analysis), GitHub Actions (CI/CD)
- Workshop tools (Java-based log4shellserver)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% DevOps Layer
    subgraph "DevOps & CI/CD" 
        direction TB
        Dockerfile["Dockerfile"]:::devops
        Compose["docker-compose.yml"]:::devops
        Workflow["GitHub Actions Workflow"]:::devops
    end

    %% Build System
    subgraph "Build System"
        direction TB
        Wrapper["Maven Wrapper (mvnw)"]:::devops
        POM["pom.xml"]:::devops
    end

    %% Application Container
    subgraph "Application Container" 
        direction TB
        App["CoffeeShopApplication"]:::server
        subgraph "Security Module"
            direction TB
            SecConf["SecurityConfig"]:::server
            ResConf["ResourceConfig"]:::server
            AuthFail["AuthenticationFailureListener"]:::server
        end
        subgraph "Presentation Layer"
            direction TB
            Controllers["Controller Layer"]:::server
        end
        subgraph "Service Layer"
            direction TB
            Services["Service Layer"]:::server
        end
        subgraph "Data Access Layer"
            direction TB
            Repos["Repository Layer"]:::server
        end
        subgraph "Domain Model"
            direction TB
            Domain["JPA Entities"]:::server
        end
        subgraph "Import/Export Module"
            direction TB
            ExportMod["Import/Export"]:::server
        end
        Formatter["ProductFormatter"]:::server
        Gadget["Vulnerability Gadgets"]:::server
        ExceptionMod["Exception Handlers"]:::server
    end

    %% Web Resources
    subgraph "Web Resources"
        direction TB
        Templates["Thymeleaf Templates"]:::frontend
        StaticCSS["Static CSS"]:::frontend
        AppProps["application.properties"]:::server
    end

    %% External Systems
    subgraph "External Systems"
        direction TB
        Browser["Client Browser"]:::frontend
        Database["Relational Database"]:::external
        CodeQL["CodeQL Scanner"]:::devops
        Log4Shell["log4shellserver"]:::external
        Workshop["Workshop Exercises"]:::external
    end

    %% Flows
    Browser -->|"HTTP GET/POST"| App
    App -->|"calls"| SecConf
    App -->|"loads"| ResConf
    App -->|"listens"| AuthFail
    App -->|"routes to"| Controllers
    Controllers -->|"invokes"| Services
    Services -->|"CRUD via JPA"| Repos
    Repos -->|"JDBC"| Database
    Controllers -->|"uses"| Templates
    Templates -->|"renders"| Browser
    StaticCSS -->|"served"| Browser
    Controllers -->|"file I/O"| ExportMod
    ExportMod -->|"parses/formats"| Formatter
    App -->|"includes"| Gadget
    App -->|"throws"| ExceptionMod
    Workflow -.->|"triggers"| CodeQL
    Dockerfile -->|"builds"| App
    Compose -->|"orchestrates"| App
    Compose -->|"orchestrates"| Database
    Log4Shell -->|"demo target"| App
    Workshop -->|"training modules"| App

    %% Click Events
    click Dockerfile "https://github.com/ragavendira1/aidevsecopsdemo/tree/master/Dockerfile"
    click Compose "https://github.com/ragavendira1/aidevsecopsdemo/blob/master/docker-compose.yml"
    click Workflow "https://github.com/ragavendira1/aidevsecopsdemo/blob/master/.github/workflows/devsecopsworkflow.yml"
    click Wrapper "https://github.com/ragavendira1/aidevsecopsdemo/tree/master/mvnw"
    click POM "https://github.com/ragavendira1/aidevsecopsdemo/blob/master/pom.xml"
    click App "https://github.com/ragavendira1/aidevsecopsdemo/blob/master/src/main/java/org/workshop/coffee/CoffeeShopApplication.java"
    click SecConf "https://github.com/ragavendira1/aidevsecopsdemo/blob/master/src/main/java/org/workshop/coffee/config/SecurityConfig.java"
    click ResConf "https://github.com/ragavendira1/aidevsecopsdemo/blob/master/src/main/java/org/workshop/coffee/config/ResourceConfig.java"
    click AuthFail "https://github.com/ragavendira1/aidevsecopsdemo/blob/master/src/main/java/org/workshop/coffee/config/AuthenticationFailureListener.java"
    click Controllers "https://github.com/ragavendira1/aidevsecopsdemo/tree/master/src/main/java/org/workshop/coffee/controller"
    click Services "https://github.com/ragavendira1/aidevsecopsdemo/tree/master/src/main/java/org/workshop/coffee/service"
    click Repos "https://github.com/ragavendira1/aidevsecopsdemo/tree/master/src/main/java/org/workshop/coffee/repository"
    click Domain "https://github.com/ragavendira1/aidevsecopsdemo/tree/master/src/main/java/org/workshop/coffee/domain"
    click ExportMod "https://github.com/ragavendira1/aidevsecopsdemo/tree/master/src/main/java/org/workshop/coffee/export"
    click Formatter "https://github.com/ragavendira1/aidevsecopsdemo/blob/master/src/main/java/org/workshop/coffee/formatter/ProductFormatter.java"
    click Gadget "https://github.com/ragavendira1/aidevsecopsdemo/tree/master/src/main/java/org/workshop/coffee/gadget"
    click ExceptionMod "https://github.com/ragavendira1/aidevsecopsdemo/tree/master/src/main/java/org/workshop/coffee/exception"
    click AppProps "https://github.com/ragavendira1/aidevsecopsdemo/blob/master/src/main/resources/application.properties"
    click Templates "https://github.com/ragavendira1/aidevsecopsdemo/tree/master/src/main/resources/templates"
    click StaticCSS "https://github.com/ragavendira1/aidevsecopsdemo/blob/master/src/main/resources/static/css/style.css"
    click CodeQL "https://github.com/ragavendira1/aidevsecopsdemo/blob/master/src/CodeQL/sql-injection.ql"
    click Log4Shell "https://github.com/ragavendira1/aidevsecopsdemo/tree/master/tools/log4shellserver"
    click Workshop "https://github.com/ragavendira1/aidevsecopsdemo/tree/master/workshop"

    %% Styles
    classDef server fill:#D0E6FF,stroke:#004080
    classDef frontend fill:#FCE5CD,stroke:#AA5500
    classDef external fill:#C6F6D5,stroke:#2E8B57
    classDef devops fill:#FFE599,stroke:#B8860B
```
