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.
- 1. Executive Summary
- 2. System Architecture
- 3. Repository Deep Dives
- 4. Data Engineering & Domain Mapping
- 5. Infrastructure & Security
- 6. Detailed Setup & Installation
- 7. Advanced Implementation Details
- 8. Authors & Contributors
- 9. License
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.
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
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.
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.
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), andsubmission_date(date) on the association itself. - Bidirectional JPA Mapping: Maps associations securely using Hibernate's
@ManyToOnebindings back toArticleandAuthorto 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)
);- 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(Port5050): For active local developer iteration.postgres_project_test_db(Port5052): For continuous integration testing.
Spin up PostgreSQL databases in the background:
cd spring-backend-main
docker-compose up -dBuild 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
- Admin Access:
Install dependencies and run the local development server:
cd ../Client-main/Client
npm install
npm startThe client app compiles and opens on http://localhost:9000, automatically pointing to the Spring REST API backend.
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 clean401 Unauthorizedand403 ForbiddenJSON 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");
}
})
);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);
}- Hasham Abdullah - Full-Stack Developer
This project is licensed under the MIT License - see individual license headers for details.