# bansh2ebreak/springvulnboot-backend architecture

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

- Interactive diagram: https://gitdiagram.com/bansh2ebreak/springvulnboot-backend
- Repository: https://github.com/bansh2ebreak/springvulnboot-backend

## Overview

##### Project Type & Purpose
- This project is a backend component of a Java security training platform built on Spring Boot.
- Its purpose is to simulate various web vulnerabilities (SQL Injection, XSS, remote code execution, file upload bugs, path traversal, URL redirection, etc.) for learning, practical exercises, and penetration testing.
- Although the front-end is handled by a separate Vue-based repository, this backend focuses on providing vulnerable endpoints and business logic for the security lab scenarios.

##### File Structure Analysis
- Key Top-Level Files/Directories:
- pom.xml: Indicates use of Maven for dependency management and build.
- src/main/java/icu/secnotes: Contains the main application code.
- Controller sub-packages (Authentication, Components, FileUpload, PathTraversal, RCE, Redirect, SQLI, XSS): Each exposing endpoints simulating a specific vulnerability.
- Service and Mapper directories: Represent the service (business logic) and data access layers respectively.
- Config package: Contains configuration classes such as CorsConfig and WebConfig, which manage cross-origin requests and other web settings.
- Exception and Interceptor packages: Provide error handling routines and pre-request checks (e.g., LoginCheckInterceptor).
- Resources: Holds configuration files (application.yml, log configurations) and static assets (including vulnerable JSP pages).

##### Elements
a. Main Components:
- Frontend Component (external Vue Admin Template): Although in a different repository, include it as a consumer of the backend APIs.
- Spring Boot Application (Backend Server): The core of the system.
▫ Entry point: SpringVulnBootApplication.java.
▫ Controllers: Expose API endpoints for each type of vulnerability.
▫ Services: Contain business logic (e.g., LoginService, SmsCodeService).
▫ Data Access Layer: Mapper interfaces that communicate with the database.
▫ Exception Handling & Interceptors: GlobalExceptionHandler and LoginCheckInterceptor to manage request flows.
▫ Utility Components: Classes like JwtUtils and Security for security operations.
- Database: Represented by db.sql (implies there is an underlying SQL database that stores application data).
- External files/configurations: Highlight elements managed by pom.xml (dependencies) and application.yml (runtime configurations).

b. Relationships & Interactions:
- The Frontend sends HTTP requests (API calls) to the Spring Boot backend.
- The controllers route these requests into various services.
- Services process business logic and invoke mappers to interact with the database.
- Config classes (CorsConfig and WebConfig) and interceptors manage request routing, security headers, and validation.
- Exception handlers capture errors across the controllers.

c. Architectural Patterns/Design Principles:
- Layered Architecture:
▫ Presentation Layer: Controllers handling HTTP request/response cycles.
▫ Business Logic Layer: Service classes implementing the core functionality.
▫ Data Access Layer: Mappers interfacing with the database.
- Separation of Concerns: Each vulnerability demonstration is placed in its own package (e.g., for SQLI, XSS) making it modular.
- Use of configuration management (Spring Boot’s application.yml) and dependency injection inherent to Spring.

d. Relevant Technologies & Frameworks:
- SpringBoot (main framework) for building the backend.
- Java for implementation.
- Maven (pom.xml) for build and dependency management.
- Database (as per db.sql) likely running on a relational database.
- Various Spring modules for web, security, and data access.
- Integration of logging (log4j2) and external configurations (ESAPI.properties).

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["Frontend (Vue Client)"]:::frontend

    subgraph "Spring Boot Application"
        E["SpringVulnBootApplication"]:::entryPoint

        subgraph "Controllers (Presentation Layer)"
            C1["Authentication Controllers"]:::controller
            C2["FileUploadController"]:::controller
            C3["PathTraversalController"]:::controller
            C4["RCEController"]:::controller
            C5["RedirectController"]:::controller
            C6["SQLI Controllers"]:::controller
            C7["XSS Controllers"]:::controller
            C8["Components Controllers"]:::controller
            C9["LoginController"]:::controller
        end

        subgraph "Services (Business Logic)"
            S1["Service Interfaces"]:::service
            S2["Service Implementations"]:::service
        end

        subgraph "Data Access Layer (Mappers)"
            M["Mapper Interfaces"]:::dao
        end

        subgraph "Configurations & Utilities"
            CFG["Config Classes"]:::config
            AC["Application Config"]:::config
            U["Utility Components"]:::utility
        end

        subgraph "Exception & Interceptors"
            EXH["GlobalExceptionHandler"]:::exception
            LI["LoginCheckInterceptor"]:::exception
        end
    end

    D["Database"]:::database
    Mvn["Maven (pom.xml)"]:::maven

    %% Connections from Frontend to Controllers
    A -->|"HTTP_requests"| C1
    A -->|"HTTP_requests"| C2
    A -->|"HTTP_requests"| C3
    A -->|"HTTP_requests"| C4
    A -->|"HTTP_requests"| C5
    A -->|"HTTP_requests"| C6
    A -->|"HTTP_requests"| C7
    A -->|"HTTP_requests"| C8
    A -->|"HTTP_requests"| C9

    %% Entry point initializing Controllers
    E --> C1
    E --> C2
    E --> C3
    E --> C4
    E --> C5
    E --> C6
    E --> C7
    E --> C8
    E --> C9

    %% Controllers delegate requests to Services
    C1 -->|"delegate"| S1
    C2 -->|"delegate"| S1
    C3 -->|"delegate"| S1
    C4 -->|"delegate"| S1
    C5 -->|"delegate"| S1
    C6 -->|"delegate"| S1
    C7 -->|"delegate"| S1
    C8 -->|"delegate"| S1
    C9 -->|"delegate"| S1

    %% Services call Data Access Layer
    S1 -->|"calls"| M
    S2 -->|"calls"| M

    %% Config Classes configure Controllers
    CFG ---|"configures"| C1
    CFG ---|"configures"| C2
    CFG ---|"configures"| C3
    CFG ---|"configures"| C4
    CFG ---|"configures"| C5
    CFG ---|"configures"| C6
    CFG ---|"configures"| C7
    CFG ---|"configures"| C8
    CFG ---|"configures"| C9

    %% Exception Handling and Interceptors for Controllers (dashed lines)
    C1 -.->|"handledBy"| EXH
    C2 -.->|"handledBy"| EXH
    C3 -.->|"handledBy"| EXH
    C4 -.->|"handledBy"| EXH
    C5 -.->|"handledBy"| EXH
    C6 -.->|"handledBy"| EXH
    C7 -.->|"handledBy"| EXH
    C8 -.->|"handledBy"| EXH
    C9 -.->|"handledBy"| EXH

    C1 -.->|"interceptedBy"| LI
    C2 -.->|"interceptedBy"| LI
    C3 -.->|"interceptedBy"| LI
    C4 -.->|"interceptedBy"| LI
    C5 -.->|"interceptedBy"| LI
    C6 -.->|"interceptedBy"| LI
    C7 -.->|"interceptedBy"| LI
    C8 -.->|"interceptedBy"| LI
    C9 -.->|"interceptedBy"| LI

    %% Data Access Layer interacts with Database
    M -->|"queries"| D

    %% Maven links to Application Entry Point
    Mvn --> E

    %% Utility components usage
    U ---|"usedBy"| S1
    U ---|"usedBy"| C1

    %% Application Config sets up Config Classes and Utility Components
    AC ---|"setsUp"| CFG
    AC ---|"setsUp"| U

    %% Click Events
    click E "https://github.com/bansh2ebreak/springvulnboot-backend/blob/main/src/main/java/icu/secnotes/SpringVulnBootApplication.java"
    click C1 "https://github.com/bansh2ebreak/springvulnboot-backend/tree/main/src/main/java/icu/secnotes/controller/Authentication/"
    click C2 "https://github.com/bansh2ebreak/springvulnboot-backend/blob/main/src/main/java/icu/secnotes/controller/FileUpload/FileUploadController.java"
    click C3 "https://github.com/bansh2ebreak/springvulnboot-backend/blob/main/src/main/java/icu/secnotes/controller/PathTraversal/PathTraversalController.java"
    click C4 "https://github.com/bansh2ebreak/springvulnboot-backend/blob/main/src/main/java/icu/secnotes/controller/RCE/RCEController.java"
    click C5 "https://github.com/bansh2ebreak/springvulnboot-backend/blob/main/src/main/java/icu/secnotes/controller/Redirect/RedirectController.java"
    click C6 "https://github.com/bansh2ebreak/springvulnboot-backend/tree/main/src/main/java/icu/secnotes/controller/SQLI/"
    click C7 "https://github.com/bansh2ebreak/springvulnboot-backend/tree/main/src/main/java/icu/secnotes/controller/XSS/"
    click C8 "https://github.com/bansh2ebreak/springvulnboot-backend/tree/main/src/main/java/icu/secnotes/controller/Components/"
    click C9 "https://github.com/bansh2ebreak/springvulnboot-backend/blob/main/src/main/java/icu/secnotes/controller/LoginController.java"
    click S1 "https://github.com/bansh2ebreak/springvulnboot-backend/tree/main/src/main/java/icu/secnotes/service/"
    click S2 "https://github.com/bansh2ebreak/springvulnboot-backend/tree/main/src/main/java/icu/secnotes/service/impl/"
    click M "https://github.com/bansh2ebreak/springvulnboot-backend/tree/main/src/main/java/icu/secnotes/mapper/"
    click CFG "https://github.com/bansh2ebreak/springvulnboot-backend/tree/main/src/main/java/icu/secnotes/config/"
    click AC "https://github.com/bansh2ebreak/springvulnboot-backend/blob/main/src/main/resources/application.yml"
    click U "https://github.com/bansh2ebreak/springvulnboot-backend/tree/main/src/main/java/icu/secnotes/utils/"
    click EXH "https://github.com/bansh2ebreak/springvulnboot-backend/blob/main/src/main/java/icu/secnotes/exception/GlobalExceptionHandler.java"
    click LI "https://github.com/bansh2ebreak/springvulnboot-backend/blob/main/src/main/java/icu/secnotes/interceptor/LoginCheckInterceptor.java"
    click Mvn "https://github.com/bansh2ebreak/springvulnboot-backend/blob/main/pom.xml"
    click D "https://github.com/bansh2ebreak/springvulnboot-backend/blob/main/db.sql"

    %% Styles
    classDef frontend fill:#FFD700,stroke:#DAA520,stroke-width:2px;
    classDef entryPoint fill:#87CEEB,stroke:#4682B4,stroke-width:2px;
    classDef controller fill:#E6E6FA,stroke:#8A2BE2,stroke-width:2px;
    classDef service fill:#98FB98,stroke:#2E8B57,stroke-width:2px;
    classDef dao fill:#FFE4B5,stroke:#FFA500,stroke-width:2px;
    classDef config fill:#ADD8E6,stroke:#00008B,stroke-width:2px;
    classDef utility fill:#F0E68C,stroke:#BDB76B,stroke-width:2px;
    classDef exception fill:#FFC0CB,stroke:#FF69B4,stroke-width:2px;
    classDef database fill:#DDA0DD,stroke:#9400D3,stroke-width:2px;
    classDef maven fill:#F5DEB3,stroke:#DEB887,stroke-width:2px;
```
