# zetaaztra/vivek-s-gaming-application architecture

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

- Interactive diagram: https://gitdiagram.com/zetaaztra/vivek-s-gaming-application
- Repository: https://github.com/zetaaztra/vivek-s-gaming-application

## Overview

##### Main Project Components
- Client / Browser: Represents the user’s interface, which renders HTML, CSS, JavaScript provided by Thymeleaf templates and static resources.
- Web Application (Backend Server): A Spring Boot application that combines several modules:
- Controllers: Handling HTTP requests (e.g., BoardGameController, HomeController).
- Beans/Domain Model: Represents core entities such as BoardGame, Review, ErrorMessage.
- Database Layer: Contains the DatabaseAccess class which uses JDBC to interact with a database (initially H2, as seen with schema.sql).
- Security: Incorporates Spring Security configuration (SecurityConfig, LoggingAccessDeniedHandler) for managing authentication and authorization based on roles (non-members, users, managers).
- View Layer: Comprised of Thymeleaf templates (including fragments for reuse), static assets (CSS, JS, images) and secured-specific templates.
- Testing: Unit tests (JUnit) present under the src/test directory.
- CI/CD and DevOps Artifacts: Directories and files related to GitHub Actions workflows (.github/workflows), Jenkins configurations, Dockerfile, and additional resources for Sonarqube, Nexus, etc.
- Build and Dependency Management: Maven (pom.xml, mvnw) managing project dependencies and build lifecycle.

##### Relationships and Interactions
- Client-Server Interaction: The client (browser) initiates HTTP requests and receives HTML responses processed by Thymeleaf from the Spring Boot application.
- MVC Flow: Controllers receive requests and interact with the underlying DatabaseAccess layer to perform CRUD operations. They then pass data to Thymeleaf templates for rendering views.
- Security Layer: All incoming requests are intercepted by Spring Security, verifying user credentials and roles before allowing access to certain controllers or endpoints.
- DevOps/CI/CD Pipeline: The presence of CI/CD configuration files (GitHub Actions, Jenkins, Dockerfile) suggests that code is continuously integrated, tested, and deployed (e.g., on AWS EC2).

##### Architectural Patterns & Design Principles
- Layered Architecture / MVC Pattern: Clear separation between presentation (views/templates), business logic (controllers/beans), and data access (database package).
- Security Integration: Use of Spring Security for authentication/authorization, ensuring role-based access.
- Reusability: Use of Thymeleaf fragments which reduces redundancy across pages.
- CI/CD & DevOps: Integration with tools like Jenkins, Sonarqube, Nexus, and containerization via Docker.
- Testing: Inclusion of a comprehensive suite of JUnit tests for maintaining code quality.

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Client / Browser
    subgraph "Client / Browser"
        C1["Static Assets"]:::client
        C2["Thymeleaf Templates"]:::client
    end

    %% Spring Boot Application
    subgraph "Spring Boot Application"
        
        %% Controllers
        subgraph "Controllers"
            S1["BoardGameController"]:::controller
            S2["HomeController"]:::controller
        end

        %% Domain/Beans
        subgraph "Domain/Beans"
            DB1["BoardGame, Review, ErrorMessage"]:::beans
        end

        %% Database Access Layer
        subgraph "Database Access Layer"
            D1["DatabaseAccess"]:::database
            D2["Schema Initialization"]:::database
        end

        %% Security Module
        subgraph "Security Module"
            Sec1["SecurityConfig"]:::security
            Sec2["LoggingAccessDeniedHandler"]:::security
        end

        %% Thymeleaf Template Engine
        subgraph "Thymeleaf Engine"
            T1["Templates & Fragments"]:::thymeleaf
            T2["Secured Templates"]:::thymeleaf
        end
    end

    %% H2 Database
    DB["H2 Database"]:::database

    %% Testing
    Test["JUnit Tests"]:::testing

    %% Build and Dependency Management
    Build["Maven Build"]:::build

    %% CI/CD & DevOps
    subgraph "CI/CD & DevOps"
        CD1["GitHub Actions"]:::cicd
        CD2["Jenkins Config"]:::cicd
        CD3["Dockerfile"]:::cicd
        CD4["EC2 Config"]:::cicd
        CD5["Nexus"]:::cicd
        CD6["Sonarqube"]:::cicd
        CD7["CICD Docs"]:::cicd
    end

    %% Deployment Environment
    AWS["AWS EC2"]:::deployment

    %% Connections
    %% Client to Security Module (Authentication request)
    C2 -->|"AuthRequest"| Sec1

    %% Security Module forwards to Controllers
    Sec1 -->|"Forward"| S1
    Sec1 -->|"Forward"| S2

    %% Controllers interact with Domain/Beans
    S1 ---|"ModelBinding"| DB1
    S2 ---|"ModelBinding"| DB1

    %% Controllers call Database Access Layer
    S1 -->|"CRUD"| D1
    S2 -->|"CRUD"| D1

    %% Database Access Layer interacts with Database
    D1 -->|"Query/Update"| DB
    D2 -->|"Initialize"| DB

    %% Thymeleaf Engine renders views to client
    T1 -->|"RenderHTML"| C2
    T2 -->|"RenderSecuredViews"| C2

    %% Build triggers CI/CD Pipeline
    Build -->|"BuildTrigger"| CD1

    %% CI/CD Pipeline deploys to AWS EC2
    CD1 -->|"Deploy"| AWS
    CD2 -->|"Deploy"| AWS
    CD3 -->|"Deploy"| AWS
    CD4 -->|"Deploy"| AWS
    CD5 -->|"Deploy"| AWS
    CD6 -->|"Deploy"| AWS
    CD7 -->|"Deploy"| AWS

    %% Testing feedback to Build
    Test -->|"TestFeedback"| Build

    %% Click Events
    click C1 "https://github.com/zetaaztra/vivek-s-gaming-application/tree/main/src/main/resources/static"
    click C2 "https://github.com/zetaaztra/vivek-s-gaming-application/tree/main/src/main/resources/templates"
    click S1 "https://github.com/zetaaztra/vivek-s-gaming-application/blob/main/src/main/java/com/javaproject/controllers/BoardGameController.java"
    click S2 "https://github.com/zetaaztra/vivek-s-gaming-application/blob/main/src/main/java/com/javaproject/controllers/HomeController.java"
    click DB1 "https://github.com/zetaaztra/vivek-s-gaming-application/tree/main/src/main/java/com/javaproject/beans"
    click D1 "https://github.com/zetaaztra/vivek-s-gaming-application/blob/main/src/main/java/com/javaproject/database/DatabaseAccess.java"
    click D2 "https://github.com/zetaaztra/vivek-s-gaming-application/blob/main/src/main/resources/schema.sql"
    click Sec1 "https://github.com/zetaaztra/vivek-s-gaming-application/blob/main/src/main/java/com/javaproject/security/SecurityConfig.java"
    click Sec2 "https://github.com/zetaaztra/vivek-s-gaming-application/blob/main/src/main/java/com/javaproject/security/LoggingAccessDeniedHandler.java"
    click T1 "https://github.com/zetaaztra/vivek-s-gaming-application/tree/main/src/main/resources/templates"
    click T2 "https://github.com/zetaaztra/vivek-s-gaming-application/tree/main/src/main/resources/templates/secured"
    click Test "https://github.com/zetaaztra/vivek-s-gaming-application/tree/main/src/test"
    click CD1 "https://github.com/zetaaztra/vivek-s-gaming-application/tree/main/.github/workflows"
    click CD2 "https://github.com/zetaaztra/vivek-s-gaming-application/tree/main/jenkinsfile_updated"
    click CD3 "https://github.com/zetaaztra/vivek-s-gaming-application/tree/main/Dockerfile"
    click CD4 "https://github.com/zetaaztra/vivek-s-gaming-application/blob/main/EC2_Instance_Creation.md"
    click CD5 "https://github.com/zetaaztra/vivek-s-gaming-application/blob/main/Nexus.md"
    click CD6 "https://github.com/zetaaztra/vivek-s-gaming-application/blob/main/Sonarqube.md"
    click CD7 "https://github.com/zetaaztra/vivek-s-gaming-application/blob/main/CICD_Updated.md"
    click Build "https://github.com/zetaaztra/vivek-s-gaming-application/blob/main/pom.xml"

    %% Styles
    classDef client fill:#f9c74f,stroke:#000,stroke-width:2px;
    classDef controller fill:#f9844a,stroke:#000,stroke-width:2px;
    classDef beans fill:#577590,stroke:#fff,stroke-width:2px;
    classDef database fill:#ff595e,stroke:#000,stroke-width:2px;
    classDef security fill:#f94144,stroke:#000,stroke-width:2px;
    classDef thymeleaf fill:#6a4c93,stroke:#000,stroke-width:2px;
    classDef cicd fill:#8ac926,stroke:#000,stroke-width:2px;
    classDef testing fill:#ffca3a,stroke:#000,stroke-width:2px;
    classDef build fill:#1982c4,stroke:#000,stroke-width:2px;
    classDef deployment fill:#9d4edd,stroke:#000,stroke-width:2px;
```
