Overview
This guide walks you through setting up the Product Distribution Dashboard for local development, allowing you to run the backend and frontend separately with hot reload capabilities for rapid development.Prerequisites
Ensure you have the following installed on your development machine:Java Development Kit (JDK)
Version Required: Java 17Verify installation:Expected output:
openjdk version "17.x.x"Download from:Apache Maven
Node.js
Version Required: Node.js 20.xVerify installation:Download from: Node.js Official Site
Use nvm for managing multiple Node.js versions.
Database Setup
Create Database
If you installed PostgreSQL locally, create the database:Then in the PostgreSQL prompt:
If using Docker for PostgreSQL (recommended), the database is automatically created with the correct credentials.
Backend Setup
Configure Environment
The backend uses Spring profiles. For local development, the
dev profile is active by default.Create a .env file in the backend directory (optional) or export environment variables:These are the default values in
application-dev.properties. Only set environment variables if you need to override defaults.Backend Hot Reload
The backend includes Spring Boot DevTools for automatic restart on code changes:DevTools automatically restarts the application when classes change. Build the project in your IDE or run
mvn compile to trigger a restart.Frontend Setup
Install Dependencies
Install all npm packages:
Use
npm ci for clean installs (recommended for development) or npm install to update packages.Configure API Endpoint
The frontend is configured to connect to the backend at
http://localhost:8080 by default.If you need to change this, update the API base URL in your environment configuration files.Run the Frontend
Start the Angular development server:The frontend will start on port 4200 by default.
Access the Application
Open your browser and navigate to:http://localhost:4200The application should load with hot reload enabled.
Frontend Hot Reload
Angular’s development server includes automatic hot reload:- Changes to TypeScript files trigger recompilation
- Browser automatically refreshes on successful build
- Live reload for HTML and SCSS changes
Keep the terminal running to maintain the development server. Press
Ctrl+C to stop.Development Workflow
Running Both Services Simultaneously
For full-stack development, you’ll need two terminal windows:Building for Production
Running Tests
Code Formatting
The frontend includes Prettier for code formatting:Configuration Files
Backend Configuration
The backend uses Spring profiles for different environments:| File | Profile | Purpose |
|---|---|---|
application.properties | Default | Base configuration |
application-dev.properties | dev | Local development settings |
application-prod.properties | prod | Production settings |
application-test.properties | test | Test configuration |
Frontend Configuration
Package.json Scripts:Environment Variables Reference
Backend Environment Variables
| Variable | Default | Description |
|---|---|---|
SPRING_PROFILES_ACTIVE | dev | Active Spring profile |
SPRING_DATASOURCE_URL | Required | PostgreSQL JDBC URL |
SPRING_DATASOURCE_USERNAME | Required | Database username |
SPRING_DATASOURCE_PASSWORD | Required | Database password |
APP_FRONTEND_URL | Required | Frontend URL for CORS |
PORT | 8080 | Server port |
DATA_PRODUCTS_URL | GitHub URL | Products data source |
DATA_STORES_URL | GitHub URL | Stores data source |
DATA_WAREHOUSES_URL | GitHub URL | Warehouses data source |
Development Values
Troubleshooting
Backend Won’t Start
Issue: Port 8080 already in use Solution: Change the port inapplication.properties or set the PORT environment variable:
Issue: Database connection failed Solution:
-
Verify PostgreSQL is running:
- Check database credentials in environment variables
-
Ensure database exists:
Frontend Won’t Start
Issue:node_modules errors
Solution: Delete and reinstall dependencies:
Issue: Port 4200 already in use Solution: Use a different port:
Hot Reload Not Working
Backend:- Ensure DevTools is in the classpath
- Check if your IDE automatically compiles on save
- Manually trigger compilation with
mvn compile
- Restart the development server
- Clear browser cache
- Check browser console for errors
Maven Build Errors
Issue: Dependencies won’t download Solution:-U flag forces update of snapshots and releases.
Issue: MapStruct annotation processing errors Solution: Ensure Lombok and MapStruct are configured correctly in
pom.xml:
IDE Configuration
IntelliJ IDEA
Enable Annotation Processing
Settings → Build, Execution, Deployment → Compiler → Annotation ProcessorsCheck: “Enable annotation processing”
VS Code
Recommended Extensions:- Spring Boot Extension Pack
- Java Extension Pack
- Angular Language Service
- Prettier - Code formatter
- ESLint
Next Steps
Docker Setup
Run the application using Docker Compose
Deployment
Deploy to production environments