CoolLib — Distributed Library Core API
A high-performance backend ecosystem engineered with Clean Architecture. It implements a strict separation between JPA Entities and DTOs, serving as the central orchestration hub for both Android (Kotlin) and iOS (SwiftUI) clients.
Project Overview
CoolLib Backend is a robust RESTful service built with Spring Boot 3.4 and Kotlin. Beyond standard CRUD operations, it manages complex business logic layers to ensure data consistency, security, and seamless synchronization across the mobile ecosystem.
Key Technical Wins
Layered Architecture
Strictly follows the Controller-Service-Repository pattern, ensuring complete decoupling between business logic and data access layers.
Secure Sessions
Integrated Spring Security with JWT (JSON Web Tokens) to provide a stateless authentication mechanism tailored for mobile clients.
Persistence Layer
Leverages PostgreSQL and Spring Data JPA, ensuring the atomicity of borrowing operations through @Transactional services.
Performance Optimization
Reduced network overhead via DTO Projections and optimized database indexing for high-speed book searches.
System Architecture
*The backend follows a strict Stateless pattern.*
Authentication Flow
*The security layer uses a OncePerRequestFilter to intercept and validate JWTs.*
Tech Stack
- Core Framework: Spring Boot 3.4, Kotlin (JVM 17), Maven
- Security: JWT, Spring Security, BCrypt Password Hashing
- Data Management: PostgreSQL, Spring Data JPA, Hibernate ORM
- Standards: RESTful API Design, Docker-Ready Deployment
Core Features
Identity Management
Advanced Search
Transaction Logic
Standardized Responses
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| POST | /api/v1/auth/login |
Verify credentials and issue a JWT Access Token. | |
| POST | /api/v1/borrow/scan |
Process borrowing via Barcode/ISBN scan. In Dev | |
| GET | /api/v1/stats/loans |
Fetch aggregate data of active loans and trends. Planned | |
| GET | /api/v1/users/profile |
Retrieve identity claims from the decrypted JWT payload. | |
| GET | /api/v1/auth/validate |
Check if the current token is expired or blacklisted. |
| Method | Endpoint | Description | Auth |
|---|---|---|---|
| GET | /api/v1/books/search |
Multi-criteria filtering by Title, Author, Publisher, and Year. | |
| GET | /api/v1/books/fuzzy |
Fuzzy search using Levenshtein Distance or partial matching logic. In Dev | |
| GET | /api/v1/books/recommend |
Content-based filtering using User Borrowing History. Planned | |
| GET | /api/v1/books/isbn/{isbn} |
Direct lookup via 10 or 13-digit International Standard Book Number. |
Transaction Processing Pipeline
ACID SECUREuserId & roles from JWT claims.SELECT FOR UPDATE to prevent race conditions.Persist LoanRecord & update Inventory.
Managed by Spring @Transactional logic.
Large Content Handling
To optimize network bandwidth for mobile clients, long descriptions are truncated in search results and fully loaded only via the /details endpoint.
{
"status": "SUCCESS",
"data": {
"id": 262,
"isbn": "9780099590088",
"title": "Sapiens: A Brief History of Humankind",
"author": "Yuval Noah Harari",
"publisher": "Vintage",
"year": 2011,
"available": true,
"description": "// [Omitted: 2,500+ characters of content] ..."
},
"_metadata": {
"content_length": 2541,
"truncated": true
}
}
Mobile Connectivity
Both Android and iOS clients interact with this backend through standard REST endpoints.
Authorization: Bearer <token>
Developed with passion by Ryan Su © 2026