Giter Club home page Giter Club logo

ktor-hexagonal-multi-module-template's Introduction

Ktor Ports and Adapters Multi Module Template

A dummy services that illustrates:

  • Ports and Adapters
  • Multi-module gradle kotlin dsl
  • Guice injection with Ktor

Testing

Run ./gradlew clean test to run all the tests

Running locally

Create the directory /app/lib/conf and add a file called 'jwt-secret.conf'

jwt.secret = 1234-1234-1234-1234

Run ./gradlew :app:run to run the service

Project Structure

This project follows a 'ports and adapters' (a.k.a. hexagonal) architecture and is divided into modules

Domain

The centre of the hexagon, contains core business logic.

Depends on

  • Ports

What goes here?

  • Classes and functions related to business logic.

What does not go here?

  • Transport layer concerns, e.g. JSON transformation,
  • Frameworks (arguable - but try to avoid)
  • Databases (arguable - but lets try to be pure)

Adapters

Everything outside the hexagon. Nothing related to business logic.

Depends on

  • Ports

What goes here?

  • JSON serializers/deserializers
  • REST clients
  • RabbitMQ senders/receivers (if applicable)
  • Framework code, e.g. ktor routes
  • DAOs, data layer

What does not go here?

  • Business logic

Ports

The 'ports' layer is the only way 'domain' and 'adapters' interact. It is divided into:

  • Provided (by domain)
  • Required (by domain

Depends on

  • Nothing

Provided ports

Interfaces (and data classes) implemented by the domain sub-project. The adapter layer uses this to communicate with domain code.

What goes here?
  • Interfaces for domain services

What does not go here?

  • Anything else

Required ports

Interfaces (and data classes) implemented by the adapters sub-project. The domain layer uses this to communicate with adapter layer.

What goes here?
  • Interfaces for remote services, message brokers, repositories, etc.
What does not go here?
  • Anything else

App

This layer can see all other layers and is responsible for bootstrapping the running application

Depends on

  • Ports
  • Adapters
  • Domain

What goes here?

  • The 'main method'
  • Framework configuration needed to glue the other layers together, e.g. initializing Guice modules
  • Build configuration needed to create a deployable service.

What does not go here?

  • Anything that otherwise fits into the 'ports', 'adapters' or 'domain' buckets

ktor-hexagonal-multi-module-template's People

Contributors

sgerber-hyperanna avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.