# nm-2000/quiz-application architecture

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

- Interactive diagram: https://gitdiagram.com/nm-2000/quiz-application
- Repository: https://github.com/nm-2000/quiz-application

## Overview

##### Main Components
- Entry Point/Application: Represent the QuizApplication.java as the starting point for the application.
- Controllers: Highlight the QuestionController and QuizController as components that handle HTTP requests, acting as the web layer.
- Services: Include the QuestionService and QuizService which encapsulate business logic, bridging the controllers and data layers.
- Repositories: Show the QuestionRepository and QuizRepository as components interfacing directly with the PostgreSQL database.
- Entities: Represent the domain models like Question, Quiz, QuizResponse, and QuestionWrapper that define the data structure.
- Database: Clearly indicate the PostgreSQL database as the persistence store.

##### Relationships and Interactions
- From each controller, illustrate calls to the corresponding Service layer.
- From Services, show interactions with the Repository layer which performs CRUD operations on the data.
- Finally, connect the Repositories to the PostgreSQL database.

##### Architectural Patterns and Design Principles
- MVC (or layered) architecture pattern, where each layer has a distinct responsibility.
- Dependency Injection that Spring Boot uses to inject services into controllers and repositories into services.
- The separation of concerns improves maintainability and scalability.

##### Technologies and Frameworks
- Use of Spring Boot as the core framework driving the application.
- PostgreSQL as the database, mentioning that it is the underlying storage technology.
- That the application uses Maven for build management (as evidenced by pom.xml).

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client("Client/API Request"):::client
    QuizApp("QuizApplication (Entry Point)"):::entryPoint

    subgraph "Web Layer"
        QC("QuizController"):::controller
        QstC("QuestionController"):::controller
    end

    subgraph "Service Layer"
        QS("QuizService"):::service
        QstS("QuestionService"):::service
    end

    subgraph "Data Layer"
        subgraph "Repositories"
            QR("QuizRepository"):::repository
            QstR("QuestionRepository"):::repository
        end
        subgraph "Entities"
            Quiz("Quiz"):::entity
            QResp("QuizResponse"):::entity
            Question("Question"):::entity
            QWrapper("QuestionWrapper"):::entity
        end
    end

    DB("PostgreSQL Database"):::database
    Config("application.properties"):::config

    Client -->|"request"| QC
    Client -->|"request"| QstC

    QuizApp -->|"bootstraps"| QC
    QuizApp -->|"bootstraps"| QstC
    QuizApp -->|"bootstraps"| QS
    QuizApp -->|"bootstraps"| QstS

    QC -->|"calls"| QS
    QstC -->|"calls"| QstS

    QS -->|"calls"| QR
    QstS -->|"calls"| QstR

    QR -->|"maps_to"| Quiz
    QR -->|"maps_to"| QResp
    QstR -->|"maps_to"| Question
    QstR -->|"maps_to"| QWrapper

    QR -->|"CRUD"| DB
    QstR -->|"CRUD"| DB

    Config -.->|"configures"| DB

    classDef client fill:#f9c,stroke:#333,stroke-width:2px;
    classDef entryPoint fill:#ff9,stroke:#333,stroke-width:2px;
    classDef controller fill:#ccf,stroke:#0a0,stroke-width:2px;
    classDef service fill:#cfc,stroke:#0aa,stroke-width:2px;
    classDef repository fill:#fcf,stroke:#a0a,stroke-width:2px;
    classDef entity fill:#eef,stroke:#008,stroke-width:2px;
    classDef database fill:#ffcccc,stroke:#900,stroke-width:2px;
    classDef config fill:#ddd,stroke:#555,stroke-width:2px;

    click QuizApp "https://github.com/nm-2000/quiz-application/blob/main/src/main/java/com/github/quiz/application/QuizApplication.java"
    click QC "https://github.com/nm-2000/quiz-application/blob/main/src/main/java/com/github/quiz/application/controller/QuizController.java"
    click QstC "https://github.com/nm-2000/quiz-application/blob/main/src/main/java/com/github/quiz/application/controller/QuestionController.java"
    click QS "https://github.com/nm-2000/quiz-application/blob/main/src/main/java/com/github/quiz/application/service/QuizService.java"
    click QstS "https://github.com/nm-2000/quiz-application/blob/main/src/main/java/com/github/quiz/application/service/QuestionService.java"
    click QR "https://github.com/nm-2000/quiz-application/blob/main/src/main/java/com/github/quiz/application/repository/QuizRepository.java"
    click QstR "https://github.com/nm-2000/quiz-application/blob/main/src/main/java/com/github/quiz/application/repository/QuestionRepository.java"
    click Quiz "https://github.com/nm-2000/quiz-application/blob/main/src/main/java/com/github/quiz/application/entity/Quiz.java"
    click QResp "https://github.com/nm-2000/quiz-application/blob/main/src/main/java/com/github/quiz/application/entity/QuizResponse.java"
    click Question "https://github.com/nm-2000/quiz-application/blob/main/src/main/java/com/github/quiz/application/entity/Question.java"
    click QWrapper "https://github.com/nm-2000/quiz-application/blob/main/src/main/java/com/github/quiz/application/entity/QuestionWrapper.java"
    click Config "https://github.com/nm-2000/quiz-application/blob/main/src/main/resources/application.properties"
```
