MaxonBank is a Kotlin + Spring Boot + Axon Framework application that supports opening, depositing to, and withdrawing from accounts.

Overview

MaxonBank

MaxonBank is a Kotlin + Spring Boot + Axon Framework application that supports opening, depositing to, and withdrawing from accounts.

The application is structured around the CQRS pattern. It has the following packages:

  • coreapi defines the basic shared interfaces: the commands, events, exceptions, and queries that are then used by the different parts of the application
  • command defines each Aggregate model with all of its command handlers, each applying its relevant business logic before publishing the relevant event
  • query defines a view and repository, which wraps the data and persistence of the model, as well as a projector, which maps the model's events to state changes in the repository in its event handlers, and also handles queries by serving relevant data from the repository.
  • web is responsible for the web interface to the application's functionality. It exposes endpoints to query and operate on the application's data through a RESTful interface. These endpoints hide the mechanics of the application's architecture, so consumers aren't required to know about CQRS, DDD, Axon Framework, etc.

Getting started

To run this application, you'll need

  • java 17 (try out asdf for managing toolchain versions if you don't have java 17)
  • a running Axon Server -- you can get it using docker or as a JAR

Once you've started the Axon Server, and it's running and accessible at localhost at the standard port, you can start the MaxonbankApplication at MaxonbankApplication.kt.

Then, hit http://localhost:8080/accounts. You should see an empty list in JSON. Check out web/AccountsController.kt for all the endpoints you can interact with.

Todos

  • Maintain a totalBalance value instead of calculating one on the fly
  • Add timestamps to LedgerEntries
  • Add tests (naughty me, I should have done this earlier :| )
    • test Account commands (src/test/kotlin/com/xtyrrell/maxonbank/command/AccountTests.kt)
    • test Account queries
      • This might a fair bit of tinkering work to get Axon integrations mocked or somehow test-ready. Obviously this would be invaluable for a production app, but I'm going to leave it for now.
    • test AccountsController
      • This also needs a bit of work to get set up. We'd want fixture data (sample Accounts and linked LedgerEntries) to work with in tests. We'd want this fixture data to be reset for each test. I'm going to leave this for now.

Notes

  • Traditional architecture has a service layer in between the interface layer (AccountsController for the web interface) and the data layer. Maxonbank does not have this, as Axon's queryGateway and commandGateway feel sufficiently abstracted, and I don't see any clear benefit to doing so. However, we could still consider this.
  • I think I should try to take the timestamps out of LedgerEntryView and put them instead inside the messages that prompt LedgerEntry creation, which would be a more accurate record of ledger entry timestamps.
  • Is there something we can do about having to use var so much instead of val (such as in Spring Data JPA entities)?
  • A lot of state is stored in the database instead of being event sourced. What are the tradeoffs of this? Would it be better to source all or more state from events? For example, the Account projection (query/AccountProjection.kt) stores all state in an AccountView Hibernate / Spring Data JPA @Entity.
    • It makes sense to me that storing unbounded data (like an account's ledger entries) in a DB is better than having it event-sourced for memory reasons. However, other data like balances I believe would work just fine with an event-sourced approach.
You might also like...
API for a library using Kotlin, Spring-boot and covered by test

Library API This API is to create Books and be able to borrow from them I'm using: Spring Boot version 2.5.6 Kotlin 1.5.31 Java 11 I'm implementing us

API Rest With Kotlin And Spring Boot

##API REST WITH KOTLIN AND SPRING BOOT GET Url: http://localhost:8080/customers Response (Status Code: 200 Ok) { "_embedded": { "customer

Spring Boot built using Kotlin, H2, Postgres, Hibernate and JPA

Spring-Boot-Kotlin-Sample Spring Boot built using Kotlin, H2, Postgres, Hibernate and JPA Getting Started Reference Documentation For further referenc

Grocery - A simple CRUD Project using Spring Boot, Kotlin and MongoDB

Grocery - A simple CRUD Project using Spring Boot, Kotlin and MongoDB

This repository demonstrates how Kotlin can simplify Spring Boot configuration properties file mapping

Kotlin spring-boot nested config props This repository demonstrates how Kotlin can simplify Spring Boot configuration properties file mapping @Constru

Generated with spring boot kotlin starter kit

Kotlin backend Generated with spring boot kotlin starter kit The idea is to: Get a microservice written in kotlin for managing users and roles. To be

Kotlin Based Spring Boot ETL project
Kotlin Based Spring Boot ETL project

Adverity ETL REST API (AERA) A simple ETL Spring Boot application with H2. This API provides the following basics functionalities: Endpoint that retur

Créer un microservice avec Spring Boot et Kotlin
Créer un microservice avec Spring Boot et Kotlin

🚀 Créer un microservice avec Spring Boot et Kotlin Ce dépôt contient les slides et la démo du talk "créer un microservice avec Spring Boot et Kotlin"

Cloud Bowl Sample - Kotlin Spring Boot

Cloud Bowl Sample - Kotlin Spring Boot To make changes, edit the src/main/kotlin/hello/KotlinApplication.kt file. Run Locally: ./mvnw spring-boot:run

Owner
Max
just cruising through cyberspace. he/him
Max
A very simple accounts application using Vert.x and Crabzilla

Accounts2 This is an example of an application using Vert.x and Crabzilla Status Work in progress Requirements Java 11 Maven Docker compose Running 1

rodolfodpk 2 Jan 12, 2022
Running Axon Server in Testcontainers tests.

Axon Server TestContainer Running axon server in testcontainers tests. Idea Run an Axon Server docker container from within your (junit) tests. Usage

holixon 3 Nov 21, 2022
The Okila server project uses the Spring boot framework and uses the Kotlin language

Okila-Server The Okila server project uses the Spring boot framework and uses the Kotlin language Format Response //The response successfully format

Nankai 1 Oct 25, 2021
Spring-graphql-getting-started - Spring for GraphQL provides support for Spring applications built on GraphQL Java

Getting Started with GraphQL and Spring Boot Spring for GraphQL provides support

Shinya 0 Feb 2, 2022
An application that simulate the Swedish Transport Agency, implemented with Spring Boot, Kotlin and GraphQL

graphql-kotlin-spring-server An application that simulate the Swedish Transport Agency, implemented with Spring Boot, Kotlin and GraphQL Running the s

null 0 Oct 31, 2021
Push notification application using One Signal + Spring Boot + Kotlin

Spring Boot push notification system using One Signal This project was created to demonstrate a simple application built with Kotlin + Spring Boot inc

Mário Fronza 3 Aug 30, 2022
Event-driven application uses React, reactive Spring Boot WebFlux, R2DBC, MySQL and Liquibase

Product delivery Event-driven application uses React, reactive Spring Boot WebFlux, R2DBC, MySQL and Liquibase Status: IN PROGRESS if [[ "" != `docker

Maksim Kostromin 2 Aug 17, 2022
A sample skeleton backend app built using Spring Boot kotlin, Expedia Kotlin Graphql, Reactive Web that can be deployed to Google App Engine Flexible environmennt

spring-kotlin-gql-gae This is a sample skeleton of a backend app that was built using: Spring Boot(Kotlin) Reactive Web Sprinng Data R2DBC with MYSQL

Dario Mungoi 7 Sep 17, 2022
Spring Boot Example with Kotlin and Domain Driven Design

Spring Boot Kotlin Domain Driven Design Example Just an example project where ddd is implemented with some other great patterns and architecture from

Fernando Guevara Sanchez 16 Jun 29, 2022
Sample Social Login Project of Spring Boot and Kotlin

Sample-Spring-Boot-Social-Kotlin Sample Social Login Project of Spring Boot and Kotlin dependencies dependencies { implementation("org.springframewor

Seokhyun 2 Oct 11, 2021