Book Image

Building Applications with Spring 5 and Kotlin

By : Miloš Vasić
Book Image

Building Applications with Spring 5 and Kotlin

By: Miloš Vasić

Overview of this book

Kotlin is being used widely by developers because of its light weight, built-in null safety, and functional and reactive programming aspects. Kotlin shares the same pragmatic, innovative and opinionated mindset as Spring, so they work well together. Spring when combined with Kotlin helps you to reach a new level of productivity. This combination has helped developers to create Functional Applications using both the tools together. This book will teach you how to take advantage of these developments and build robust, scalable and reactive applications with ease. In this book, you will begin with an introduction to Spring and its setup with Kotlin. You will then dive into assessing the design considerations of your application. Then you will learn to use Spring (with Spring Boot) along with Kotlin to build a robust backend in a microservice architecture with a REST based collaboration, and leverage Project Reactor in your application. You’ll then learn how to integrate Spring Data and Spring Cloud to manage configurations for database interaction and cloud deployment. You’ll also learn to use Spring Security to beef up security of your application before testing it with the JUnit framework and then deploying it on a cloud platform like AWS.
Table of Contents (12 chapters)

What is your mission?

Your mission, as we mentioned, will be making a real-world application. What can be a better learning path than building real things from scratch through to production deployment? Our real-world application example will have a real theme!

We will create a REST application that will represent the application programming interface (API) for other applications. The theme for our application will be simple: management for user Notes and TODOs.

Imagine that there is a real-world mobile application that manages all these Notes and TODOs. That application will need a REST API so that all the data is synchronized to the backend. The story is simple. The user creates a Note or TODO. The user's mobile application then, at some point, does the synchronization. After some time, the user updates the content in it. Again, data is synchronized with the remote backend instance. Then, after a year, the user buys a new device that has a plain mobile application running. Luckily, the mobile application will synchronize with the remote backend instance again and get all the Notes and TODOs the user created.

So, what will this REST API do?

It will expose to the end user API calls for all Create, Read, Update, and Delete (CRUD) operations. The data we create or modify will be stored in the persistence layer. In our case, that will be MySQL database. Using Spring Security, we will create user roles so certain user profiles can do various things, such as creating the other users or modifying the main application content. To make things more interesting, we will create microservices responsible for various tasks.

Before we deploy, we will first test our code with the proper tests. We will also write unit tests. All tests will cover some of the core functionality so that our application is sufficiently stable to be deployed. We will deploy to Apache Tomcat and to Amazon AWS Elastic Beanstalk.