# Battle-tested template project for backend with Kotlin and Ktor

DevFeed: [Battle-tested template project for backend with Kotlin and Ktor](<https://devfeed.tech/articles/battle-tested-template-project-for-backend-with-kotlin-and-ktor-24731.md>)

Original publisher: [Read original article](<https://medium.com/xorum-io/battle-tested-template-project-for-backend-with-kotlin-and-ktor-c655a2e276c2?source=rss----92bb7980cc9f---4>)

Author: Yev Kanivets

Published: 2021-07-16T05:24:17Z

Content type: tutorial

Language: en

Sources: [xorum.io - Medium](<https://devfeed.tech/sources/xorum-io-medium.md>)

Topics: [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Ktor](<https://devfeed.tech/topics/ktor.md>), [Template](<https://devfeed.tech/topics/template.md>), [mvc](<https://devfeed.tech/topics/mvc.md>), [Authentication](<https://devfeed.tech/topics/authentication.md>), [Authorization](<https://devfeed.tech/topics/authorization.md>), [Framework](<https://devfeed.tech/topics/framework.md>), [API](<https://devfeed.tech/topics/api.md>), [Firebase](<https://devfeed.tech/topics/firebase.md>), [Gradle](<https://devfeed.tech/topics/gradle.md>), [Heroku](<https://devfeed.tech/topics/heroku.md>), [Postman](<https://devfeed.tech/topics/postman.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [architecture](<https://devfeed.tech/tags/architecture.md>), [authentication](<https://devfeed.tech/tags/authentication.md>), [authorization](<https://devfeed.tech/tags/authorization.md>), [backend](<https://devfeed.tech/tags/backend.md>), [firebase](<https://devfeed.tech/tags/firebase.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [heroku](<https://devfeed.tech/tags/heroku.md>), [intellij](<https://devfeed.tech/tags/intellij.md>), [intellij-idea](<https://devfeed.tech/tags/intellij-idea.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [ktor](<https://devfeed.tech/tags/ktor.md>), [mvc](<https://devfeed.tech/tags/mvc.md>), [open-source](<https://devfeed.tech/tags/open-source.md>), [postgresql](<https://devfeed.tech/tags/postgresql.md>), [postman](<https://devfeed.tech/tags/postman.md>), [project](<https://devfeed.tech/tags/project.md>)

## AI overview

This article presents a personal Ktor template for Kotlin backend applications, describing its production use, project structure, tools, libraries, MVC-based architecture, API design, Heroku deployment files, and Firebase Auth integration.

## Source excerpt

With Kotlin and Ktor technologies gaining more popularity among the community of backend developers, dozens of different sample applications and templates are created and published as open-source projects. Ktor is an asynchronous framework for creating microservices, web applications, and more. It's fun, free, and open source. So it doesn't force any particular architecture, set of libraries, or framework to be used, which means that you are free to choose what's best for you and your project. Today, I'm finally ready to share my personal Ktor template, polished by almost a year of use in production applications. This article gives a short overview of the template, its architecture, chosen tools, and libraries. Tools Since we are using Kotlin to develop Ktor applications, pretty much any IDE compatible with Java/Kotlin should work. But the default choice is IntelliJ IDEA, of course. Community edition (free) will work just fine. Postman is a great choice for documenting, testing, and sharing your backend APIs. There are many similar tools. You can use cURL requests, for example. But always think about your API users first. What will be the most convenient for them, as they depend on you a lot. Structure Most of the Kotlin projects (including Ktor) are powered by Gradle, so they look quite similar. My template isn't different, with many Gradle-related files in the root and single src folder. Other files are related to Heroku deployment, but more on this later. Architecture Ktor isn't forcing you for any particular approach, so you are free to choose and implement the architecture that fits your needs best. In our case, we implemented classical MVC (Model -- View -- Controller) architecture with a public API instead of View and dedicated Interactors, which encapsulate all business logic related to each endpoint. Firebase Auth Most applications require some authentication and authorization business logic, so my template includes one of the possible implementations out of