Giter Site home page Giter Site logo

braintelligencepl / project-manager-kotlin Goto Github PK

View Code? Open in Web Editor NEW
11.0 6.0 1.0 678 KB

🚀 From layered (n-tier) to hexagonal architecture with Kotlin. [WIP]

Home Page: http://www.braintelligence.pl/prawie-trywialna-aplikacja-do-zarzadzania-projektami/

Kotlin 66.74% Groovy 32.86% Shell 0.39%
architecture hexagonal-architecture hexagonal layered-architecture microservices-architecture tdd bdd integration-testing unit-testing kotlin

project-manager-kotlin's Introduction

Build Status 🛠

Journey from layered (n-tier) architecture to hexagonal architecture in Kotlin 💪

Project-Manager is a simple application for managing projects at company. You can create projects and teams. Projects can have features and status. Teams can have members and projects. You'll find more business requirments below.

We'll go from traditional layered architecture to hexagonal architecture A.K.A. Ports and Adapters architecture.


There is also newer repository with similar architecture style:


Quick Start

Working with Project-Manager

./gradlew bootRun - to run application.
./gradlew test - to run unit tests.
./gradlew clean build test- one to rule them all 💍

Start with endpoints. After that check tests. Whole domain is tested with unit tests. Isolated from controllers, database, framework. Tests are done with a use of repository implemented as HashMap. You also have AcceptanceTests that show user flow, bigger picture.


Implementation step-by-step

Idea is to see how does project changes while time passes. Each branch has some changes either refactor or new features implemented.


1️⃣ branch: step-1-team

🏠 Architecture: Layered Architecure

  • POST: /teams - create a team.
  • POST: /teams/:teamName/members - add members to the team.
  • GET: /teams - show teams.

Needs and constraints:

  • Team cannot be created if already exists
  • How many projects team has?

2️⃣ branch: step-2-projects

🏠 Architecture: Layered Architecure

  • POST: /projects/drafts - create project draft (only project name).
  • POST: /projects - create project with features. 📊
  • GET: /projects - show draft projects

Needs and constraints:

  • JobPosition must be valid (Developer, Scrum Master...)
  • Team can have no more than 3 projects at the time

3️⃣ branch: step-3-refactor

🏠 Architecture: Hexagonal Architecure

Things done:

  • Moving from layered (n-tier) architecture to Hexagonal Architecture (ports and adapters). 😎
  • Introduced idea of shared-kernel from DDD

Improved tests:

  • Unit tests without touching IO. Domain is tested with unit tests. Idea of InMemoryRepository as HashMap.
  • Acceptance tests show flow of the app or bounded-context.
  • Integration tests are only for most important business value paths because whole domain is tested with unit tests.

4️⃣ branch: step-4-projects

🏠 Architecture: Hexagonal Architecure

  • GET: /projects/:id - show project
  • GET: /projects - show projects
  • PUT: /projects/:id - change/update project
  • PATCH: /projects/:id/started - start project when team assigned
  • PATCH: /projects/:id/ended - close project when features are done

Needs and constraints:

  • No if statements! We can do better in Kotlin. Not something that you should avoid at any cost (its just a kata).
  • Project status and feature status -> Status must be valid (TO_DO, IN_PROGRESS...)
  • PriorityLevel for project features must be valid (HIGH, MEDIUM, NOT_DEFINED...)

#️⃣ branch: will-be-more

  • Refactor introducing simple CQRS.
  • monitoring, grafana, actuator, performance tests with gatling

branch: step-X-zoo-of-microservices

🏠 Architecture: Hexagonal Architecture (modularization on package level)
🕳 Tests: Integration/Acceptance/Unit
Backing-Services from Twelve-Factor-App methodology.

Services from our zoo:
🦓 user-autorization-service - authentication gateway that protects back-end resources. There is two kinds of resources protected and unprotected. First one requires user-level authentication and second one is just read-only such as listing of offers/products.

🐼 edge-service - gives possibility to expose unified REST API from all of ours backend services. To be able to do this, the Edge Service matches a request route’s URL fragment from a front-end application to a back-end microservice through a reverse proxy to retrieve the remote REST API response.

🐰 discovery-service - Edge-service matches a request route’s URL fragment from a front-end application to a back-end microservice through a reverse proxy to retrieve the remote REST API response.

🐿 centralized-configuration-server - Spring Cloud application that centralizes external configurations using various methodologies of building twelve-factor applications.


Technologies used:

  • Kotlin with spring
  • Spock (groovy) for tests
  • ArchUnit (kotlin) for architecture tests
  • Gradle to build project

Materials from mine blog:

Materials from outside world:

project-manager-kotlin's People

Contributors

braintelligencepl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

faelivrinx

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.