Who is this for?
This course is for Kotlin and Android developers interested in learning how to use Kotlin on the server to build a web app and a web API. It expects you to be familiar with the Kotlin language and either Android Studio or IntelliJ IDEA. You'll also need basic knowledge of how HTTP works and have some experience with use of the command-line.
- Creating a Ktor web app
- Building a REST API with Ktor
- Type-safe routing in a Ktor app
- HTML Templating with FreeMarker
- Using Bootstrap with FreeMarker
- The Exposed SQL Library
- Using PostgreSQL with Ktor
- Session and Cookie Authentication
- JSON Web Token Authentication
- Deploying a Ktor app to Heroku
- Dockerizing a Ktor app
Part 1: Getting Started with Ktor
Let's introduce Server-Side Kotlin and Ktor, discuss our sample project, and review all that you'll be learning in the course.
You'll create a Ktor app from scratch in IntelliJ IDEA and add simple Hello World routes to the app.
In order to keep your code organized, you'll refactor the routes you've written so far so that each route has its own source file.
Test your knowledge about building app routes in Ktor by adding an about route to the web app, then see a solution.
Model and Repository
Add a repository interface and in-memory repository implementation in order to save model EmojiPhrases in between requests to the app.
API Post Endpoint
Create a POST endpoint to which you can send new EmojiPhrases, then test the endpoint using curl and a REST client app.
Add a GET route to the web app that will let you retrieve and see EmojiPhrases that have been add to the repository.
Introduce FreeMarker templating into the app and create a simple HTML page for showing your EmojiPhrases.
Review all that you've done in Part 1 of the course, and take a look ahead at where we'll be going in Part 2 and beyond.
Part 2: Beautification and Type-Safe Routing
See what we'll be covering in Part 2: adding basic authentication, using Bootstrap components for styling, and adding type-safe routing.
Install the Ktor Authentication feature into your app and add Basic Authentication to the POST route and GET route for phrases.
POST from the App
Build an HTML form to let users post new EmojiPhrases directly from the app instead of using other REST clients.
Get an introduction to the Bootstrap open-source front-end framework, and review the Bootstrap code that has been added to the app FreeMarker templates.
Setup static content in your Ktor web app, and complete the process of adding Bootstrap to the Home and Phrases pages of the app.
Test your knowledge of FreeMarker and the use of Bootstrap by completing the EmojiPhrases app About page, then see a solution.
Install the Ktor Locations feature into the app, then use the feature to switch to using type-safe routing.
Review all that you've done in Part 2 of the course, and take a look ahead at where we'll be going in Part 3 and beyond.
Part 3: Persistence and Sessions
See what we'll be covering in Part 3 of the course, adding true data persistence using Exposed and PostgreSQL and building in real authentication via sessions.
Exposed and H2
Add the Exposed SQL library framework from JetBrains into the app, and use it with an in-memory H2 database and with database connection pooling.
Switch from using H2 with Exposed to instead using PostgreSQL, adding true data persistence so that data is saved between different runs of the app.
Sessions Part 1
Learn about user authentication via cookies and sessions, understand the purpose of password hashing, and begin to add user sessions into the course app.
Sessions Part 2
Continue adding sessions into the course app by creating the code for the sign up and sign in pages of the app.
Sessions Part 3
Finish adding sessions into the app by checking for active sessions on the different pages of the app, and verifying a session when users post new data.
Review all that we've done in Part 3 of the course and take a look at where we'll be going in Parts 4 and 5.
Part 4: JWT Auth and the API
See what we'll be covering in Part 4 of the course, adding JSON Web Tokens for API authentication and completing a phrases API for the app.
Learn about JSON Web Tokens and how they are used, and then add a login endpoint from which API users can obtain a JWT.
Get Phrases API
Create a GET endpoint in the API from which API users can request the EmojiPhrases stored in the app repository.
Post Phrases API
Create a POST endpoint in the API to which API users can send new EmojiPhrases, and test adding data in the Postman REST client.
Review all that we've done in Part 4 of the course and take a look at where we'll be going in Part 5.
Part 5: Deployment
See what we'll be covering in Part 5 of the course, deploying our Ktor app to Heroku, creating a Docker image, and running the Docker image in a container.
Deploy to Heroku
See how to deploy your Ktor app to Heroku, connect Heroku to GitHub, and setup a PostgreSQL database on Heroku for your app.
Dockerizing the App
Add some build flags to support Dockerizing your Ktor app, then write a Dockerfile and use it to build a Docker image of the app.
Running with Docker
Run your Ktor app Docker image in a container, including connecting the app container to a Docker container running PostgreSQL.
Review all that you've done to build a deployable Ktor web app and API, both backed by a PostgreSQL database, and take a look at where to go from here.