Prerequisites
Before you begin, ensure you have:- Docker Desktop (or Docker Engine + Docker Compose)
- Git
- 4GB+ RAM available
This guide uses Docker Compose to run PostgreSQL, the Spring Boot backend, and the React frontend together. No manual setup required!
Steps
Start the stack
Build and launch all services with a single command:This will:
- Start PostgreSQL 16 on port 5432
- Build and start the Spring Boot backend on port 8080
- Build and start the React frontend (Nginx) on port 80
Access the application
Open your browser and navigate to:
- Frontend: http://localhost
- Backend API: http://localhost:8080/api/stats
Verify Installation
Test the API directly with curl:Common Commands
View logs in real-time
Check service status
Stop all services
Reset database (delete all data)
What’s Running?
The Docker Compose stack creates three services:| Service | Port | Description |
|---|---|---|
| frontend | 80 | React SPA served by Nginx |
| backend | 8080 | Spring Boot 3.4.2 REST API |
| postgres | 5432 | PostgreSQL 16 database |
Default Credentials
These are development defaults from
docker-compose.yml. Never use these in production!- PostgreSQL User:
postgres - PostgreSQL Password:
changeme - Database Name:
urlshortener - JWT Secret:
changeme-this-must-be-at-least-32-chars-long!!
Next Steps
Local Development
Learn about environment variables, debugging, and hot reload
API Reference
Explore all available endpoints and authentication
Troubleshooting
Port 80 already in use
Port 80 already in use
If port 80 is already taken, edit
docker-compose.yml and change the frontend port mapping:Backend fails to connect to database
Backend fails to connect to database
Ensure PostgreSQL is healthy before the backend starts. Check logs:If needed, restart services:
Frontend shows 'Network Error'
Frontend shows 'Network Error'
The frontend is trying to reach the backend at
http://localhost:8080. Verify:- Backend is running:
docker compose ps - Backend is accessible:
curl http://localhost:8080/api/stats - CORS is configured correctly (default allows localhost origins)