Skip to content

Getting Started with Development

Prerequisites

Before you begin, ensure you have the following installed:

  • Java Development Kit (JDK) 17 or later
  • Gradle 7.x or later
  • PostgreSQL 13.x or later
  • Git
  • IDE (IntelliJ IDEA recommended)

Setting Up the Development Environment

1. Clone the Repository

1
2
git clone https://github.com/gustaffo/reservations.git
cd reservations

2. Configure the Database

Create a local PostgreSQL database for development:

1
2
3
CREATE DATABASE gustaffo_reservations;
CREATE USER gustaffo WITH PASSWORD 'dev_password';
GRANT ALL PRIVILEGES ON DATABASE gustaffo_reservations TO gustaffo;

3. Configure Application Properties

Create a file src/main/resources/application-dev.yml with your local configuration:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/gustaffo_reservations
    username: gustaffo
    password: dev_password
  jpa:
    hibernate:
      ddl-auto: validate
    show-sql: true

logging:
  level:
    com.gustaffo: DEBUG
    org.hibernate.SQL: DEBUG

4. Build the Application

1
./gradlew clean build

5. Run Database Migrations

The application uses Flyway for database migrations:

1
./gradlew flywayMigrate

6. Run the Application

1
./gradlew bootRun --args='--spring.profiles.active=dev'

Alternatively, you can run the application from your IDE with the following VM options:

1
-Dspring.profiles.active=dev

The application will be available at http://localhost:8080

Project Structure

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
src/
├── main/
│   ├── java/
│   │   └── com/
│   │       └── gustaffo/
│   │           └── reservations/
│   │               ├── asm/               # Assembly module
│   │               ├── cms/               # Content Management System
│   │               ├── configuration/     # Application configuration
│   │               ├── connectors/        # External system integrations
│   │               ├── controller/        # REST controllers
│   │               ├── mail/              # Email functionality
│   │               ├── offers/            # Offers module
│   │               ├── payment/           # Payment processing
│   │               ├── rbac/              # Role-Based Access Control
│   │               ├── security/          # Security configuration
│   │               └── InteractiveQApp.java  # Main application class
│   └── resources/
│       ├── db/
│       │   └── migration/                 # Flyway database migrations
│       ├── static/                        # Static resources
│       ├── templates/                     # Template files
│       └── application.yml                # Application configuration
└── test/
    └── java/
        └── com/
            └── gustaffo/
                └── reservations/          # Test classes

Development Workflow

1. Create a Feature Branch

1
git checkout -b feature/my-new-feature

2. Implement Your Changes

Make your code changes following the project's coding standards.

3. Run Tests

1
./gradlew test

4. Build the Application

1
./gradlew clean build

5. Submit a Pull Request

Push your changes and create a pull request:

1
git push origin feature/my-new-feature

Development Tools

Spring Boot DevTools

The project includes Spring Boot DevTools for automatic restarts and live reload. When running the application in development mode, changes to class files will trigger an automatic restart.

H2 Console

When running with the dev profile, the H2 console is available at http://localhost:8080/h2-console for database inspection.

Swagger UI

API documentation is available at http://localhost:8080/swagger-ui.html when the application is running.

Common Development Tasks

Adding a New Entity

  1. Create the entity class in the appropriate package
  2. Create a repository interface for the entity
  3. Create a service class for business logic
  4. Create a controller for API endpoints
  5. Create a Flyway migration script in src/main/resources/db/migration

Adding a New API Endpoint

  1. Identify the appropriate controller or create a new one
  2. Add the new endpoint method with proper annotations
  3. Implement the service logic
  4. Document the endpoint with OpenAPI annotations
  5. Write tests for the new endpoint
Back to top