Configuration files
The application uses two main configuration sources:.envfile - Root-level environment variables for Docker Composeapplication.properties- Spring Boot application configuration
Create your
.env file by copying .env.example and filling in the required values.Environment variables reference
PostgreSQL configuration
These variables configure the PostgreSQL database connection.The username for the PostgreSQL database.Example:
library_adminThe password for the PostgreSQL database user.Security: Use a strong, randomly generated password in production.Example:
secure_password_123The name of the PostgreSQL database.Example:
library_dbBackend configuration
The port on which the backend server will be exposed on the host machine.The Spring Boot application always runs on port 8080 inside the container. This variable maps the container port to your host.Example:
8080Spring datasource variables
These variables are set automatically by Docker Compose and consumed by Spring Boot.JDBC connection string for PostgreSQL.Format:
jdbc:postgresql://database:5432/${POSTGRES_DB}Note: This is automatically set in compose.yaml using the container hostname database.Database username for Spring Boot.Value: Same as
POSTGRES_USERDatabase password for Spring Boot.Value: Same as
POSTGRES_PASSWORDRedis configuration
These variables configure the Redis cache connection.Redis server hostname.Default:
cache (the Docker Compose service name)Redis server port.Default:
6379Security configuration
Secret key used for signing and verifying JWT tokens.Security considerations:Example:
- Use a strong, randomly generated secret key
- Keep this value confidential and never commit it to version control
- Rotate this key periodically in production
- Minimum recommended length: 256 bits (32 characters)
your-256-bit-secret-key-hereFrontend configuration
These variables configure the Next.js frontend application.Backend API URL for server-side requests (container-to-container).This is used by the Next.js server when making API calls during server-side rendering.Default:
http://backend:8080Backend API URL for client-side requests (browser-to-host).This is used by the browser when making API calls from the client side. The
NEXT_PUBLIC_ prefix makes this variable available to the browser.Default: http://localhost:8080Production: Set this to your public API domain (e.g., https://api.yourdomain.com)Example .env file
Here’s a complete example of a.env file for local development:
.env
Spring Boot application properties
Theapplication.properties file contains additional configuration that references environment variables.
JPA and Hibernate settings
spring.jpa.hibernate.ddl-auto=update- Automatically updates the database schemaspring.jpa.show-sql=true- Logs SQL statements (useful for debugging)spring.jpa.properties.hibernate.dialect- Specifies PostgreSQL dialect
Actuator endpoints
/actuator/health endpoint used for container health checks.
JWT token configuration
- Access token expiration: 900,000 ms (15 minutes)
- Refresh token expiration: 2,592,000,000 ms (30 days)
- Cleanup cron: Runs daily at 3:00 AM to remove expired refresh tokens
DevTools settings
DevTools features are automatically disabled when the application runs with a packaged JAR (production mode).
JSON serialization
Environment-specific configuration
Development
For local development, use the default values from.env.example:
- Database:
localhost:5432 - Backend:
localhost:8080 - Frontend:
localhost:3000 - Redis:
localhost:6379
Production
For production deployments, consider:- Use strong passwords - Generate secure, random passwords for database access
- Rotate JWT secrets - Change the JWT secret key periodically
- Use HTTPS - Set
NEXT_PUBLIC_API_URLto an HTTPS endpoint - Disable SQL logging - Set
spring.jpa.show-sql=false - Use managed services - Consider using managed PostgreSQL and Redis services
- Set appropriate DDL mode - Change
spring.jpa.hibernate.ddl-autotovalidateornone
Verifying configuration
You can verify your environment configuration by checking the backend health endpoint:Troubleshooting
Database connection failed
If the backend cannot connect to the database:- Verify
POSTGRES_USER,POSTGRES_PASSWORD, andPOSTGRES_DBmatch in your.envfile - Check that the database container is healthy:
docker compose ps database - Review database logs:
docker compose logs database
JWT authentication errors
If you encounter JWT-related errors:- Ensure
JWT_SECRET_KEYis set and has sufficient length (minimum 32 characters) - Verify the environment variable is properly passed to the backend container
- Check backend logs:
docker compose logs backend
Frontend cannot connect to backend
If the frontend cannot reach the backend API:- Verify
NEXT_PUBLIC_API_URLis set correctly - Check that the backend is accessible at the specified URL
- Review browser console for CORS or network errors