2 Development Environment Setup
Jan Klattenhoff edited this page 2025-03-19 12:02:22 +01:00

Development Environment Setup

This guide will help you set up your development environment for the Casino Gaming Platform.

Prerequisites

Before you begin, make sure you have the following tools installed:

  1. Docker & Docker Compose

  2. Java Development Kit (JDK) 17+

  3. Node.js 18+

  4. Bun (Alternative to npm for faster package management)

    • Bun installation
    • Verify installation with: bun --version
    • Required for the frontend build and package management
  5. IDE/Code Editor

Setting Up the Backend

  1. Clone the repository

    git clone <repository-url>
    cd casino
    
  2. Import the project into your IDE

    • For IntelliJ IDEA:
      • Go to File > Open
      • Navigate to the backend directory and click Open
      • Wait for the Gradle import to complete
  3. Configure IntelliJ Database View (Optional)

    • Start Docker services (see Infrastructure Setup below)
    • Open application.properties in the resources folder
    • Copy the database URL
    • Open the Database tab in IntelliJ
    • Click on the database icon with key in the Database toolbar
    • Click the plus sign and select "Datasource from URL"
    • Paste the DB URL and select PostgreSQL driver
    • Enter username postgres_user and password postgres_pass
    • In the Schemas tab, uncheck all options and only check postgresdb and public

Setting Up the Frontend

  1. Navigate to the frontend directory

    cd frontend
    
  2. Install dependencies

    bun install
    

    or

    npm install
    
  3. Configure your IDE/Editor (for VS Code)

    • Install recommended extensions:
      • Angular Language Service
      • ESLint
      • Prettier
      • Tailwind CSS IntelliSense
  4. Import project settings

    • VS Code workspace settings are included in the repository

Setting Up Infrastructure

  1. Start Docker services

    cd docker
    docker-compose up -d
    

    This will start:

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

    docker-compose ps
    

    All services should show as "running"

  3. Access Keycloak Admin Console

    • Open http://localhost:9090 in your browser
    • Login with username admin and password admin
    • Verify the lf12-realm is imported

Configuring IDE for Java Development

IntelliJ IDEA Setup

  1. Install Checkstyle Plugin

    • Go to Settings > Plugins
    • Search for "Checkstyle-IDEA"
    • Install and restart IntelliJ
  2. Configure Checkstyle

    • Go to Settings > Tools > Checkstyle
    • Set Checkstyle version to 8.42
    • Add a new configuration file
    • Select the checkstyle.xml from the config/checkstyle directory
    • Name it "Casino Checkstyle"
    • Set it as active
  3. Configure Code Style

    • Go to Settings > Editor > Code Style
    • Import scheme from config/codestyles/Casino.xml (if available)

Running the Components

Backend

  1. From the IDE

    • Find the CasinoApplication.java file
    • Right-click and select "Run CasinoApplication"
  2. From the command line

    cd backend
    ./gradlew bootRun
    
  3. Verify the backend is running

Frontend

  1. Start the development server

    cd frontend
    bun run start
    

    or

    bunx @angular/cli serve --proxy-config src/proxy.conf.json
    
  2. Verify the frontend is running

    • Open http://localhost:4200 in your browser
    • You should see the landing page of the Casino Gaming Platform

Troubleshooting

PostgreSQL Issues

If you encounter PostgreSQL connection issues:

  1. Reset the database
    cd docker
    docker-compose down
    docker volume rm local_lf8_starter_postgres_data
    docker-compose up -d
    

Keycloak Issues

If you have problems with Keycloak:

  1. Reset Keycloak

    cd docker
    docker-compose down
    docker volume rm casino_keycloak_data
    docker-compose up -d
    
  2. Manual Realm Import

    • Open http://localhost:9090/admin
    • Create a new realm named "lf12-realm"
    • Import the realm configuration from docker/imports/lf12-realm.json

Frontend Build Issues

If you encounter build or dependency issues:

  1. Clear node_modules and reinstall

    cd frontend
    rm -rf node_modules
    bun install
    
  2. Clear Angular cache

    rm -rf .angular
    

Getting Help

If you encounter any issues not covered in this guide:

  1. Check the project's GitHub Issues
  2. Consult the documentation
  3. Reach out to the development team