1 Running the Application
Jan Klattenhoff edited this page 2025-03-19 12:02:22 +01:00

Running the Application

This guide describes how to run the Casino Gaming Platform locally.

Prerequisites

Ensure you have all requirements installed as described in the Development Environment Setup guide.

Starting the Infrastructure

Before running the application, you need to start the required infrastructure:

  1. Start Docker services

    cd docker
    docker-compose up -d
    

    This starts:

    • PostgreSQL database (port 5432)
    • PostgreSQL for Keycloak (port 9433)
    • Keycloak authentication server (port 9090)
  2. Verify services are running

    docker ps
    

Running the Backend

  1. Navigate to the backend directory

    cd backend
    
  2. Start the Spring Boot application

    ./gradlew bootRun
    

    Alternatively, you can run it from your IDE by running the CasinoApplication class.

  3. Verify the backend is running

Running the Frontend

  1. Navigate to the frontend directory

    cd frontend
    
  2. Install dependencies (if not already done)

    bun install
    
  3. Start the development server

    bun run start
    

    or

    bunx @angular/cli serve --proxy-config src/proxy.conf.json
    
  4. Access the application

Using Docker Compose for Everything

For convenience, you can run the entire stack using Docker Compose:

  1. Build the containers

    docker-compose -f docker/docker-compose.yml build
    
  2. Start the services

    docker-compose -f docker/docker-compose.yml up -d
    
  3. Access the application

Stopping the Application

  1. Stop the frontend

    • Press Ctrl+C in the terminal where the frontend is running
  2. Stop the backend

    • Press Ctrl+C in the terminal where the backend is running
  3. Stop Docker services

    cd docker
    docker-compose down
    

Common Issues and Solutions

Frontend cannot connect to backend

  • Ensure the backend is running
  • Check that the proxy configuration in src/proxy.conf.json is correct
  • Verify that Docker services are running

Authentication issues

  • Ensure Keycloak is running and accessible at http://localhost:9090
  • Check that the user exists in the Keycloak realm
  • Verify the client configuration in Keycloak

Database connection issues

  • Ensure PostgreSQL is running
  • Check the database connection settings in application.properties
  • Try resetting the database (see Troubleshooting)

Development Modes

Backend Development with Hot Reload

Spring Boot Development Tools provide hot reload capabilities:

./gradlew bootRun --args="--spring.devtools.restart.enabled=true"

Frontend Development with HMR

Angular CLI provides hot module replacement:

bun run start

This automatically enables HMR for faster development.