Pollito Dev
December 29, 2023

Contract-Driven Development 2: Coming up with a practice scenario

Posted on December 29, 2023  •  3 minutes  • 596 words  • Other languages:  Español

Let’s create a simple application to put some ideas into practice.

Check the github repo

This is a continuation of Contract-Driven Development: Crafting Microservices from the Ground Up .

Everything we’ll do here, you can find in in the github repo.

Spring City Explorer - Backend: Branch feature/cdd-2

Sketch the app

After a very quick look at AnyAPI , I chose the APIs weatherstack and mediastack to consume in the test application. Creating a free account in both is quite simple and more than enough for our purpose.

So, what’s the app gonna do?

architecture Sorry for the image looking so small. Feel free to right click -> open image in new tab

Observations:

Let’s begin: Creating the Java Spring Boot Backend

Here’s the most difficult part, coming up with a name. After asking chatGPT for ideas, one stood out: SpringCityExplorer. So yep, now this is oficially The Pollito Spring City Explorer Project.

So now we go to Spring Initializr , and:

With all that, we are good to go, click on Generate, save the zip, extract wherever you want, open with your favourite IDE. Mine is IntelliJ IDEA 2021.3.2 (Ultimate Edition)

Spring Initializr

After opening the project, do a quick maven clean and compile. Any problems that appears here are probably due to some conflict related to Java in your pc, IDE, and/or a mix of both. Google is your best friend here.

If everything is ok, go to your main class (annotated with @SpringBootApplication), run, and we should be good to go.

After a few seconds, go to localhost and you should see an error message.

Spring default error

Now is a good moment to init a git, and close it up here. Next part we’ll create the OAS for the controllers to implement, and for the feign-client to extend.

Hey, check me out!

You can find me here