Skip to content

Hiking Trail service using Java 11, SpringBoot and hexagonal architecture

Notifications You must be signed in to change notification settings

otaviosgoncalves/hiking-trail-java-hexagonal

 
 

Repository files navigation

Hiking Trail Service

Technologies

  • Java 11
  • Gradle
  • Springboot
  • Mongo DB

How to run

What do I need?

  • Docker compose
  • Makefile (optional)
  1. Using makefile, run
$ make start

This will build the dependencies (mongodb), build the app and run the containers all in one process.

  1. Seed the application's database
$ make seed-database

API Documentation

  1. See all trails:
GET /trails
  1. Find specific trail
GET /trails/trailName
  1. Book a trail
POST /booking
requestBody: 
{
  "trailName": "Shire",
  "bookingDetails": {
    "hikers": [
      {
        "name": "Christine",
        "age": 31
      },
      {
        "name": "Raul",
        "age": 27
      }
    ]
  }  
}

You will get a bookingId in the response. Save this for the next request.

  1. Find specific booking
GET /booking/bookingId
  1. Cancel a booking
DELETE /booking/bookingId

There is also a postman collection in the root folder with all of these requests.

Architecture Details

This service was built using the hexagonal architecture design pattern. You can see a diagram representing the application below:

hexagonal-architecture

The idea here is that we are decoupling the domain and use cases (services) of the application from the external world (infastructure inputs and outputs) by reversing the dependency order. The domain should not know anything about the external world. The dependency should go from: external -> application -> domain, this way we can keep it pure and be ready for changes.

About the tests

The application has around 30 tests, everything is covered. Two types of tests were made: unit and integration.

About

Hiking Trail service using Java 11, SpringBoot and hexagonal architecture

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 98.2%
  • Other 1.8%