Backend

You will find here how to configure a backend with Beagle.

Requirements

Before you integrate Beagle to your application to run it on the backend, it’s important to check out if you have installed all the current versions of the following programs:

  • JDK 8+ language (Kotlin 1.3+ is recommended)
  • Maven 3+

If you already have updated all the programs above, then just go to the following instructions.

Installation

Step 1: Create a micro-service

When you create a micro-service, it’s recommend to use your team’s established mechanisms. If that’s not your case, you can just follow the configurations below.

For a simple setup, you can choose between 2 frameworks to create your BFF:

Micronaut

A modern, JVM-based, full-stack framework for building modular, easily testable micro-service and serverless applications.

Spring

Spring makes programming Java quicker, easier, and safer for everybody. Spring’s focus on speed, simplicity, and productivity has made it the world’s most popular Java framework.

Once you choose the framework you’ll work with, proceed with the configurations below:

Creating a micro-service

Micronaut <= 1.3

As described on Micronaut’s quick start, create your application through a CLI tool with this command:

$ mn create app bff --build maven --lang kotlin

This will create an executable Micronaut project using Kotlin and Maven in a directory called bff. Open this project on the chosen IDE and follow the following steps to set the dependencies.

Micronaut >= 2.0

If you want to use Micronaut 2.0, you can use the new website, very similar to Spring.

Micronaut Launch with recommendation to start a Beagle project with Micronaut

  • This configuration uses:
    • Kotlin with Maven forJava 8 (compatible with this version);
    • Junit like the unit tests library.
  • Unzip the file and open the extracted folder in your IDE.

Create a micro-service

Use Spring’s Initializr to create a project for your micro-service. Click the following link, Spring Initializr for Beagle Spring Starter, to get recommended settings.

Spring Initializr with recommended settings for a BFF with Spring, using Beagle Spring Starter

  • These settings are:
    • Maven dependency manager;
    • Kotlin with JAR packaging and Java 8+ compatibility;
    • Spring Boot Actuator dependency.
  • Click GENERATE to download a zip file containing your project.
  • Unzip the file and open the extracted folder in your IDE.

Step 2: Include starter dependency

Lastly, you have to add the dependency for the Beagle starter to your backend. In that case, the framework you chose will define the dependency’s name (artifactId) should be done.

Click on the tab of the framework you’re using and follow the steps to continue the configuration.

Additional Requirements:

  • Beagle’s current release version is: back

Maven configuration

To follow this requirement, you just have to add the dependency below to your pom.xml.

<dependency>
	<groupId>br.com.zup.beagle</groupId>
	<artifactId>beagle-micronaut-starter</artifactId>
	<version>${beagle.version}</version>
</dependency>

Gradle configuration

For projects configured with Gradle, just add the starter dependency in your build.gradle or build.gradle.kts file.

dependencies {
  implementation("br.com.zup.beagle:beagle-micronaut-starter:${beagle.version}")
}

Additional Requirements:

  • Beagle’s current release version is: back

Maven configuration

To follow this requirement, you just have to add the dependency below to your pom.xml.

<dependency>
	<groupId>br.com.zup.beagle</groupId>
	<artifactId>beagle-spring-starter</artifactId>
	<version>${beagle.version}</version>
</dependency>

Gradle configuration

For projects configured with Gradle, just add the starter dependency in your build.gradle or build.gradle.kts file.

dependencies {
  implementation("br.com.zup.beagle:beagle-spring-starter:${beagle.version}")
}

Insert the Beagle’s release version on the place of${beagle.version}, in other words, put the Beagle’s version highlighted in blue badge above without the v character.

For example:

-ext.beagle.version = "1.5.1"

Well done, your initial configuration is ready to be used!

You can check a screen or server-driven component to test the BFF.

You can see more of how to use Beagle on the backend or how to test a BFF with server-driven components.

Next Steps

On this section, you made Beagle’s initial installation on your application!
Now, to keep configuring Beagle:

👉Go to initial configurations to enable the use of Beagle on your Web project.

👉 If you want to go straight to practice, access our tutorial to create a projeto from zero.