# himikovalk/quizapp architecture

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

- Interactive diagram: https://gitdiagram.com/himikovalk/quizapp
- Repository: https://github.com/himikovalk/quizapp

## Overview

##### Main Components
- Client (quizClient):
– GUI Layer: Includes all classes under com.himiko.gui (screens, theme, manager) for user interaction (e.g., ConnectionScreen, GameSelectionScreen).
– Game Logic: Found in com.himiko.game, handling game state and elements (Question, QuestionCategory, GameState, etc.).
– Network Communication: Under com.himiko.network and its protocol packages. This handles sending requests, receiving responses, and wrapping network packets.
– Utility Classes: E.g., UserData and others, supporting business logic.
- Server (quizServer):
– Server Core: Main entry point and server initialization in com.himiko/server/Server.java.
– Game Management: Game coordination and state management under com.himiko/game and com.himiko/server/manager (e.g., SessionManager, GameManager).
– Network Protocol: Packages under com.himiko/server/protocol and related data, handling request-response, package handling (similar to the client but in a server context).
– Data and Configuration: Supporting files like questions.json, and configuration loaders (e.g., QuestionConfigLoader).
- Shared or Mirrored Components:
– Notice the similarity between client and server packages for game elements and network protocols. This may indicate a mirrored model where similar structures exist on both sides to ensure cohesive communication.

##### Relationships and Data Flows
- UI and Game Logic Interaction: On the client side, the GUI components trigger game events which are forwarded to the GameManager and then to NetworkWrapper for communication.
- Game Data Flow: Questions, scores, and user data flow from the server (likely loaded and maintained from the questions.json file) to client side screens, updating the game state in real time.

##### Architectural Patterns and Design Principles
- Layered Architecture: Clearly separate the UI, game logic, networking, and data management layers.
- Protocol-Oriented Communication: Highlight the use of Request/Response and Package handling to abstract network communication.
- Modular Design: Both client and server are divided into submodules (game, gui, network, server manager, etc.). Show these as subcomponents within each main block.

##### Relevant Technologies and Frameworks
- Java: The project is built in Java, as suggested by the .java files.
- Maven: pom.xml files exist in both client and server, indicating Maven for dependency management and project build.
- Logging: The presence of logs.txt and Logger.jar indicates usage of logging utilities.

##### Being Detailed
- Similarly, reflect the mirrored design of protocol classes in both client and server to illustrate consistency in communication.
- Even if some details seem redundant, including these layers helps underscore the project’s modular and maintainable design.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Quiz Client"
        Client_GUI["GUI Layer"]
        Client_GameLogic["Game Logic"]
        Client_Network["Network Communication"]
        Client_Utilities["Utilities"]
    end

    subgraph "Quiz Server"
        Server_Core["Server Core"]
        
        subgraph "Game Management"
            Session_Manager["Session Manager"]
            Game_Manager["Game Manager"]
        end
        
        Server_Network["Network Protocol"]
        
        subgraph "Data and Config"
            Questions["questions.json"]
            Config_Loader["QuestionConfigLoader"]
        end
    end

    %% Client internal flow
    Client_GUI -->|"triggers"| Client_GameLogic
    Client_GameLogic -->|"processes"| Client_Network
    Client_GameLogic -->|"uses"| Client_Utilities

    %% Client to Server Communication
    Client_Network -->|"Request/Response"| Server_Network

    %% Server internal flow
    Server_Core -->|"starts"| Session_Manager
    Server_Core -->|"starts"| Game_Manager
    Server_Core -->|"handles"| Server_Network

    Game_Manager -->|"loads"| Questions
    Game_Manager -->|"loads"| Config_Loader

    Server_Network -->|"routes"| Session_Manager
    Server_Network -->|"routes"| Game_Manager

    %% Server updates sent to Client
    Game_Manager -->|"Update"| Client_GUI

    %% Click Events
    click Client_GUI "https://github.com/himikovalk/quizapp/tree/master/quizClient/src/main/java/com/himiko/gui"
    click Client_GameLogic "https://github.com/himikovalk/quizapp/tree/master/quizClient/src/main/java/com/himiko/game"
    click Client_Network "https://github.com/himikovalk/quizapp/tree/master/quizClient/src/main/java/com/himiko/network"
    click Client_Utilities "https://github.com/himikovalk/quizapp/blob/master/quizClient/src/main/java/com/himiko/game/utils/UserData.java"
    click Server_Core "https://github.com/himikovalk/quizapp/blob/master/quizServer/src/main/java/com/himiko/server/Server.java"
    click Session_Manager "https://github.com/himikovalk/quizapp/tree/master/quizServer/src/main/java/com/himiko/server/manager"
    click Game_Manager "https://github.com/himikovalk/quizapp/blob/master/quizServer/src/main/java/com/himiko/game/GameManager.java"
    click Server_Network "https://github.com/himikovalk/quizapp/tree/master/quizServer/src/main/java/com/himiko/server/protocol"
    click Questions "https://github.com/himikovalk/quizapp/blob/master/quizServer/questions.json"
    click Config_Loader "https://github.com/himikovalk/quizapp/blob/master/quizServer/src/main/java/com/himiko/game/config/QuestionConfigLoader.java"

    %% Styles
    classDef client fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef server fill:#ffcccc,stroke:#333,stroke-width:2px;
    classDef network fill:#d1e7dd,stroke:#333,stroke-width:2px;

    class Client_GUI,Client_GameLogic,Client_Utilities client;
    class Client_Network network;
    class Server_Core,Session_Manager,Game_Manager,Questions,Config_Loader server;
    class Server_Network network;
```
