Prerequisites
Before you begin, ensure you have the following installed:- Docker (version 20.10 or higher)
- Docker Compose (version 2.0 or higher)
- Git
Docker Desktop includes Docker Compose, so you don’t need to install it separately if you’re using Docker Desktop.
Setup steps
Clone the repository
Clone the library management system repository to your local machine:The repository is organized as a monorepo:
apps/spring-boot-app- Backend applicationapps/nextjs-app- Frontend applicationcompose.yaml- Docker Compose configuration for all services
Configure environment variables
Create a Open the
.env file in the root directory by copying the example file:.env file and configure the following variables:Start the services
Launch all services using Docker Compose:This command will:The services will start in the following order:
- Build Docker images for the frontend and backend
- Start PostgreSQL database (port 5432)
- Start Redis cache (internal)
- Start Spring Boot backend (port 8080)
- Start Next.js frontend (port 3000)
The first run will take several minutes as Docker builds the images and downloads dependencies. Subsequent starts will be much faster.
- PostgreSQL database
- Redis cache
- Spring Boot backend (waits for database and cache health checks)
- Next.js frontend (waits for backend health check)
Verify the installation
Once all containers are running, you can access:You can verify all containers are running:You should see all four services (database, cache, backend, frontend) with status “Up” and “healthy”.
Frontend
http://localhost:3000The Next.js application with the user interfaceBackend API
http://localhost:8080The Spring Boot REST APIAPI documentation
http://localhost:8080/swagger-ui.htmlInteractive API documentation powered by SpringDocHealth check
http://localhost:8080/actuator/healthBackend health statusDocker Compose architecture
Thecompose.yaml file defines the complete application stack:
compose.yaml
Managing the application
Stop the services
To stop all running services:Stop and remove data
To stop services and remove all data (including the database):View logs
To view logs from all services:Restart a service
To restart a specific service:Development workflow
For local development without Docker, you can run services individually:Start infrastructure only
Start just the database and cache:Backend development
With infrastructure running, start the Spring Boot backend:Frontend development
Start the Next.js frontend:Troubleshooting
Port already in use
Port already in use
If you see an error about ports being in use (3000, 5432, or 8080), you can either:
- Stop the service using that port
- Change the port in the
.envfile (for backend) orcompose.yaml(for frontend/database)
Database connection failed
Database connection failed
If the backend can’t connect to the database:
- Ensure the database container is healthy:
docker-compose ps - Verify environment variables in
.envmatch the database configuration - Check database logs:
docker-compose logs database
Build fails
Build fails
If Docker build fails:
- Ensure you have enough disk space
- Try cleaning Docker cache:
docker system prune -a - Pull the latest base images:
docker-compose pull - Rebuild without cache:
docker-compose build --no-cache
Frontend can't reach backend
Frontend can't reach backend
If the frontend shows connection errors:
- Verify the backend is running:
curl http://localhost:8080/actuator/health - Check that
NEXT_PUBLIC_API_URLin the frontend environment is set tohttp://localhost:8080 - Ensure there are no CORS issues in the browser console
Next steps
Authentication
Learn how to authenticate users with JWT tokens
Book management
Explore book CRUD operations and management features
API reference
Browse the complete API documentation
Environment configuration
Configure the system for production deployment