1. Introduction

In today’s fast-paced development environment, accelerating the development process is crucial for delivering projects efficiently. Generating boilerplate code and configuration files can significantly streamline this process.

Bootify offers a powerful Spring Boot prototype solution for this purpose. By automating the creation of standard components and configurations, Bootify enables us to bypass repetitive and time-consuming setup tasks. This allows developers to dedicate their efforts to the more innovative and unique aspects of the application, such as refining business logic and adding custom features.

In this tutorial, we’ll explore the basics of the Bootify project, providing a comprehensive overview of its core features and capabilities. We’ll also walk through a practical example to demonstrate how Bootify can effectively be utilized in real-world scenarios.

2. What Is Bootify?

Bootify is a user-friendly application generator designed specifically for Spring Boot frameworks. It simplifies and accelerates the development process by automating the creation of boilerplate code and configuration files necessary for building Spring Boot applications.

With Bootify, developers can effortlessly set up entities, relationships, and various application components through an intuitive web-based interface. This tool streamlines the initial setup and ensures consistency and adherence to best practices in code structure.

By generating foundational code and configurations, Bootify allows developers to focus on crafting unique business logic and custom features, making it an invaluable asset for both rapid prototyping and full-scale application development.

3. Creating a Project

Creating a project with Bootify is straightforward and efficient, and it helps us quickly get our Spring Boot application up and running.

To simplify things, we’ll build a Spring Boot CRUD application with H2 as a database and no frontend.

3.1. Start New Project

First, we go to Bootify.io and click on the “Open Project” link. We’ll be greeted with options to start a new project or modify an existing one. We select the “Start new project” option to create a new project to begin the setup process:

bootify first page

Our new project can now be accessed via its unique URL.

3.2. Configure Project Settings

Now, we configure the basic details of our project, such as the project name, package structure, and any other general settings. Bootify provides a user-friendly interface to specify these parameters, ensuring that our project is set up according to our preferences.

We select Maven as the build tool and Java together with Lombok as the language. Also, we select H2 as a database. Bootify adds the necessary dependencies for our selected database.

bootify general 1

Further down in the developer preferences, we also activate the OpenAPI for documenting REST APIs:

bootify general 2

3.3. Define Our Domain Model

We can now create our database schema in the “Entities” tab. Bootify provides a graphical interface to define our application’s entities and their relationships. We can create entities, specify their attributes, and establish relationships between them, such as one-to-many or many-to-many associations.

bootify entity 1

We will create a simple database schema to manage Post and PostComment. Let’s create the Post entity:

bootify post

Also, we create the PostComment entity:

bootify postcomments

For each of the two entities, we activate the “CRUD Options“.

Now, we can create a relationship between two entities. There is a 1:N relation between a Post and a PostComment, so we create a one-to-many relation here:

bootify relationship

The below figure shows the entities, their properties, and the relationships between them:

bootify entities

3.4. Define Our Data Objects and Controllers

Next is “Data Objects” where we can define DTO’s and enums. Bootify adds a PostDTO and PostCommentDTO automatically.

The final section is for the “Controllers“. Bootify adds a PostResource and PostCommentResource automatically, which is just what we needed:

bootify controller

3.5. Generate Code

Once we’ve completed the configuration, Bootify will generate the corresponding Spring Boot code for us. This includes the necessary entity classes, repositories, services, controllers, and other boilerplate components required for our application.

We can use “Explore” to view all the generated files:

bootify preview

Also, we can download the generated project as a ZIP file.

4. Overview of Generated Code

After downloading the zip file, we can open it up in our favorite IDE (such as IntelliJ IDEA or Eclipse) to start working on it locally:

bootify intellij

Here’s a breakdown of the key components and files included in the generated code.

The domain component includes the entity classes. These classes are annotated with JPA annotations such as @Entity, @Id, and @GeneratedValue to map them to the corresponding database tables. Each entity class contains fields representing the defined attributes and getter and setter methods.

The repos component represents the repository interfaces. Bootify generates interfaces that extend JpaRepository, which provides built-in methods for CRUD (Create, Read, Update, Delete) operations. These repository interfaces enable database interactions without custom implementation for common database operations.

The service component is responsible for providing the service layer. The generated code includes service classes that encapsulate the business logic. These classes are annotated with @Service and often include methods to handle business operations related to the entities. Services interact with repositories to perform data access operations and implement additional logic when required.

The rest of the components contain the REST controllers. Bootify generates REST controllers annotated with @RestController and @RequestMapping to manage HTTP requests. These controllers map incoming requests to the appropriate service methods and return the correct responses. They include endpoints for CRUD operations and use annotations like @GetMapping, @PostMapping, @PutMapping, and @DeleteMapping to define their operations.

The model component includes the DTO classes. Bootify generates these classes to facilitate data transfer between the client and server. DTOs are used to structure the data returned by the API or received from the client, effectively decoupling the internal data model from the external API representation.

The config component consists of configuration classes such as SwaggerConfig and JacksonConfig. These classes manage settings related to API documentation and object mapping.

Finally, the application properties are defined in the application.properties or application.yml files, which manage application configuration. These files handle settings like database connection details, server port configuration, and other environment-specific properties.

5. Conclusion

In this article, we explored the Bootify application generator. With Bootify handling the routine setup, we can focus on building and enhancing our application’s core functionality rather than spending time on repetitive setup tasks.