Taxonomy Icon

Containers

Design a step-tracking app with Kitura and Kubernetes

Get the code

Summary

Full-stack development can be tough. When you code in different languages and frameworks, things can get messy. When Swift was open-sourced, many things changed, but the biggest change was that Swift allowed iOS developers to fully code their back end with Swift. Kitura is one of the powerful server-side Swift web frameworks that helps developers concentrate and spend more time in the logic of their application. Kitura can also be deployed in Kubernetes and be exposed on a public domain to act as an iOS app’s back-end infrastructure.

Description

In this pattern, we’ll create an iOS step-tracking app by using Swift. The application’s back end will also be written in Swift with the use of Kitura, a server-side web framework for Swift. This pattern is for iOS developers who want to write both their front end and back end in one language. Working in one language helps developers concentrate and spend more time in the logic of their application, rather than learning or dealing with another programming language. The three simple Kitura microservices will be deployed in Kubernetes, a container-orchestration platform. The sample iOS app is a step tracker that rewards users with “fitcoins.”

When you’ve completed this pattern, you will understand how to:

  • Build a server-side Swift application with Kitura.
  • Use Kitura with Swift Kuery to connect to a database.
  • Deploy Kitura microservices in Kubernetes.
  • Integrate an iOS app with the Kitura back end.
  • Make Kubernetes available under a public domain with TLS.

Flow

flow

  1. The first time the iOS app opens, it tries to register through the “Users” microservice.
  2. The “Users” microservice communicates with an external service for its avatar assignment to users.
  3. The “Users” microservice then persists all users’ info in the database. The &Users& microservice also updates the steps of the user and awards &fitcoins.&
  4. The “Leaderboard” microservice provides a way to give standings to the users with their steps count, based on the stored data in the database.
  5. The “Shop” microservice gets the products from the database where users can exchange them with their “fitcoins.” This is also where the APIs (for creating the transactions) update users’ fitcoins.”

Instructions

Ready to put this pattern to use? Complete details on how to get started running and using this application are in the README.