# williamniemiec/nforum-web architecture

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

- Interactive diagram: https://gitdiagram.com/williamniemiec/nforum-web
- Repository: https://github.com/williamniemiec/nforum-web

## Overview

##### Main Components

a) Client Layer:
- Web Browser
- JSP Views (located in /src/main/webapp/WEB-INF/views)
- Static Assets (CSS, JavaScript, Images in /src/main/webapp/assets)

b) Application Layer:
- Controllers Package (/controllers)
- Services Package (/services)
- DTOs Package (/dto)
- Repositories Package (/repositories)

c) Data Layer:
- PostgreSQL Database
- Database Configuration (/config)

##### Component Relationships

**[Client Browser] ←→ [JSP Views]**
- ↑↓
**[Controllers (Servlets)]**
- ↑↓
**[Services Layer]**
- ↑↓
**[DTOs] ←→ [Repositories]**
- ↑↓
**[Database Config]**
- ↑↓
**[PostgreSQL Database]**

##### Specific Implementation Details

- Rectangles: Core components (Controllers, Services, Repositories)
- Rounded rectangles: UI components
- Hexagons: DTOs and Config classes

##### Component Details

Controllers:
- AuthController
- HomeController
- TopicController
- RankingController
- SignInController
- SignUpController

Services:
- AuthService
- CommentService
- TopicService
- UserAccountService

Repositories:
- CommentRepository
- TopicRepository
- UserAccountRepository

Views:
- TopicsPage
- TopicPage
- SignInPage
- SignUpPage
- RankingPage

##### Additional Elements

Supporting components:
- ViewLoader (core package)
- Exception handling
- Database configuration variants (Local/Production)

##### Important Architectural Notes

- MVC pattern implementation
- Separation between presentation (JSP), business logic (Services), and data access (Repositories)
- Database schema connection as shown in the README
- Authentication flow separately
- Where Selenium tests interface with the system

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Style definitions
    classDef client fill:#3498db,stroke:#2980b9,color:white
    classDef service fill:#2ecc71,stroke:#27ae60,color:white
    classDef data fill:#f1c40f,stroke:#f39c12,color:black
    classDef config fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef error fill:#e74c3c,stroke:#c0392b,color:white

    %% Client Layer
    subgraph ClientLayer
        Browser["Web Browser"]:::client
        JSPViews["JSP Views"]:::client
        StaticAssets["Static Assets"]:::client
    end

    %% Controllers Layer
    subgraph ControllersLayer
        AuthC["AuthController"]:::service
        HomeC["HomeController"]:::service
        TopicC["TopicController"]:::service
        RankingC["RankingController"]:::service
        SignInC["SignInController"]:::service
        SignUpC["SignUpController"]:::service
    end

    %% Services Layer
    subgraph ServicesLayer
        AuthS["AuthService"]:::service
        CommentS["CommentService"]:::service
        TopicS["TopicService"]:::service
        UserS["UserAccountService"]:::service
    end

    %% DTOs Layer
    subgraph DTOsLayer
        CommentDTO[("CommentDTO")]:::data
        TopicDTO[("TopicDTO")]:::data
        UserDTO[("UserDTO")]:::data
    end

    %% Repositories Layer
    subgraph RepositoriesLayer
        CommentR["CommentRepository"]:::data
        TopicR["TopicRepository"]:::data
        UserR["UserAccountRepository"]:::data
    end

    %% Database Configuration
    subgraph ConfigLayer
        DbConfig["Database Config"]:::config
        LocalDb["Local Database"]:::config
        ProdDb["Production Database"]:::config
    end

    %% Core Components
    ViewLoader["ViewLoader"]:::service
    ExceptionHandler["Exception Handler"]:::error

    %% Database
    Database[(PostgreSQL)]:::data

    %% Relationships
    Browser <--> JSPViews
    Browser <--> StaticAssets
    JSPViews <--> ControllersLayer
    ControllersLayer <--> ServicesLayer
    ServicesLayer <--> DTOsLayer
    DTOsLayer <--> RepositoriesLayer
    RepositoriesLayer <--> ConfigLayer
    ConfigLayer <--> Database
    ViewLoader --> JSPViews
    ExceptionHandler --> ServicesLayer

    %% Click events
    click JSPViews "https://github.com/williamniemiec/nforum-web/tree/master/src/main/webapp/WEB-INF/views/"
    click StaticAssets "https://github.com/williamniemiec/nforum-web/tree/master/src/main/webapp/assets/"
    click AuthC "https://github.com/williamniemiec/nforum-web/blob/master/src/main/java/wniemiec/web/nforum/controllers/AuthController.java"
    click HomeC "https://github.com/williamniemiec/nforum-web/blob/master/src/main/java/wniemiec/web/nforum/controllers/HomeController.java"
    click TopicC "https://github.com/williamniemiec/nforum-web/blob/master/src/main/java/wniemiec/web/nforum/controllers/TopicController.java"
    click RankingC "https://github.com/williamniemiec/nforum-web/blob/master/src/main/java/wniemiec/web/nforum/controllers/RankingController.java"
    click SignInC "https://github.com/williamniemiec/nforum-web/blob/master/src/main/java/wniemiec/web/nforum/controllers/SignInController.java"
    click SignUpC "https://github.com/williamniemiec/nforum-web/blob/master/src/main/java/wniemiec/web/nforum/controllers/SignUpController.java"
    click AuthS "https://github.com/williamniemiec/nforum-web/blob/master/src/main/java/wniemiec/web/nforum/services/AuthService.java"
    click CommentS "https://github.com/williamniemiec/nforum-web/blob/master/src/main/java/wniemiec/web/nforum/services/CommentService.java"
    click TopicS "https://github.com/williamniemiec/nforum-web/blob/master/src/main/java/wniemiec/web/nforum/services/TopicService.java"
    click UserS "https://github.com/williamniemiec/nforum-web/blob/master/src/main/java/wniemiec/web/nforum/services/UserAccountService.java"
    click CommentDTO "https://github.com/williamniemiec/nforum-web/blob/master/src/main/java/wniemiec/web/nforum/dto/CommentDTO.java"
    click TopicDTO "https://github.com/williamniemiec/nforum-web/blob/master/src/main/java/wniemiec/web/nforum/dto/TopicDTO.java"
    click UserDTO "https://github.com/williamniemiec/nforum-web/blob/master/src/main/java/wniemiec/web/nforum/dto/UserDTO.java"
    click CommentR "https://github.com/williamniemiec/nforum-web/blob/master/src/main/java/wniemiec/web/nforum/repositories/CommentRepository.java"
    click TopicR "https://github.com/williamniemiec/nforum-web/blob/master/src/main/java/wniemiec/web/nforum/repositories/TopicRepository.java"
    click UserR "https://github.com/williamniemiec/nforum-web/blob/master/src/main/java/wniemiec/web/nforum/repositories/UserAccountRepository.java"
    click DbConfig "https://github.com/williamniemiec/nforum-web/blob/master/src/main/java/wniemiec/web/nforum/config/DatabaseConfig.java"
    click LocalDb "https://github.com/williamniemiec/nforum-web/blob/master/src/main/java/wniemiec/web/nforum/config/LocalDatabase.java"
    click ProdDb "https://github.com/williamniemiec/nforum-web/blob/master/src/main/java/wniemiec/web/nforum/config/ProductionDatabase.java"
    click ViewLoader "https://github.com/williamniemiec/nforum-web/blob/master/src/main/java/wniemiec/web/nforum/core/ViewLoader.java"
    click ExceptionHandler "https://github.com/williamniemiec/nforum-web/tree/master/src/main/java/wniemiec/web/nforum/services/exceptions/"
```
