(Go: >> BACK << -|- >> HOME <<)

Skip to content

srmds/clean-architecture-spring-kotlin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Clean Architecture - Spring - Kotlin

This is a simple hands-on Spring application demonstrating how to implement Clean Architecture (Uncle Bob).

You can find the accompanying slides, here.

This codebase utilizes injection, to easily swap the persistence gateway. Thus, by only swapping (injecting) another Gateway, one can go from in-memory persistence to a persistent storage (i.e. Mongo), see here, without changing anything else (domain models / logic ect). This accounts for the notion that a database is an implementation detail.

TODO's / Work In Progress (WIP)

Prerequisites

Note: this application comes with the Gradle Wrapper, therefore one does not need to install Gradle

Setup, build and run

  • Make sure prerequisites are met, then clone the repo:
$ git clone git@github.com:srmds/clean-architecture-spring-kotlin.git
  • Navigate to root of project, then:

Build the application

$ ./gradlew clean build --stacktrace

Run the application

$ ./gradlew bootRun --stacktrace

Clean Architecture

Seperation of concerns

Here you will find how the different layers have each own responsibilty, and which corresponding class is represented in each layer.

Use case

User Story

Register new Companies to an online platform.

In order to register a new company As a site admin I need to be able to register new companies

Requirements

  • A company must have a name

Scenario

  • Given that the company has approved to be listed on the public online platform

  • When I register the new arrived company with platform API

  • Then I should have a verification that the registration has succedeed and

  • And overall the new company is listed in the overview of

API Endpoints

GET /api/v1/companies

Response body

HTTP 200 OK

[
  {
    "name": "CompanyName",
    "website": "https://example.com",
    "missionStatement": "Lorum ipsum dolor...",
    "logo": "https://via.placeholder.com/50x50.png"
  },
  ...
]

POST /api/v1/companies

Request body

{
  "name": "CompanyName",
  "website": "https://example.com",
  "missionStatement": "Lorum ipsum dolor...",
  "logo": "https://via.placeholder.com/50x50.png"
}

Response body

HTTP 201 CREATED

{
    "id": "eb4cce9f-2055-444c-8a21-107c9c0cb410",
    "name": "CompanyName",
    "website": "https://example.com",
    "missionStatement": "Lorum ipsum dolor...",
    "logo": "https://via.placeholder.com/50x50.png",
    "registration": {
        "status": "ACCEPTED",
        "date": "2019-12-03 22:46:58"
    }
}

Resources

About

Clean Architecture example with Spring and Kotlin

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages