How sudeshnapathak/blog_management_system works
1. Application type and runtime
- This is a Spring Boot backend built with Maven.
- The core runtime is a layered Java service exposing REST APIs for blog administration, content, and user management.
2. Primary request flow
- Requests enter through the controller layer under Controllers/.
- Controllers delegate to Service implementations, which coordinate business rules, persistence, security checks, and side effects.
- Responses are normalized through Advice/GlobalResponseHandler, while failures are mapped by Advice/GlobalExceptionHandler.
3. Domain boundaries
- The main domain entities are UserEntity, PostEntity, CategoryEntity, CommentEntity, LikeEntity, FollowEntity, and BookmarkEntity.
- DTOs are used extensively to separate API contracts from persistence models, covering authentication, posts, users, follows, likes, comments, and categories.
4. Persistence layer
- Repositories in Repositories/ provide data access for each major entity.
- The domain model is backed by database migrations in src/main/resources/db/migration, indicating schema management is handled explicitly rather than ad hoc.
- Specifications/PostFilterSpecification suggests dynamic query filtering for post search/listing.
5. Business services
- PostServiceImpl, UserServiceImpl, and CategoryServiceImpl hold the main domain logic.
- The Service/Interfaces/ package defines service boundaries, while implementation classes encapsulate orchestration and validation.
- RedisViewCountServiceImpl is a separate service, showing that view counting is treated as a distinct data path from standard relational persistence.
6. Security and authentication
- Authentication is JWT-based, with JWTService, JWTAuthFilter, and WebSecurityConfig forming the security boundary.
- AuthService handles login/signup/refresh token workflows exposed through AuthController.
- SecurityUtils and SecurityConfigUtils support request/user context handling, likely for current-user access in services and controllers.
7. Event-driven side effects
- The system publishes internal application events such as CommentAddedEvent, NewPostPublishedEvent, PostLikedEvent, and NewFollowerEvent.
- Listeners/EmailEventListeners consumes these events and triggers email-related side effects.
- This decouples core business actions from notification delivery, which is an important architectural boundary.
8. Email templating and notification delivery
- Email content is rendered from FreeMarker templates in src/main/resources/templates/.
- EmailTemplateServiceImpl and EmailServiceImpl form the email subsystem, with template models in TemplateModels/.
- This subsystem is fed by domain events rather than direct controller calls, so notifications are asynchronous by design.
9. Scheduled/background jobs
- Schedulers/ contains background processes for post publication, user batch processing, and Redis-to-database view synchronization.
- PostPublishScheduler likely handles scheduled publication of queued posts.
- ViewSyncScheduler is the bridge between fast in-memory view tracking and durable storage, showing a deliberate split between write-heavy metrics and relational data.
10. Cross-cutting concerns
- Logging is handled by both an AOP aspect (LoggingAspect) and an HTTP filter (RequestLoggingFilter).
- Input sanitization is reinforced by custom deserializers in Deserializers/, which is relevant for safe handling of HTML/string content in post/comment fields.
- AsyncConfig, MapperConfig, MessageSourceConfig, and SwaggerConfig are supporting configuration for async work, object mapping, i18n/messages, and API documentation.
11. API conventions and constants
- Constants/ApiRoutes.java centralizes endpoint paths, which helps keep controller mappings consistent.
- Other constants cover regex validation and Redis key naming, suggesting shared rules for routing, input validation, and cache structure.
12. Infrastructure and operational tooling
- docker-compose.yml, Dockerfile, and the elk-config/ directory show the project is packaged for containerized deployment with log shipping into an ELK stack via Filebeat/Logstash.
- logback-spring.xml supports structured application logging.
- Swagger screenshots in the README and SwaggerConfig indicate API documentation is first-class.
- src/test/ contains controller, service, repository, scheduler, listener, security, and utility tests, reflecting coverage across the whole architecture rather than only the API layer.
Main entry points: Controllers Controllers · PostServiceImpl.java Post Service · UserServiceImpl.java User Service · Repositories Repositories
Components 23
API Layer
HTTP entrypoints, response handling, and request logging
- Application · Main application bootstrap for the blog management system
src/main/java/com/project/Blog_Management_System/BlogManagementSystemApplication.java - Controllers · Admin, auth, post, category, and user HTTP controllers
src/main/java/com/project/Blog_Management_System/Controllers - Response Advice · Normalizes success responses and maps exceptions to API errors
src/main/java/com/project/Blog_Management_System/Advice - Request Logging · Cross-cutting request and execution logging
src/main/java/com/project/Blog_Management_System/Logging
Core Domain
Business services, entities, DTOs, and query logic
- Post Service · Core post creation, publishing, filtering, reactions, and comments
src/main/java/com/project/Blog_Management_System/Service/PostServiceImpl.java - User Service · User profile, follow, and account-related business rules
src/main/java/com/project/Blog_Management_System/Service/UserServiceImpl.java - Category Service · Category management and validation logic
src/main/java/com/project/Blog_Management_System/Service/CategoryServiceImpl.java - Service Contracts · Service boundaries for posts, users, categories, email, and view counts
src/main/java/com/project/Blog_Management_System/Service/Interfaces - View Counts · Fast view tracking separate from relational persistence
src/main/java/com/project/Blog_Management_System/Service/RedisViewCountServiceImpl.java - Post Filter · Dynamic filtering and search criteria for posts
src/main/java/com/project/Blog_Management_System/Specifications/PostFilterSpecification.java - Entities · User, post, category, comment, like, follow, and bookmark entities
src/main/java/com/project/Blog_Management_System/Entities - DTOs · Request and response models for auth, posts, users, follows, likes, comments, categories, and email
src/main/java/com/project/Blog_Management_System/Dto - Repositories · Persistence repositories for the major domain entities
src/main/java/com/project/Blog_Management_System/Repositories
Security
JWT authentication and request authorization
- Security Layer · Authentication, token handling, request filtering, and security configuration
src/main/java/com/project/Blog_Management_System/Security - Auth Service · Login, signup, and token refresh coordination
src/main/java/com/project/Blog_Management_System/Security/AuthService.java
Notifications
Events and email delivery
- Domain Events · Events for post publication, comments, likes, followers, and scheduled publication
src/main/java/com/project/Blog_Management_System/Events - Email Listeners · Consumes domain events and triggers notification side effects
src/main/java/com/project/Blog_Management_System/Listeners/EmailEventListeners.java - Email Service · Renders templates and sends notification emails
src/main/java/com/project/Blog_Management_System/Service - Email Templates · FreeMarker templates for notification emails
src/main/resources/templates
Operations
Scheduling, persistence migrations, and deployment support
- Schedulers · Scheduled publication, user batch processing, and view synchronization
src/main/java/com/project/Blog_Management_System/Schedulers - Migrations · Flyway migrations and initial data scripts
src/main/resources/db/migration - Config · Async, mapper, message source, and Swagger configuration
src/main/java/com/project/Blog_Management_System/Config - Deploy Assets · Docker packaging and ELK shipping configuration
docker-compose.yml
Connections 28
- Application → Controllers: hosts · Application exposes REST controllers
- Controllers → Response Advice: returns via · Controllers rely on shared response and error handling
- Controllers → Auth Service: auth calls · Auth endpoints delegate login and token workflows
- Controllers → Post Service: uses · Post endpoints delegate business operations
- Controllers → User Service: uses · User endpoints delegate account operations
- Controllers → Category Service: uses · Category endpoints delegate category operations
- Controllers → Request Logging: observed by · HTTP requests are logged through filters and aspects
- Post Service → Repositories: persists via · Post workflows read and write relational data
- User Service → Repositories: persists via · User workflows read and write relational data
- Category Service → Repositories: persists via · Category workflows read and write relational data
- Post Service → Post Filter: filters with · Post listing/search uses dynamic specifications
- Post Service → Entities: maps to · Services operate on persistent domain entities
- User Service → Entities: maps to · User and relation entities model the domain
- Category Service → Entities: maps to · Categories are represented as JPA entities
- Repositories → Migrations: backed by · Repository schema is created and evolved through Flyway migrations
- Auth Service → Security Layer: secured by · JWT filter and security config define the access boundary
- Security Layer → Controllers: protects · Security layer sits in front of API endpoints
- Post Service → Domain Events: publishes · Business actions emit domain events
- User Service → Domain Events: publishes · User actions emit follower-related events
- Domain Events → Email Listeners: consumed by · Listeners react to application events
- Email Listeners → Email Service: triggers · Email side effects are delegated to the email subsystem
- Email Service → Email Templates: renders · Notification content is produced from templates
- Email Listeners → Email Templates: uses models · Listeners pass template models into email rendering
- Schedulers → Domain Events: emits · Scheduled jobs can publish background events
- Schedulers → View Counts: syncs · View counts are synchronized from Redis to durable storage
- Config → Security Layer: configures · Configuration supports security and request processing
- Config → Email Service: configures · Configuration supports object mapping, async work, and messaging
- Deploy Assets → Request Logging: ships logs · Container tooling forwards logs to ELK