Architecture Overview
This project is a Monolithic MVC Full-Stack Application mimicking core Q&A forums, built natively on Java Spring Boot 3.
- Backend & Security: Spring Boot orchestrates the business logic, data persistence, and security. Instead of a decoupled SPA, it uses Server-Side Rendering (SSR) via Thymeleaf combined with Bootstrap 5 for responsive UI components. This pragmatic decision consolidated the application into a pure monolithic MVC pattern, simplifying session management and circumventing CORS complexity.
- Data Layer: Interacts with a PostgreSQL database via Spring Data JPA/Hibernate. The relational models are highly structured, keeping user mappings strictly bounded to questions, answers, and voting mechanisms.
- Asset Storage: Media uploads (e.g., screenshots attached to questions) are offloaded externally to Cloudinary using their Java SDK, ensuring the local server or database is completely free of binary bloat.
Engineering Challenges Solved
Ensuring Vote Integrity
Simple integer counters for upvotes/downvotes are susceptible to spam or multiple votes by the same user. To combat this, I designed dedicated junction tables (AnswerUpvoteEntity and AnswerDownvoteEntity) to track exact relational mappings between an Answer and a User. The toggleUpvote logic checks the database for an existing vote by the authenticated user; if found, it deletes it; if not, it registers it. This creates a perfect, race-condition-resistant toggle effect.
Orphaned Cloud Media Management
Storing images externally on Cloudinary can lead to cloud storage bloat if a user deletes a question or updates it with a new image, leaving the old image orphaned. The QuestionServiceImpl explicitly tracks both imageUrl and imagePublicId in PostgreSQL. When a question is updated or deleted, the service makes an explicit API call using the imagePublicId to safely destroy the remote asset, keeping the cloud environment highly sanitized.
Pragmatic Dev Environment (Email Simulation)
Implementing an account activation flow (with activation tokens) is difficult during local development due to SMTP configuration bottlenecks. The EmailServiceImpl was engineered to build the actual activation URL and format the email, but explicitly bypasses the JavaMailSender in the local environment, dumping the activation link directly into the terminal console instead. This allowed the full authentication flow to be built without external friction.
Outcomes
The codebase highlights a pragmatic approach to Java enterprise architecture. By leaning into Server-Side Rendering (SSR) and abandoning RESTful decoupled APIs for this specific use-case, the system achieved significantly faster time-to-delivery while retaining strict, enterprise-grade Spring Security and robust relational integrity.