Skip to content

MatheusVict/Spring-Hexagonal-Architecture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Spring Hexagonal Architecture

This a task manager Spring Boot application using Hexagonal architecture with a low framework coupling that consumes Json place holder api

hexagonal architecture

Technologies used

Dependencies

  • Java - Version: 17
  • Spring - Version: 3.1.5
  • Maven - Version: 3.8.6 (Optional)

Getting start

OBS: First of all, look at application.yml and change the database configuration for yours

you can use this example:

jdbc:mysql://<your_database_host>:<your_database_port>/<your_database_name>?useSSL=false&serverTimezone=UTC

Running with javac

mvn clean install

After that:

java -jar target/hexagonal-0.0.1-SNAPSHOT.jar

Running with Maven:

mvn spring-boot:run

Running with docker:

docker build -t image_name .

After that:

docker run image_name

You'll see messagem saying it's running on port 8080 open your localhost:8080

How to run tests

mvn test

Http routes

Register a task

POST

/

Body:

{
  "title": "Play with TĂș",
  "description": "play with her bird",
  "completed": false
}

Retun:

{
  "id": 2,
  "title": "Play with TĂș",
  "description": "play with her bird",
  "createdAt": null,
  "completed": false
}

get a task

GET

/{taskId}

Retun:

{
  "id": 2,
  "title": "Play with TĂș",
  "description": "play with her bird",
  "createdAt": null,
  "completed": false
}

get all task

GET

/

Retun:

[
  {
    "id": 2,
    "title": "Play with TĂș",
    "description": "play with her bird",
    "createdAt": null,
    "completed": false
  },
  {
    "id": 2,
    "title": "Play with TĂș",
    "description": "play with her bird",
    "createdAt": null,
    "completed": false
  }
]

get additional information of a task

GET

/{taskId}/additionalInfo

Retun:

{
  "userId": 1,
  "userName": "Leanne Graham",
  "userEmail": "[email protected]"
}

Update a task

PUT

/{taskId}

Body:

{
  "title": "Play with TĂș",
  "description": "play with her bird",
  "completed": false
}

Retun:

{
  "id": 2,
  "title": "Play with TĂș",
  "description": "play with her bird",
  "createdAt": null,
  "completed": false
}

Delete a task

DELETE

/{taskId}

Retun:

Status 204

Problems faced

Problem 1:

Error on using this architecture because it's decoupled from framework

  • You need to do manual dependency injection

Next steps

Documentation with Swagger

About

🏗 An Spring API with Hexagonal Architecure

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages