What is POJOs?

What is POJO? POJO stands for “Plain Old Java Object.” It is a term used to describe a Java object that is not “polluted” by any special requirements from a framework or a library. It is a simple Java object that does not have any special restrictions or requirements. In the context of Clean Architecture and DDD, a POJO is an object that: Doesn’t extend a specific class (e.g., extends HttpServlet or extends BaseEntity). Doesn’t implement a specific interface from a library (e.g., implements Serializable is often okay, but implements org.hibernate.Entity is not). Doesn’t use “heavy” annotations that tie it to a technology (like @Entity from JPA or @Table from SQL). Why use POJOs in your Domain (Domain Driven Diagram)? Technology Independence: Your business logic doesn’t care if you use PostgreSQL, MongoDB, or even if you’re running on a Web Server or a CLI. Easier Testing: You can test a POJO with simple Unit Tests without needing to start a Spring Context or a database. Future Proofing: If you decide to switch from JPA to another database technology later, your core business logic (the POJOs) won’t have to change at all. Example comparison: POJO (Clean/DDD style): public class User { private String username; // Pure Java logic } NOT a POJO (Infrastructure-coupled style): @Entity // Tied to JPA @Table(name = "users") // Tied to SQL public class User { @Id // Tied to JPA private Long id; } Notes: By keeping your domain.entities as POJOs, you are ensuring that your “Business Truth” remains pure and independent! ...

May 2, 2026

Library Management System

Overview A production-grade Library Management System built with Domain-Driven Design (DDD), Clean Architecture, and Hexagonal Architecture principles. This RESTful API demonstrates enterprise-level Java development practices with a focus on maintainability, testability, and scalability. The system handles book catalog management, user/member management, borrowing operations, and includes comprehensive authentication and authorization features. Tech Stack Java 17 with Spring Boot 3.3.3 PostgreSQL 15 with Flyway for database migrations Spring Security 6 with JWT (JJWT 0.12.6) for authentication Spring Data JPA with Hibernate 6 Lombok for boilerplate reduction TestContainers for integration testing GitHub Actions for CI/CD JaCoCo for code coverage (50% minimum threshold) Key Features Book Management: Full CRUD operations with ISBN validation (ISBN-10/13 formats), availability tracking, and copy management User Management: Role-based system with ADMIN, USER, and GUEST roles, each with different borrowing limits and durations Borrowing System: Complete borrowing workflow including book checkout, returns, due date extensions, overdue tracking, and automatic penalty calculation ($1/day) JWT Authentication: Secure HTTP-only cookie-based authentication with role-based access control Security Features: CSRF protection, XSS filtering with Content Security Policy headers, BCrypt password encryption Clean Architecture: Clear separation between Domain, Application, Infrastructure, and Interface layers with 18 single-responsibility use cases Challenges & Solutions Challenge 1: Maintaining Clean Architecture Boundaries Implementing true Clean Architecture required strict discipline in keeping domain logic free from framework dependencies. Solution: Created separate JPA entities in the infrastructure layer with mappers to convert between domain and persistence models, ensuring the domain layer remains pure. ...

March 10, 2025