Ktor Series : Repository Design Pattern using Ktor and Exposed

Vishwas Trivedi
5 min readDec 7, 2023

Software developers are no strangers to design patterns to make things handy or to complicate things for the next developer.

Jokes aside, today we will be taking look at how we can implement one of those design pattern that helps us to make our life easier : Repository Design Pattern. Repository design pattern is not a new design pattern but the language and framework that we are using today are relatively new.

  • Ktor is a newly introduced asynchronous framework for creating microservices, web applications and more. Written in Kotlin from the ground up.
  • Exposed is a lightweight SQL library on top of JDBC driver for Kotlin language. Exposed has two flavors of database access: type-safe SQL wrapping DSL and lightweight Data Access Objects (DAO).

Let’s not waste any more time, and jump straight into creating the project structure.

API project Structure

Let’s take a look at how we are going to structure out project in respect to repository design pattern. We are going to create API project as are are talking about Ktor and Exposed this time. Following is the high level directory structure of the backend applications.
(Sample repo. link is available at the end of the article)

--

--

Vishwas Trivedi

I am an accomplished Software Engineer/ Project Manager with 8.5 years of technical experience in driving successful software development teams.