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
| git clone https://github.com/gustaffo/reservations.git
cd reservations
|
Create a local PostgreSQL database for development:
| CREATE DATABASE gustaffo_reservations;
CREATE USER gustaffo WITH PASSWORD 'dev_password';
GRANT ALL PRIVILEGES ON DATABASE gustaffo_reservations TO gustaffo;
|
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
5. Run Database Migrations
The application uses Flyway for database migrations:
6. Run the Application
| ./gradlew bootRun --args='--spring.profiles.active=dev'
|
Alternatively, you can run the application from your IDE with the following VM options:
| -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
| git checkout -b feature/my-new-feature
|
2. Implement Your Changes
Make your code changes following the project's coding standards.
3. Run Tests
4. Build the Application
5. Submit a Pull Request
Push your changes and create a pull request:
| git push origin feature/my-new-feature
|
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
- Create the entity class in the appropriate package
- Create a repository interface for the entity
- Create a service class for business logic
- Create a controller for API endpoints
- Create a Flyway migration script in
src/main/resources/db/migration
Adding a New API Endpoint
- Identify the appropriate controller or create a new one
- Add the new endpoint method with proper annotations
- Implement the service logic
- Document the endpoint with OpenAPI annotations
- Write tests for the new endpoint