Skip to content

About

Digital publication & magazine portal. Built with Spring Boot 3.4.2, Java 21, and Webpack 5. Features role-based security filters (CORS/CSRF), MapStruct DTO compilation, and robust PostgreSQL data auditing. High-performance publishing engine for digital media.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

ArticleWorld: Digital Publication & Magazine Management Portal

License: MIT Java 21 Spring Boot Webpack Bootstrap 5 Docker

A professional-grade, multi-tier publishing ecosystem integrating a Spring Boot backend, a secure RESTful API layer, and an independent Webpack-bundled client application. This platform represents a solid full-stack engineering blueprint, demonstrating clean separation of concerns, MapStruct DTO mappings, and role-based security filters.


📑 Table of Contents


1. Executive Summary

The ArticleWorld platform is an enterprise publishing tool designed to manage articles, magazines, and authors. It demonstrates how to build and maintain domain integrity across decoupled applications by solving these engineering challenges:

  • Clean Architecture Boundaries: Separating server-side MVC operations from decoupled REST services utilizing a structured CORS environment.
  • Enhanced Mapping Patterns: Managing complex database relationships (many-to-many) with rich audit metadata using JPA entity mappings.
  • Context-Aware Security: Configuring Spring Security to handle both traditional session-based MVC UI workflows and stateless REST API requests in a single security context.
  • Frontend Optimization: Bundling dynamic frontend dependencies (Bootstrap 5, custom SCSS variables, search engines) using Webpack.

2. System Architecture

The platform utilizes a Hybrid Integration Architecture. The core backend functions as both a traditional Thymeleaf MVC server and a REST API host, while the standalone frontend operates as an independent SPA communicating via Fetch requests.

graph TD
    subgraph "Presentation Layer"
        UI[Webpack Web Client <br> Port 9000]
        MVC[Thymeleaf MVC Pages <br> Port 8080]
    end

    subgraph "Core Backend (Spring Boot 3.4.2)"
        BE[Spring Web MVC]
        Sec[Spring Security Filters]
        Mapper[MapStruct Compiler]
        Service[Transactional Services]
        Repo[Spring Data JPA]
    end

    subgraph "Database Tier (Docker)"
        DB_Dev[(PostgreSQL Dev <br> Port 5050)]
        DB_Test[(PostgreSQL Test <br> Port 5052)]
    end

    UI <-->|Fetch API Requests| Sec
    MVC <-->|Direct HTTP Actions| Sec
    Sec --> BE
    BE --> Mapper
    Mapper --> Service
    Service --> Repo
    Repo <--> DB_Dev
    Repo <--> DB_Test
Loading

3. Repository Deep Dives

3.1 ArticleWorld Backend (spring-backend-main)

The engine behind the persistence and business layer.

  • Architecture: Layered Controller-Service-Repository architecture with clear separation between MVC controllers (handling UI template binding) and REST API controllers (delivering JSON payloads).
  • Core Entities:
    • Article: Holds editorial metadata (title, word count, publication state).
    • Author: Captures writer demographic details.
    • Magazine: Represents individual publication issues with specified genres (Technology, Science, Literature, News).
  • Audit & Versioning: Tracks manuscript version numbers and finalization status within authorship records.

3.2 Standalone Web Client (Client-main)

A modern Javascript frontend client.

  • Tech Stack: Vanilla JS (ES6+), Webpack 5, Webpack Dev Server, Bootstrap 5, Sass.
  • Dynamic Search Integration: Employs clientside real-time querying filters to look up authors dynamically.
  • Validations: Employs client-side schema assertions to validate new entry forms before firing API POST requests.

4. Data Engineering & Domain Mapping

A key technical highlight is the many-to-many relationship mapping between Articles and Authors. Instead of using a simple join table, the system implements an intermediary AuthorshipRecord entity mapping to authorship_record in PostgreSQL:

  • Custom Audit Columns: Tracks version (integer), is_final_version (boolean), and submission_date (date) on the association itself.
  • Bidirectional JPA Mapping: Maps associations securely using Hibernate's @ManyToOne bindings back to Article and Author to prevent memory leaks and circular reference errors during JSON serialization.
CREATE TABLE authorship_record (
    article_id BIGINT REFERENCES article(id),
    author_id BIGINT REFERENCES author(id),
    version INT,
    is_final_version BOOLEAN,
    submission_date DATE,
    PRIMARY KEY (article_id, author_id)
);

5. Infrastructure & Security

  • Authentication System: Powered by Spring Security using BCryptPasswordEncoder for secure credentials verification.
  • Authorization Scopes: Access rules are separated by roles (ADMIN, USER):
    • Public visitors can search and view articles, authors, and magazines.
    • Authenticated users are granted full write permissions to add and edit articles/authors.
  • Environment Isolation: Configured with Docker Compose hosting two isolated PostgreSQL Alpine containers:
    • postgres_magazineManagement_db (Port 5050): For active local developer iteration.
    • postgres_project_test_db (Port 5052): For continuous integration testing.

6. Detailed Setup & Installation

Infrastructure Initialization

Spin up PostgreSQL databases in the background:

cd spring-backend-main
docker-compose up -d

Backend Bootstrapping

Build the Gradle application and run:

# On Windows
gradlew.bat bootRun

# On Linux/macOS
./gradlew bootRun
  • REST API Port: http://localhost:8080
  • Database Credentials (seeded via data.sql):
    • Admin Access: admin@example.com | password
    • Standard Access: user@example.com | password

Frontend Client Setup

Install dependencies and run the local development server:

cd ../Client-main/Client
npm install
npm start

The client app compiles and opens on http://localhost:9000, automatically pointing to the Spring REST API backend.


7. Advanced Implementation Details

Context-Aware Security Filter Chain

A key security design pattern is the integration of dual-purpose exceptions:

  • For web browsers browsing MVC pages, authentication failures trigger standard redirects to /login.
  • For Javascript-driven REST clients accessing /api/** resources, authentication failures yield clean 401 Unauthorized and 403 Forbidden JSON response headers, preventing redirect loops.
// Spring Security Exception Override Example
httpSecurity.exceptionHandling(handling ->
    handling.authenticationEntryPoint((request, response, authException) -> {
        if (request.getRequestURI().startsWith("/api")) {
            response.setStatus(HttpStatus.UNAUTHORIZED.value());
        } else {
            response.sendRedirect("/login");
        }
    })
);

MapStruct Compiler DTO Pattern

To prevent domain leakage and overhead, entities are converted to DTOs compile-time:

@Mapper(componentModel = "spring")
public interface ArticleMapper {
    ArticleDto toDto(Article article);
    Article toEntity(ArticleDto articleDto);
}

8. Authors & Contributors

  • Hasham Abdullah - Full-Stack Developer

9. License

This project is licensed under the MIT License - see individual license headers for details.

About

Digital publication & magazine portal. Built with Spring Boot 3.4.2, Java 21, and Webpack 5. Features role-based security filters (CORS/CSRF), MapStruct DTO compilation, and robust PostgreSQL data auditing. High-performance publishing engine for digital media.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages