Skip to content

Spring boot kotlin implementation of realworld example.app

License

Notifications You must be signed in to change notification settings

raeperd/realworld-springboot-kotlin

Repository files navigation

RealWorld Example App

.github/workflows/build-and-deploy.yml Quality Gate Status Coverage Maintainability Rating

Spring boot kotlin codebase containing real world examples (CRUD, auth, DDD) that adheres to the RealWorld spec and API.

Demo     RealWorld

This codebase was created to demonstrate a fully fledged fullstack application built with Spring boot kotlin including CRUD operations, authentication, routing, pagination, and more.

For more information on how to this works with other frontends/backends, head over to the RealWorld repo.

Getting started

Run from scratch

$ ./gradlew bootRun

Using docker

$ docker run --rm -it -p 8080:8080 ghcr.io/raeperd/realworld-springboot-kotlin:master 

Run using MySQL as database

$ docker compose up 
  • Configure backend database with flyway
$ SPRING_PROFILES_ACTIVE=develop ./gradlew bootRun
  • Change profile to develop

Running tests

Using shell script

$ ./api/run-api-tests.sh

Using gradle test

$ ./gradlew test

How it works

  • Spring Boot for Web API implementations
  • Spring Data JPA for persistent layer
  • H2 and MySQL for actual database
  • Spring's HandlerInterceptor for security

Package Structure

./src/main/kotlin/io/github/raeperd/realworldspringbootkotlin/
├── domain
│   └── article
├── infrastructure
│   ├── jpa
│   └── security
│       └── jwt
└── web
    └── jwt
  • domain contains only domain logic without explicit dependencies
  • infrastructure contains implementation details with external dependencies
  • web contains API endpoints and spring web configurations

Design Principal

  • Maintain 90% of code coverages
  • Domain logics without external dependencies
  • Allow-list for endpoints rather than block-list for authentication
  • Reasonable database performance
    • Avoiding N + 1 query problems
    • Explicitly save entity

Performance

See Also

About

Spring boot kotlin implementation of realworld example.app

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages