# binhnqhe172185/swp391_se1727net_practicequiz architecture

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

- Interactive diagram: https://gitdiagram.com/binhnqhe172185/swp391_se1727net_practicequiz
- Repository: https://github.com/binhnqhe172185/swp391_se1727net_practicequiz

## Overview

##### Project Type & Purpose
- The project is a web-based Quiz Practice application.
- It is built using Java with a mix of JSP for the view, Servlets as controllers, and a traditional Java model–view–controller (MVC) layered architecture.
- The README identifies it simply as “Quiz Practice,” and the extensive file structure confirms its use for administering quizzes, user registration, and both frontend (user-facing) and backend (admin and expert interfaces).

##### Analyzing the File Structure
- There are multiple directories and files:
– Directories like “src/java/Controller”, “src/java/DAO”, “src/java/Model”, and “src/java/Filter” clearly indicate the MVC pattern, with additional layers for data access.
– The “build/web” and “web” directories contain many JSP files (e.g. Login.jsp, Dashboard.jsp, QuizHandle.jsp) to render the UI.
– Assets and vendor directories under “build/web/FrontEnd” and “web/FrontEnd” show integration with front-end frameworks such as Bootstrap, along with themes and custom JavaScript (e.g. quizHandle.js) to enhance the UI.
– The presence of configuration files (web.xml, context.xml, MANIFEST.MF) as well as build scripts (build.xml) shows formal deployment processes.
- The controllers in the “src/java/Controller” directory handle various actions (e.g. LoginServlet, CreateQuiz, Admin* servlets) which interact with DAO and model classes.

a. Main Components:
– Client (Browser): End users interact through web browsers.
– Web Server (Servlet Container): Hosts JSP pages and Java Servlets.
– Controllers (Servlets): Manage requests (e.g., LoginServlet, QuizHandleServlet, Admin controllers).
– Business Logic Layer:
○ Model: Contains Java classes representing entities (Account, Quiz, Question, etc.).
○ Service/Controller layer: Processes business rules.
– Data Access Layer:
○ DAO: Responsible for interacting with the database.
○ DBContext (in DAL): Manages connections and queries.
– Database: Although not explicitly visible as a folder, the project is designed to interface with a relational database.
– Presentation Layer:
○ JSP Pages: These render the frontend views.
○ FrontEnd Assets: CSS, JavaScript, images, vendor libraries (Bootstrap, FontAwesome, etc.)
– Filters: For authentication, authorization, or request processing (e.g., MarketerFilter).

b. Relationships & Interactions:
– Users use a browser to send HTTP requests to the web server.
– Requests are routed (often via web.xml configuration) to appropriate Servlets (controllers).
– Controllers process the request by interacting with model objects and using the DAO layer to query or update the database.
– Responses are forwarded to JSP pages to render a dynamic user interface.
– Frontend assets (CSS/JS files) enhance the user experience and interact with the backend through AJAX where applicable.

c. Important Patterns and Design Principles:
– MVC (Model–View–Controller): Clear separation of concerns with Controller (Servlets), Model (Java classes), and View (JSP pages).
– Layered Architecture: Distinct layers for presentation, business logic, data access, and configuration.
– Use of Filters for pre-processing requests (e.g., authentication checks).
– The project has a modular structure where different functionalities (admin, expert, marketer, user) are separated into different controllers and views.

d. Relevant Technologies:
– Java Servlets and JSP as the core of the web application.
– Java-based data access (DAO pattern) with likely JDBC.
– Frontend frameworks/libraries: Bootstrap, various vendor CSS/JS libraries for UI components.
– Build and configuration tools: Ant (build.xml), NetBeans project files (.iml and nbproject).

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client["Client Browser"]:::client
    Client -->|"HTTP_Request/Response"| Server

    subgraph "Web Server / Servlet Container"
        direction TB
        %% Presentation Layer
        subgraph "Presentation Layer"
            JSP["JSP Views (Login.jsp, Dashboard.jsp, QuizHandle.jsp)"]:::presentation
            FE["FrontEnd Assets (CSS, JS, Images)"]:::presentation
        end

        %% Business Logic Layer
        subgraph "Business Logic Layer"
            SC["Servlet Controllers"]:::business
            RF["Request Filters"]:::business
            BM["Business Model"]:::business
        end

        %% Data Access Layer
        subgraph "Data Access Layer"
            DAO["DAO"]:::data
            DBCT["DB Connection (DBContext)"]:::data
        end

        AC["App Configuration (web.xml, context.xml)"]:::configuration
    end

    %% External Database
    Database["Database"]:::database

    %% Relationships inside Web Server
    SC -->|"invokes"| DAO
    SC -->|"renders"| JSP
    RF -->|"pre-processes"| SC
    DAO -->|"uses"| DBCT
    DBCT -->|"queries/updates"| Database
    FE -->|"enhances"| JSP

    %% Click Events
    click SC "https://github.com/binhnqhe172185/swp391_se1727net_practicequiz/tree/main/QuizThink/src/java/Controller"
    click DAO "https://github.com/binhnqhe172185/swp391_se1727net_practicequiz/tree/main/QuizThink/src/java/DAO"
    click BM "https://github.com/binhnqhe172185/swp391_se1727net_practicequiz/tree/main/QuizThink/src/java/Model"
    click DBCT "https://github.com/binhnqhe172185/swp391_se1727net_practicequiz/blob/main/QuizThink/src/java/DAL/DBContext.java"
    click RF "https://github.com/binhnqhe172185/swp391_se1727net_practicequiz/blob/main/QuizThink/src/java/Filter/MarketerFilter.java"
    click JSP "https://github.com/binhnqhe172185/swp391_se1727net_practicequiz/tree/main/QuizThink/build/web"
    click FE "https://github.com/binhnqhe172185/swp391_se1727net_practicequiz/tree/main/QuizThink/build/web/FrontEnd"
    click AC "https://github.com/binhnqhe172185/swp391_se1727net_practicequiz/blob/main/QuizThink/build/web/WEB-INF/web.xml"

    %% Styles
    classDef client fill:#ffcccc,stroke:#cc0000,stroke-width:2px;
    classDef presentation fill:#cce5ff,stroke:#004085,stroke-width:2px;
    classDef business fill:#d4edda,stroke:#155724,stroke-width:2px;
    classDef data fill:#fff3cd,stroke:#856404,stroke-width:2px;
    classDef configuration fill:#e2e3e5,stroke:#6c757d,stroke-width:2px;
    classDef database fill:#f8d7da,stroke:#721c24,stroke-width:2px;
```
