{"id":23119746,"url":"https://github.com/alisabzevari/kotlin-http4k-realworld-example-app","last_synced_at":"2025-08-17T00:31:56.975Z","repository":{"id":63773957,"uuid":"141314345","full_name":"alisabzevari/kotlin-http4k-realworld-example-app","owner":"alisabzevari","description":"realworld app implementation using kotlin, http4k and exposed","archived":false,"fork":false,"pushed_at":"2023-06-05T15:01:31.000Z","size":540,"stargazers_count":89,"open_issues_count":11,"forks_count":17,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-04T20:51:22.673Z","etag":null,"topics":["exposed","http4k","kotlin","kotlintest","mockk","realworld","realworld-backend"],"latest_commit_sha":null,"homepage":"https://github.com/gothinkster/realworld","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alisabzevari.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-07-17T16:14:43.000Z","updated_at":"2025-03-16T23:33:46.000Z","dependencies_parsed_at":"2024-12-17T05:41:03.911Z","dependency_job_id":"1aff778d-4383-4819-813e-b8466e5cc2ee","html_url":"https://github.com/alisabzevari/kotlin-http4k-realworld-example-app","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/alisabzevari/kotlin-http4k-realworld-example-app","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisabzevari%2Fkotlin-http4k-realworld-example-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisabzevari%2Fkotlin-http4k-realworld-example-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisabzevari%2Fkotlin-http4k-realworld-example-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisabzevari%2Fkotlin-http4k-realworld-example-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alisabzevari","download_url":"https://codeload.github.com/alisabzevari/kotlin-http4k-realworld-example-app/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alisabzevari%2Fkotlin-http4k-realworld-example-app/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270791255,"owners_count":24645781,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-16T02:00:11.002Z","response_time":91,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["exposed","http4k","kotlin","kotlintest","mockk","realworld","realworld-backend"],"created_at":"2024-12-17T05:41:00.248Z","updated_at":"2025-08-17T00:31:56.520Z","avatar_url":"https://github.com/alisabzevari.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ![RealWorld Example App](logo.png)\n\n[![Java CI](https://github.com/alisabzevari/kotlin-http4k-realworld-example-app/workflows/Java%20CI/badge.svg)](https://github.com/alisabzevari/kotlin-http4k-realworld-example-app/actions)\n[![codecov](https://codecov.io/gh/alisabzevari/kotlin-http4k-realworld-example-app/branch/master/graph/badge.svg)](https://codecov.io/gh/alisabzevari/kotlin-http4k-realworld-example-app)\n\n\u003e ### Kotlin + http4k codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the [RealWorld](https://github.com/gothinkster/realworld) spec and API.\n\nThis codebase was created to demonstrate a fully fledged fullstack application built with Kotlin + http4k + Exposed including CRUD operations, authentication, routing, pagination, and more.\n\nFor more information on how to this works with other frontends/backends, head over to the [RealWorld](https://github.com/gothinkster/realworld) repo.\n\n# How it works\n\nThe application was made mainly to demo the functionality of http4k framework together with exposed.\n\n## Tech stack\nThe application was built with:\n\n* [Kotlin](https://kotlinlang.org) as programming language.\n* [http4k](https://http4k.org) as web framework.\n* [h2](https://www.h2database.com/html/main.html), an embedded lightweight database, as data storage. Although the application can support all the databases supported by exposed.\n* [exposed](https://github.com/JetBrains/Exposed) to access database and build typesafe SQL queries.\n* [jsonwebtoken](https://github.com/jwtk/jjwt) to handle JSON Web Tokens for request authorization.\n* [log4j](https://logging.apache.org/log4j/2.x/) for proper logging in the application.\n* [kotest](https://github.com/kotest/kotest/) as testing framework for kotlin.\n* [mockk](https://mockk.io/) as mocking library for Kotlin.\n\n## Application structure\n\nBasically, the application has four main parts:\n* `main` function which instantiates all the services and handlers and connects them together, then starts the server.\n* `Router` class which handles the translation of 1. http requests to request handler calls and 2. handler results to http responses. Authorization logic is also implemented in this class.\n* `handler` package which contains a class for every request handler. Handlers are classes with one method (`invoke`) which handles the request. This package contains the whole business logic of the application. Handlers have access to data layer.\n* `ConduitRepository` class which is responsible for building database queries. In order to communicate to database, a class called `ConduitTransactionManagerImpl` is needed. this class has one method (`tx`) which connects to database and opens a transaction to communicate with database. `tx` accepts an anonymous function while provides an instance of `ConduitRepository` as a receiver.\n\n```\n+ config/\n    Application config as simple data classes\n+ handler/\n    All handler classes which describe business logic of the application\n+ model/\n    domain model and dtos\n+ repository/\n    table definitions, typesafe database creation scripts and classes to communicate with database\n+ util/\n    utility classes such as request filters, serialization/deserialization functions and jwt utility functions\n+ Main.kt\n    File containing main function\n+ Router.kt\n    File containing Router class responsible for handling http server communication\n```\n\n## Database\n\nThe application currently uses H2 embedded database. The connection is defined in `config/local.kt`. If you want to change the database you need to provide the correct dependency for the driver and change the configuration. \n\n## Tests\n\nYou can run `./gradlew test` to run all the tests. A test logger gradle plugin (`com.adarshr.test-logger`) has used to render the test beautifully in console.\nThere are a couple of unit tests for handlers but not for all of them (contributions welcome!).\nThere are integration tests to cover all the cases of the postman test file.\n\n# Getting started\n\nYou need Java 11 installed.\n\n**Build and run tests:**\n```\n./gradlew clean build\n```\n\n**Start the server:**\n```\n./gradlew run\n```\nThe server will be available on `http://localhost:9000`\n\n# Contribution\n\nThere are various ways to contribute to this project. Some of them are:\n* Just clone the project and play with it! This is the purpose of this project.\n* Create an issue if you find a bug or you have suggestions.\n* Fix bugs, improve code or documentation.\n* Write more tests for the project to increase the code coverage.\n* Or look at the issue with [help wanted](https://github.com/alisabzevari/kotlin-http4k-realworld-example-app/issues?utf8=%E2%9C%93\u0026q=is%3Aopen+is%3Aissue+label%3A%22help+wanted%22) label.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falisabzevari%2Fkotlin-http4k-realworld-example-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falisabzevari%2Fkotlin-http4k-realworld-example-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falisabzevari%2Fkotlin-http4k-realworld-example-app/lists"}