# santosh4568/quizzmaker architecture

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

- Interactive diagram: https://gitdiagram.com/santosh4568/quizzmaker
- Repository: https://github.com/santosh4568/quizzmaker

## Overview

##### Project type and purpose
- This is a full-stack web application (“Quiz Maker”) combining:
- A Java/Spring Boot backend with Thymeleaf server-rendered views and REST endpoints
- A modern React/Vite frontend in the `frontend/` directory
- A relational database (configured via `application.properties`) for persisting users, questions, and results
- Purpose: Allow authenticated users (role-based) to create quizzes, take them, and view history.

##### File structure
- Top-level:
- `pom.xml`, Maven wrapper (`mvnw`): backend build & dependency management
- `frontend/`: React application (Vite, Node)
- `src/main/java/com/quizz/QuizzMaker/`: Spring Boot application code
- `src/main/resources/templates` + `static`: Thymeleaf HTML/CSS
- `src/main/java/.../Controller`, `Service`, `Model`, `Repository`: standard layered MVC
- Patterns and conventions:
- Layered architecture (Controller → Service → Repository → DB)
- MVC for server-side pages (Thymeleaf)
- REST API layer for React frontend (`MyController.java` likely exposes JSON endpoints)

##### Key insights from README
- Modules: Controller, Service, Model, Templates, Static resources
- Features: Authentication & RBAC, quiz creation/participation/history, responsive UI
- Tech stack: Java 11+, Spring Boot, Thymeleaf, React, Vite, Maven, Node/NPM

##### Main components
a. Client tier
- React/Vite SPA (frontend/)
- Browser consuming server-rendered Thymeleaf pages (optional path)
b. API & Web tier
- Spring Boot application (`Application.java`)
- Controllers (`MyController.java`, `Error.java`) exposing JSON & HTML views
- WebConfig for CORS/URL mappings
c. Service layer
- UserService, QuestionService, ResultService (business logic)
d. Data access layer
- Spring Data Repositories (UserRepo, QuestionRepo, ResultRepo)
- JPA Entities (User, Question, Result)
e. Database
- External RDBMS (configured via `application.properties`)
f. Static assets
- CSS/JS under `src/main/resources/static`
g. Build & deployment tools
- Maven (backend), Node/NPM & Vite (frontend)

##### Relationships & interactions
- React SPA → HTTP/HTTPS → Spring Boot REST endpoints → Service layer → Repository → Database
- Browser → Spring Boot MVC controllers → Thymeleaf templates → HTML/CSS → Browser
- All Controllers delegate authentication/authorization to Spring Security (implied by RBAC)
- Build pipelines:
- `mvn clean install` produces jar
- `npm run build` (in frontend) produces static bundle, which can be served from Spring Boot or CDN

##### Architectural patterns & principles
- Layered Architecture (Presentation → Business → Data)
- MVC for server-rendered views
- Client-Server separation: SPA vs REST API
- Dependency Injection (Spring IoC)
- Repository pattern (Spring Data JPA)

##### Essential elements to capture
- All Controllers (entry points)
- Service classes (business rules)
- Repositories & Entities (data model)
- Frontend (React) vs Thymeleaf templates
- External database
- Build & deployment steps

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Tier
    subgraph "Client Tier"
        direction TB
        React["React/Vite SPA"]:::client
        Browser["Browser (Thymeleaf UI)"]:::client
    end

    %% Web/API Tier
    subgraph "Web/API Tier"
        direction TB
        Application["Spring Boot Application"]:::backend
        WebConfig["WebConfig (CORS & URL mappings)"]:::backend
        MyController["MyController (REST & MVC)"]:::backend
        ErrorHandler["Error Handler"]:::backend
        Templates["Thymeleaf Templates"]:::static
        StaticAssets["Static Assets (CSS/JS)"]:::static
    end

    %% Business Logic
    subgraph "Business Logic"
        direction TB
        UserService["UserService"]:::backend
        QuestionService["QuestionService"]:::backend
        ResultService["ResultService"]:::backend
    end

    %% Persistence Layer
    subgraph "Persistence Layer"
        direction TB
        UserRepo["UserRepo"]:::backend
        QuestionRepo["QuestionRepo"]:::backend
        ResultRepo["ResultRepo"]:::backend
        subgraph "JPA Entities"
            direction TB
            UserEntity["User Entity"]:::backend
            QuestionEntity["Question Entity"]:::backend
            ResultEntity["Result Entity"]:::backend
        end
        Database["Relational Database"]:::database
    end

    %% Build & Deployment Tools
    subgraph "Build & Deployment"
        direction TB
        Maven["Maven (pom.xml, mvnw)"]:::tool
        NPM["Node/NPM & Vite"]:::tool
    end

    %% Connections
    React -->|"HTTP/JSON"| MyController
    Browser -->|"HTTP/HTML"| MyController
    MyController -->|"renders"| Templates
    MyController -->|"serves"| StaticAssets
    Templates -->|HTML/CSS| Browser
    StaticAssets -->|CSS/JS| Browser

    Application -->|uses| WebConfig
    MyController -->|"delegates"| UserService
    MyController -->|"delegates"| QuestionService
    MyController -->|"delegates"| ResultService

    UserService -->|"calls"| UserRepo
    QuestionService -->|"calls"| QuestionRepo
    ResultService -->|"calls"| ResultRepo

    UserRepo -->|"maps"| UserEntity
    QuestionRepo -->|"maps"| QuestionEntity
    ResultRepo -->|"maps"| ResultEntity

    UserRepo -->|"JDBC"| Database
    QuestionRepo -->|"JDBC"| Database
    ResultRepo -->|"JDBC"| Database

    Maven -->|builds| Application
    NPM -->|builds| React

    %% Click Events
    click React "https://github.com/santosh4568/quizzmaker/tree/main/frontend/"
    click Application "https://github.com/santosh4568/quizzmaker/blob/main/src/main/java/com/quizz/QuizzMaker/Application.java"
    click WebConfig "https://github.com/santosh4568/quizzmaker/blob/main/src/main/java/com/quizz/QuizzMaker/Config/WebConfig.java"
    click MyController "https://github.com/santosh4568/quizzmaker/blob/main/src/main/java/com/quizz/QuizzMaker/Controller/MyController.java"
    click ErrorHandler "https://github.com/santosh4568/quizzmaker/blob/main/src/main/java/com/quizz/QuizzMaker/Controller/Error.java"
    click UserService "https://github.com/santosh4568/quizzmaker/blob/main/src/main/java/com/quizz/QuizzMaker/Service/UserService.java"
    click QuestionService "https://github.com/santosh4568/quizzmaker/blob/main/src/main/java/com/quizz/QuizzMaker/Service/QuestionService.java"
    click ResultService "https://github.com/santosh4568/quizzmaker/blob/main/src/main/java/com/quizz/QuizzMaker/Service/ResultService.java"
    click UserRepo "https://github.com/santosh4568/quizzmaker/blob/main/src/main/java/com/quizz/QuizzMaker/Repository/UserRepo.java"
    click QuestionRepo "https://github.com/santosh4568/quizzmaker/blob/main/src/main/java/com/quizz/QuizzMaker/Repository/QuestionRepo.java"
    click ResultRepo "https://github.com/santosh4568/quizzmaker/blob/main/src/main/java/com/quizz/QuizzMaker/Repository/ResultRepo.java"
    click UserEntity "https://github.com/santosh4568/quizzmaker/blob/main/src/main/java/com/quizz/QuizzMaker/Model/User.java"
    click QuestionEntity "https://github.com/santosh4568/quizzmaker/blob/main/src/main/java/com/quizz/QuizzMaker/Model/Question.java"
    click ResultEntity "https://github.com/santosh4568/quizzmaker/blob/main/src/main/java/com/quizz/QuizzMaker/Model/Result.java"
    click Templates "https://github.com/santosh4568/quizzmaker/tree/main/src/main/resources/templates/"
    click StaticAssets "https://github.com/santosh4568/quizzmaker/tree/main/src/main/resources/static/"
    click Maven "https://github.com/santosh4568/quizzmaker/blob/main/pom.xml"
    click Maven "https://github.com/santosh4568/quizzmaker/tree/main/mvnw"
    click NPM "https://github.com/santosh4568/quizzmaker/blob/main/frontend/package.json"
    click NPM "https://github.com/santosh4568/quizzmaker/blob/main/frontend/vite.config.js"

    %% Styles
    classDef client fill:#cfe2f3,stroke:#036; 
    classDef backend fill:#d9ead3,stroke:#070;
    classDef database fill:#f9cb9c,stroke:#a85;
    classDef static fill:#eeeeee,stroke:#888;
    classDef tool fill:#dddddd,stroke:#666;
```
