Modern book lending management system built with Spring Boot 3, featuring JWT authentication, role-based access control, and RESTful API.
docker-compose up -ddocker run -d \
-e SPRING_DATASOURCE_URL=jdbc:postgresql://host.docker.internal:5432/booktrack \
-e SPRING_DATASOURCE_USERNAME=booktrack \
-e SPRING_DATASOURCE_PASSWORD=booktrack123 \
-e JWT_SECRET_KEY=your-secret-key \
-p 8080:8080 \
TWOJ_USERNAME/booktrack:latest-
User Management
- User registration and authentication
- JWT-based security
- Role-based access control (USER, ADMIN)
-
Book Management
- CRUD operations for books
- Book availability tracking
- Search and pagination
-
Loan Management
- Book lending with 14-day default period
- Maximum 3 active loans per user
- Automatic overdue detection
- Book return handling
-
Technical Features
- RESTful API with OpenAPI/Swagger documentation
- Caching with Caffeine
- Database migrations with Flyway
- Comprehensive test coverage (>80%)
- Docker support
- Backend: Java 21, Spring Boot 3.x
- Security: Spring Security, JWT
- Database: PostgreSQL
- Caching: Caffeine
- Documentation: SpringDoc OpenAPI
- Testing: JUnit 5, Mockito, Testcontainers
- Build: Maven
- Containerization: Docker, Docker Compose
- Java 21 or higher
- Maven 3.9+
- Docker & Docker Compose (for database)
- PostgreSQL 16 (or use Docker)
git clone https://github.com/yourusername/booktrack.git
cd booktrackdocker-compose up -dmvn spring-boot:runThe application will start on http://localhost:8080
Open your browser and navigate to:
http://localhost:8080/swagger-ui/index.html
Register User
POST /api/auth/register
Content-Type: application/json
{
"email": "user@example.com",
"password": "Password123!",
"firstName": "John",
"lastName": "Doe"
}Login
POST /api/auth/login
Content-Type: application/json
{
"email": "user@example.com",
"password": "Password123!"
}Get Available Books
GET /api/books/available?page=0&size=20Create Book (ADMIN only)
POST /api/books
Authorization: Bearer {token}
Content-Type: application/json
{
"title": "Clean Code",
"author": "Robert C. Martin",
"isbn": "9780132350884",
"publisher": "Prentice Hall",
"publishYear": 2008
}Create Loan
POST /api/loans
Authorization: Bearer {token}
Content-Type: application/json
{
"userId": 1,
"bookId": 1,
"loanDate": "2025-01-15"
}Return Book
PUT /api/loans/{id}/return
Authorization: Bearer {token}Get Overdue Loans (ADMIN only)
GET /api/loans/overdue
Authorization: Bearer {admin_token}# Run all tests
mvn clean test
# Run with coverage report
mvn clean test jacoco:report
# View coverage report
open target/site/jacoco/index.htmldocker build -t booktrack:latest .docker-compose up -dsrc/
βββ main/
β βββ java/com/yourname/booktrack/
β β βββ book/ # Book domain
β β βββ loan/ # Loan domain
β β βββ user/ # User domain
β β βββ security/ # Security & JWT
β β βββ common/ # Shared utilities
β β βββ config/ # Configuration
β βββ resources/
β βββ application.yml
β βββ db/migration/ # Flyway migrations
βββ test/
βββ java/ # Tests
Key configuration in application.yml:
spring:
datasource:
url: jdbc:postgresql://localhost:5432/booktrack
username: booktrack
password: booktrack123
jwt:
secret-key: your-secret-key
expiration-ms: 86400000 # 24 hours- users: User accounts and authentication
- books: Book catalog
- loans: Lending transactions
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License.
- Spring Boot Team
- All contributors
Made with β€οΈ using Spring Boot 3