You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CogniPost is a full-featured blog platform REST API built with Spring Boot 3.2.4 and Java 17. It provides a complete backend for a modern blogging application with JWT authentication, article management, nested comments, social interactions, personalized feeds, and full-text search. Designed to be consumed by a Next.js SSR frontend.
Architecture
com.example.blog_app_springboot/
├── config/ # SecurityConfig, CorsConfig, OpenApiConfig, JpaConfig
├── common/
│ ├── base/ # BaseEntity with JPA auditing
│ ├── dtos/ # ApiResponse<T>, PageResponse<T>, ErrorResponse
│ ├── exceptions/ # GlobalExceptionHandler, custom exceptions
│ ├── utils/ # SlugGenerator, ReadingTimeCalculator
├── security/
│ ├── jwt/ # JwtTokenProvider, JwtAuthFilter
│ ├── config/ # SecurityFilterChain, CustomAuthenticationEntryPoint
│ ├── auth/ # AuthService, AuthController
│ └── util/ # SecurityUtil
├── users/ # User management with BCrypt + roles
├── articles/ # Full CRUD with drafts, tags, pagination
├── comments/ # Nested comments with cascade delete
├── tags/ # Auto-created tags, many-to-many with articles
├── interactions/ # Likes & Bookmarks with toggle logic
├── follows/ # User follow system with events
├── feed/ # Personalized feed from followed users
├── search/ # JPA Specifications + PostgreSQL full-text search
└── notifications/ # Spring Events, async email service
Tech Stack
Layer
Technology
Framework
Spring Boot 3.2.4, Java 17
Database
H2 (dev), PostgreSQL (prod)
Auth
JWT (jjwt 0.12.5), BCrypt, Spring Security
ORM
Spring Data JPA, Hibernate 6.4
Validation
Bean Validation (Hibernate Validator)
API Docs
springdoc OpenAPI 2.5 (Swagger UI)
Rate Limiting
Bucket4j 8.10.1
Testing
JUnit 5, Mockito, MockMvc, @DataJpaTest
Build
Gradle
Design Patterns
Pattern
Implementation
Repository
Spring Data JPA interfaces with custom queries
Service Layer
Interface + implementation per module
DTO Pattern
Request/Response DTOs decoupled from entities
Strategy
Search strategies (PostgreSQL tsvector vs LIKE fallback)
Observer
Spring @EventListener for domain events (comments, follows)
# Clone the repository
git clone https://github.com/your-org/CogniPost.git
cd CogniPost
# Run with dev profile (H2 database)
./gradlew bootRun
# Run with prod profile (PostgreSQL)
./gradlew bootRun --args='--spring.profiles.active=prod'
Configuration
Profile
Database
Port
dev
H2 (file-based)
8080
prod
PostgreSQL
${PORT}
test
H2 (in-memory)
-
H2 Console (dev):http://localhost:8080/h2-console
Swagger UI:http://localhost:8080/swagger-ui.html
Environment Variables (prod)
Variable
Description
DB_URL
PostgreSQL connection URL
DB_USERNAME
Database username
DB_PASSWORD
Database password
JWT_SECRET
JWT signing key (min 256 bits)
CORS_ALLOWED_ORIGINS
Comma-separated allowed origins
Testing
# Run all tests
./gradlew test# Run with coverage
./gradlew test jacocoTestReport
# Run specific test class
./gradlew test --tests "AuthIntegrationTest"
Test Coverage: 95+ unit and integration tests covering: