A full-stack library management system built with Spring Boot 3.4 on Java 21 (backend) and React + Vite + TailwindCSS (frontend).
- Book Management - Add, update, delete, and search books with full-text search
- Copy Management - Track individual copies with status (On Shelf, Loaned, Returned, Lost)
- Loan System - Borrow, return, and renew books with configurable limits
- User Management - Two roles: MEMBER (borrowers) and LIBRARIAN (administrators)
- Overdue Tracking - Real-time overdue calculation (no background job needed)
- JWT-based authentication
- Role-based access control (RBAC)
- Stateless sessions
- PostgreSQL with Flyway migrations
- Partial unique index on
loans(copy_id)WHEREstatus IN ('ACTIVE', 'OVERDUE')to prevent double-lending
- Docker & Docker Compose
# Start all services (PostgreSQL, Backend API, Frontend)
docker-compose up --build
# Or run in background
docker-compose up -dAccess the application:
- Frontend: http://localhost:3000
- API: http://localhost:8080
| Username | Password | Role |
|---|---|---|
| librarian | member123 | LIBRARIAN |
| john_doe | member123 | MEMBER |
| jane_smith | member123 | MEMBER |
cd backend
# Run with Maven
./mvnw spring-boot:run
# Or build JAR
./mvnw clean package -DskipTests
java -jar target/library-management-1.0.0.jarcd frontend
# Install dependencies
npm install
# Run dev server
npm run devPOST /api/auth/login- LoginGET /api/auth/me- Get current user
GET /api/books- List books (paginated)GET /api/books/search?q=query- Full-text searchPOST /api/books- Create book (Librarian)PUT /api/books/{id}- Update book (Librarian)DELETE /api/books/{id}- Delete book (Librarian)POST /api/books/{id}/copies- Add copy (Librarian)
GET /api/loans/my-loans- Get my active loansPOST /api/loans/{id}/return- Return a bookPOST /api/loans/{id}/renew- Renew a loan
GET /api/loans- List all loansPOST /api/loans- Create loanGET /api/loans/overdue- Get overdue loans
GET /api/users- List usersPOST /api/users- Create userPATCH /api/users/{id}/toggle-status- Toggle active status
library-management/
├── docker-compose.yml # Docker orchestration
├── backend/
│ ├── src/main/java/com/library/
│ │ ├── config/ # Security & app config
│ │ ├── controller/ # REST controllers
│ │ ├── dto/ # Request/Response DTOs
│ │ ├── entity/ # JPA entities
│ │ ├── exception/ # Exception handling
│ │ ├── repository/ # JPA repositories
│ │ ├── security/ # JWT & auth
│ │ └── service/ # Business logic
│ ├── src/main/resources/
│ │ ├── application.yml # App configuration
│ │ └── db/migration/ # Flyway SQL migrations
│ └── Dockerfile
└── frontend/
├── src/
│ ├── components/ # React components
│ ├── context/ # Auth context
│ ├── pages/ # Page components
│ ├── services/ # API services
│ └── App.jsx # Router setup
├── Dockerfile
└── nginx.conf # Reverse proxy config
See backend/src/main/resources/db/migration/V1__Initial_Schema.sql
MIT