A Modern Kotlin-Ktor RESTful API example. Connects to a PostgreSQL database and uses Exposed framework for database operations. Focused on Software Architecture, SOLID Principles, dependency injection, testable code and feature based development.
- Ktor Framework
- Kotlin
- Dependency Injection -> Koin
- Authorization -> JWT
- Database -> PostgreSQL
- ORM SQL Framework -> Exposed
- Ktor Client -> For External API calls
- Build Tool -> Gradle
- Server -> Tomcat
- Docker support for containerization
- POSTMAN Collection for testing API
- Gradle 7, JDK (Amazon Coretto 11)
resources/application.conf
database {
exampleDatabaseUrl="jdbc:postgresql://localhost:5432/$YOUR_DB_NAME"
exampleDatabaseDriver="org.postgresql.Driver"
exampleDatabaseUser="$YOUR_USERNAME"
exampleDatabasePassword="$YOUR_PASSWORD"
}
GET /public-api/v1/healthCheck
Just returns a simple object
POST /public-api/v1/authentication/createUser
Registers a user to the db
POST /public-api/v1/authentication/login
Returns a jwt token if success
GET /api/v1/authentication/userInfo (Needs Authorization token from login as Authorization header : "Bearer
$token")
Returns the user information
GET /api/v1/star-wars/movie (Needs Authorization token from login as Authorization header : "Bearer $token")
An External API call example. Returns a movie information from an external api