Prerequisites
Before you begin, ensure you have:- Docker & Docker Compose installed on your system
Optional: Node.js (v18+) and Java 17 are only needed if you want to run tests, linting, or builds outside of Docker.
Start the Application
The fastest way to run the Product Distribution Dashboard is with Docker Compose, which starts all services (PostgreSQL, backend, frontend, and pgAdmin) in one command.Start the Stack
From the project root, run:This command will:
- Build the backend Spring Boot application
- Build the Angular frontend application
- Start PostgreSQL 16 with the configured database
- Start pgAdmin for database administration
- Connect all services together
The
--build flag ensures the latest code changes are included. For subsequent starts without code changes, you can use docker compose up.Wait for Services to Initialize
The first startup takes a few minutes as Docker builds the images and initializes the database. Watch for these indicators:
- PostgreSQL health check passes
- Backend starts and runs Flyway migrations
- Frontend compilation completes
- Data loading from JSON sources completes
Access the Application
Once all services are running, you can access:Frontend Dashboard
URL: http://localhost:4200The main application interface with maps, metrics, and data tables
Backend API
URL: http://localhost:8080RESTful API endpoints and Spring Boot actuator
pgAdmin
Health Check
URL: http://localhost:8080/actuator/healthBackend health status endpoint
What Happens on First Startup
When the application starts for the first time, the following automatic processes occur:Database Schema Creation
Flyway runs migrations to create the database schema:
productsandproduct_sizestablesstorestable with geolocation and capacity fieldswarehousestable with geolocation dataproduct_itemstable for inventorystock_assignmentstable for distribution resultsunfulfilled_demandstable for tracking shortages
JSON Data Loading
The backend loads initial data from JSON sources:
- Products: Product catalog with brands and sizes
- Stores: Store locations with coordinates, capacity, and demand
- Warehouses: Warehouse locations with available inventory
/data/current/ directory.Distribution Algorithm Execution
The system automatically runs the distribution algorithm to:
- Calculate optimal warehouse assignments for each store’s demand
- Respect store capacity constraints and expected return rates
- Generate stock assignments and track unfulfilled demands
- Populate the database with distribution results
Verify the Installation
To confirm everything is working correctly:- Check the Frontend: Open http://localhost:4200 and verify you see the dashboard with a map
- View Stock Assignments: Click on the “Stock Assignments” tab to see distribution data
- Inspect Metrics: Look for global metrics showing fulfillment rates and total assignments
- Test Filtering: Use the filters to select specific warehouses, stores, or products
Docker Compose Configuration
Thedocker-compose.yml file defines the following services:
Environment Profiles
The backend uses Spring Boot profiles to manage different environments:Development Profile (dev)
Used by default in Docker Compose:
- Connects to local PostgreSQL container
- Loads data from GitHub raw JSON URLs (configurable)
- Enables Spring Boot DevTools for hot reload
- Uses environment variables for database connection
Production Profile (prod)
Used for Render deployment:
- Connects to external PostgreSQL with SSL
- Configurable via
DATABASE_HOST,DATABASE_PORT,DATABASE_NAME - Optimized HikariCP connection pool settings
- Configurable scheduler cron expressions
Stopping the Application
To stop all services:Troubleshooting
Backend fails to connect to PostgreSQL
Backend fails to connect to PostgreSQL
Ensure the PostgreSQL container is healthy before the backend starts. The
docker-compose.yml includes a health check dependency. Check logs with:Frontend shows connection errors
Frontend shows connection errors
Verify the backend is running and accessible at http://localhost:8080. The frontend is configured to connect to this URL by default.
Data not loading
Data not loading
Check that the backend can access the JSON data URLs. By default, it fetches from GitHub. You can override with environment variables:
DATA_PRODUCTS_URLDATA_STORES_URLDATA_WAREHOUSES_URL
Port conflicts
Port conflicts
If ports 4200, 8080, 5432, or 5050 are already in use, modify the port mappings in
docker-compose.yml.What’s Next?
Architecture Overview
Learn about the system architecture, data flow, and core components
API Reference
Explore the backend REST API endpoints
Frontend Guide
Understand the Angular components and services
Configuration
Customize data sources, strategies, and deployment settings