Skip to content

Commit 010bbc8

Browse files
committed
first commit
0 parents  commit 010bbc8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2987
-0
lines changed

.gitignore

+129
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/.gradle
2+
/.idea
3+
/out
4+
/build
5+
*.iml
6+
*.ipr
7+
*.iws
8+
### Gradle template
9+
.gradle
10+
/build/
11+
12+
# Ignore Gradle GUI config
13+
gradle-app.setting
14+
15+
# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
16+
!gradle-wrapper.jar
17+
18+
# Cache of project
19+
.gradletasknamecache
20+
21+
# # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
22+
# gradle/wrapper/gradle-wrapper.properties
23+
24+
### Kotlin template
25+
# Compiled class file
26+
*.class
27+
28+
# Log file
29+
*.log
30+
31+
# BlueJ files
32+
*.ctxt
33+
34+
# Mobile Tools for Java (J2ME)
35+
.mtj.tmp/
36+
37+
# Package Files #
38+
*.jar
39+
*.war
40+
*.nar
41+
*.ear
42+
*.zip
43+
*.tar.gz
44+
*.rar
45+
46+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
47+
hs_err_pid*
48+
49+
### Java template
50+
# Compiled class file
51+
52+
# Log file
53+
54+
# BlueJ files
55+
56+
# Mobile Tools for Java (J2ME)
57+
58+
# Package Files #
59+
60+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
61+
62+
### JetBrains template
63+
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
64+
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
65+
66+
# User-specific stuff
67+
.idea/**/workspace.xml
68+
.idea/**/tasks.xml
69+
.idea/**/usage.statistics.xml
70+
.idea/**/dictionaries
71+
.idea/**/shelf
72+
73+
# Generated files
74+
.idea/**/contentModel.xml
75+
76+
# Sensitive or high-churn files
77+
.idea/**/dataSources/
78+
.idea/**/dataSources.ids
79+
.idea/**/dataSources.local.xml
80+
.idea/**/sqlDataSources.xml
81+
.idea/**/dynamic.xml
82+
.idea/**/uiDesigner.xml
83+
.idea/**/dbnavigator.xml
84+
85+
# Gradle
86+
.idea/**/gradle.xml
87+
.idea/**/libraries
88+
89+
# Gradle and Maven with auto-import
90+
# When using Gradle or Maven with auto-import, you should exclude module files,
91+
# since they will be recreated, and may cause churn. Uncomment if using
92+
# auto-import.
93+
# .idea/modules.xml
94+
# .idea/*.iml
95+
# .idea/modules
96+
# *.iml
97+
# *.ipr
98+
99+
# CMake
100+
cmake-build-*/
101+
102+
# Mongo Explorer plugin
103+
.idea/**/mongoSettings.xml
104+
105+
# File-based project format
106+
107+
# IntelliJ
108+
out/
109+
110+
# mpeltonen/sbt-idea plugin
111+
.idea_modules/
112+
113+
# JIRA plugin
114+
atlassian-ide-plugin.xml
115+
116+
# Cursive Clojure plugin
117+
.idea/replstate.xml
118+
119+
# Crashlytics plugin (for Android Studio and IntelliJ)
120+
com_crashlytics_export_strings.xml
121+
crashlytics.properties
122+
crashlytics-build.properties
123+
fabric.properties
124+
125+
# Editor-based Rest Client
126+
.idea/httpRequests
127+
128+
# Android studio 3.1+ serialized cache file
129+
.idea/caches/build_file_checksums.ser

Docker

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM openjdk:8-jre-alpine
2+
3+
ENV APPLICATION_USER ktor
4+
RUN adduser -D -g '' $APPLICATION_USER
5+
6+
RUN mkdir /app
7+
RUN chown -R $APPLICATION_USER /app
8+
9+
USER $APPLICATION_USER
10+
11+
COPY ./build/libs/simple-gl-0.0.1-all.jar /app/simple-gl-0.0.1-all.jar
12+
WORKDIR /app
13+
14+
CMD ["java", "-server", "-XX:+UnlockExperimentalVMOptions", "-XX:+UseCGroupMemoryLimitForHeap", "-XX:InitialRAMFraction=2", "-XX:MinRAMFraction=2", "-XX:MaxRAMFraction=2", "-XX:+UseG1GC", "-XX:MaxGCPauseMillis=100", "-XX:+UseStringDeduplication", "-jar", "simple-gl-0.0.1-all.jar"]

README.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# simple-gl
2+
Simple general ledger application.
3+
4+
## Run instructions
5+
6+
1. Run `./gradlew build` command
7+
2. After successful build go to the `build/libs` directory
8+
3. Then run app using following command `java -jar simple-gl-0.0.1-all.jar`
9+
10+
## Two modes
11+
12+
Application logic implemented twice within two similar approaches.
13+
14+
The first approach kinda `actor` based.
15+
Programm state and all communications are handled by actors.
16+
17+
The second one is `eventstorming`.
18+
I have used `axon` framework to get beautiful `DDD` and `CQRS` out of the box.
19+
20+
The `actor` approach is active by default but you can switch it using ``MODE`` environment variable.
21+
Just set it to `axon` and run application.
22+
23+
## Project structure
24+
25+
Project code structured by following packages.
26+
27+
1. ``actor`` - Kotlin actor based approach
28+
2. ``axon`` - Axon based approach
29+
3. ``core`` - API that implemented in packages above.
30+
4. ``rest`` - REST API facade
31+
5. ``utils`` - Utility functions
32+
33+
## Public API
34+
35+
Examples of all queries could be found in ``resources`` folder.
36+
37+
### account
38+
39+
`POST /account` - Will create new account.
40+
41+
`GET /account/{id}` - Will return account balance.
42+
43+
`PUT /account/{id}/deposit` - Will deposit money to account.
44+
45+
`PUT /account/{id}/withdraw` - Will withdraw money from account.
46+
47+
### transfer
48+
49+
`POST /transfer` - Will create transfer with specified `{amount}` of money from `{from}` account id to `{to}` account id.
50+
51+
`POST /transfer/{id}` - Will return transfer status.

build.gradle.kts

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import org.jetbrains.kotlin.gradle.dsl.Coroutines
2+
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
3+
4+
val ktor_version: String by project
5+
val kotlin_version: String by project
6+
val logback_version: String by project
7+
val axon_version: String by project
8+
val javax_version: String by project
9+
10+
plugins {
11+
application
12+
kotlin("jvm") version "1.3.31"
13+
id("com.github.johnrengelman.shadow") version "5.0.0"
14+
}
15+
16+
group = "simple-gl"
17+
version = "0.0.1"
18+
19+
application {
20+
mainClassName = "io.ktor.server.cio.EngineMain"
21+
}
22+
23+
repositories {
24+
mavenLocal()
25+
jcenter()
26+
maven { url = uri("https://kotlin.bintray.com/ktor") }
27+
}
28+
29+
dependencies {
30+
compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version")
31+
compile("io.ktor:ktor-server-cio:$ktor_version")
32+
compile("ch.qos.logback:logback-classic:$logback_version")
33+
compile("io.ktor:ktor-server-core:$ktor_version")
34+
compile("io.ktor:ktor-server-host-common:$ktor_version")
35+
compile("io.ktor:ktor-jackson:$ktor_version")
36+
compile("org.axonframework:axon-configuration:$axon_version")
37+
compile("org.axonframework:axon-modelling:$axon_version")
38+
compile("javax.inject:javax.inject:$javax_version")
39+
testCompile("io.ktor:ktor-server-tests:$ktor_version")
40+
testCompile("org.axonframework:axon-test:$axon_version")
41+
}
42+
43+
kotlin.sourceSets["main"].kotlin.srcDirs("src")
44+
kotlin.sourceSets["test"].kotlin.srcDirs("test")
45+
46+
sourceSets["main"].resources.srcDirs("resources")
47+
sourceSets["test"].resources.srcDirs("testresources")
48+
49+
tasks.withType<Jar> {
50+
manifest {
51+
attributes(
52+
mapOf(
53+
"Main-Class" to application.mainClassName
54+
)
55+
)
56+
}
57+
}

gradle.properties

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
ktor_version=1.2.0
2+
kotlin.code.style=official
3+
kotlin_version=1.3.31
4+
logback_version=1.2.1
5+
axon_version=4.1.1
6+
javax_version=1
+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
distributionBase=GRADLE_USER_HOME
2+
distributionPath=wrapper/dists
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-bin.zip
4+
zipStoreBase=GRADLE_USER_HOME
5+
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)