# 23jz0104/thread-app architecture

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

- Interactive diagram: https://gitdiagram.com/23jz0104/thread-app
- Repository: https://github.com/23jz0104/thread-app

## Overview

##### Main Components
- Presentation (Frontend) Layer: This is implemented with HTML, CSS, and JSP files found under src/main/webapp. The JSP pages (e.g., home.jsp, userLogin.jsp, postCreate.jsp, etc.) serve as the view.
- Controller Layer: The Servlets (located in src/main/java/servlet) are your entry points. They handle incoming HTTP requests, manage session-based tasks (login, logout, user updates), and delegate processing.
- Business/Logic Layer: The core application logic is encapsulated in Logic.java (in src/main/java/logic), which processes requests and implements business rules.
- Data Access Layer: The DAO classes (src/main/java/dao with PostDAO.java, UserDAO.java, DBManager.java) manage connections to the database and execute queries. The DTO objects (found in src/main/java/dto) serve as data carriers.
- Model Layer: Represents the domain entities such as Post and User (located in src/main/java/model).
- Database: MySQL is used as the backend database, interfaced via the mysql-connector library in WEB-INF/lib.

##### Relationships and Interactions
- Data Flow: Data retrieved from the database is packaged into DTOs or model objects and sent back through the logic and controller to populate JSP views.
- Support for session management (Login/Logout processes) at the controller layer.

##### Architectural Patterns and Technologies
- Layered Architecture: Separate components by their roles—Presentation (JSP/HTML/CSS), Controller (Servlets), Business Logic, and Data Access.
- Technologies: Highlight Java as the primary language, MySQL as the database, and that the project uses standard JSP for the front end. Also note the use of the Jakarta Servlet/JSTL libraries in WEB-INF/lib.

- Clear labels and component names.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        JSP["JSP Views"]:::presentation
        CSS["CSS Assets"]:::presentation
        JS["JS Assets"]:::presentation
        IMG["Image Assets"]:::presentation
    end

    %% Controller Layer
    subgraph "Controller Layer"
        CTRL["Servlet Controllers"]:::controller
    end

    %% Business/Logic Layer
    subgraph "Business/Logic Layer"
        LOGIC["Business Logic"]:::logic
    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        DAO["DAO Classes"]:::data
        DTO["DTO Classes"]:::data
    end

    %% Model Layer
    subgraph "Model Layer"
        MODEL["Domain Models"]:::model
    end

    %% Database Layer
    subgraph "Database Layer"
        DB["MySQL Database"]:::database
        LIB["External Libraries"]:::database
    end

    %% Request Flow
    JSP -->|"HTTP_Request"| CTRL
    CTRL -->|"Delegates_to"| LOGIC
    LOGIC -->|"Calls_DBManager"| DAO
    DAO -->|"Returns_Data"| DTO
    LOGIC -->|"Maps_DTO_to_Model"| MODEL
    DAO -->|"Uses_JDBCConnector"| LIB
    LIB -->|"Connects_To_DB"| DB

    %% Response Flow
    MODEL -->|"Response_Data"| CTRL
    CTRL -->|"Renders_View_with_Data"| JSP

    %% Click Events
    click JSP "https://github.com/23jz0104/thread-app/tree/main/src/main/webapp/WEB-INF/jsp"
    click CSS "https://github.com/23jz0104/thread-app/blob/main/src/main/webapp/css/style.css"
    click JS "https://github.com/23jz0104/thread-app/tree/main/src/main/webapp/js"
    click IMG "https://github.com/23jz0104/thread-app/tree/main/src/main/webapp/img"
    click CTRL "https://github.com/23jz0104/thread-app/tree/main/src/main/java/servlet"
    click LOGIC "https://github.com/23jz0104/thread-app/blob/main/src/main/java/logic/Logic.java"
    click DAO "https://github.com/23jz0104/thread-app/tree/main/src/main/java/dao"
    click DTO "https://github.com/23jz0104/thread-app/tree/main/src/main/java/dto"
    click MODEL "https://github.com/23jz0104/thread-app/tree/main/src/main/java/model"
    click LIB "https://github.com/23jz0104/thread-app/tree/main/src/main/webapp/WEB-INF/lib"

    %% Styles
    classDef presentation fill:#f9f,stroke:#333,stroke-width:2px;
    classDef controller fill:#ffce54,stroke:#333,stroke-width:2px;
    classDef logic fill:#ac92ec,stroke:#333,stroke-width:2px;
    classDef data fill:#4fc1e9,stroke:#333,stroke-width:2px;
    classDef model fill:#a0d468,stroke:#333,stroke-width:2px;
    classDef database fill:#e9573f,stroke:#333,stroke-width:2px;
```
