The project
Server-side
This is a server-side JVM application for simple notes keeping (you can add and list notes via REST and gRPC) implemented in clean architecture in Kotlin.
Client-side
Check out according client-side app(s).
domain
and app-api
are Kotlin Multiplatform modules.
Install them to local Maven repository for the JVM clients:
./gradlew publishToMavenLocal
Generate CocoaPod specs for iOS clients (iOS simulator target only - iosX64
):
./gradlew podspec
Note: while Kotlin/Multiplatform is still experimental
-Xuse-experimental=kotlin.ExperimentalMultiplatform
compiler option is used.
The motivation
Here is a quick recap of the benefits that clean architecture brings:
- Independent of Frameworks
- Testable
- Independent of UI
- Independent of Database
- Independent of any external agency
You can find few more README.md files in subdirectories.
Clean architecture implementation
Find the classes in clean architecture diagram:
Building
Run using Spring:
./gradlew :app-spring:bootJar
or Quarkus:
./gradlew publishToMavenLocal
./mvnw clean compile quarkus:dev -f app-quarkus/pom.xml
Current Gradle support is not mature enough, so using Maven instead.
Testing
Unit/integration testing
One can find few unit tests that demonstrate some benefits of clean architecture for testing.
./gradlew test
./gradlew publishToMavenLocal
./mvnw test -f app-quarkus/pom.xml
Integration testing of app-spring-vaadin
is a bit tricky (one have to use commercial testing framework from Vaadin team Testbench
or
make Selenide
working with TestContainers
instead).
Manual testing
First, run the app from IDE or command line:
./gradlew :app-spring:bootRun
URLs
Add a note by navigating to URL as follows http://localhost:8080/api/add?title=title1&body=body1
:
List the notes by navigating to URL http://localhost:8080/api/list
Simple UI (Spring MVC + Thymeleaf)
Add a note at web page with URL http://localhost:8080/app/add
:
Make sure you can see added note (forwarded after adding) http://localhost:8080/app/list
Simple UI (Vaadin)
Make sure you've installed the modules into local Maven repo:
./gradlew publishToMavenLocal
Run the app from command line:
./mvnw spring-boot:run -f app-spring-vaadin/pom.xml
Add a note at web page with URL http://localhost:8080/app/add
:
Make sure you can see added note (forwarded after adding) http://localhost:8080/app/list
Frameworks and tools
- Kotlin, Kotlin/Native programming language
- Kotlin Multiplatform for multiplatform configuration/building
- IntelliJ IDEA IDE for coding
- Gradle with Kotlin DSL for building
- Maven for dependency management (for JVM clients, Quarkus and Vaadin)
- CocoaPods for dependency management (for iOS/macOS clients)
- ORMLite ORM for persistence
- H2 db engine for testing
- Spring Web for HTTP REST
- Spring MVC for Front end
- Thymeleaf for views templating
- Vaadin for Front end
- Spring Boot for bootstrapping
- Quarkus for AOT-compilation and bootstrapping
- GraalVM for AOT-compilation into native binaries with Quarkus
- Google Protocol Buffers and gRPC for RPC
- Travis CI for CI
Feedback
Any feedback and discussion is appreciated. Contact me on e-mail for this or fork the repository and pull a request.
Author
Anton Smirnov
dev [at] antonsmirnov [dot] name
2019