A scalable, domain-driven social platform built with Java Spring Boot.
Social Network Z is a backend system designed to solve the architectural challenges of scaling a complex domain.
Instead of a traditional Monolith where data is tightly coupled via database joins, this system follows Strict Modular Boundaries. It implements Domain-Driven Design (DDD) principles to ensure that modules like User, Content, and Engagement are loosely coupled, highly cohesive, and ready to be extracted into Microservices if needed.
The application is structured as a Modular Monolith.
- Vertical Slicing: Code is organized by Feature/Domain (
modules.user,modules.content), not by Technical Layer (controllers,services). - Strict Boundaries: No
@OneToManyor@ManyToOnerelationships across module lines. Cross-module data access is handled via Public APIs and DTOs. - Event-Driven: Uses Spring Events for side effects (e.g., User Deletion cleanup) to ensure eventual consistency without tight coupling.
- Assembler Pattern: Solves the "N+1 Problem" manually by fetching related entities in bulk and stitching them in memory, avoiding cross-module SQL JOINs.
- Rich Domain Models: Business logic lives in Entities (Aggregates).
- Strategy Pattern: Used for flexible authentication flows.
- Responsibility: Identity Management, Token Generation.
- Tech: Spring Security 6, JWT (RS256).
- Highlights: Custom
ArgumentResolversfor injection-safe user context (@CurrentUserId).
- Responsibility: User Profiles, Roles, Permissions.
- Communication: Exposes a
UserAPIinterface for other modules to validate user existence or fetch profile summaries in bulk.
- Responsibility: Posts, Comments.
- DDD Structure:
Postis the Aggregate Root.Commentis an entity within the Post aggregate. - Constraints: High integrity (Cascading deletes managed internally).
- Responsibility: Upvotes, Downvotes.
- Design Choice: Separated from Content to handle high-write volume.
- Responsibility: Follower/Following Graph.
- Core: Java 21, Spring Boot 3.2
- Database: MySQL
- Security: Spring Security, OAuth2 Resource Server
- Persistence: Spring Data JPA (Hibernate)