Skip to content

Case Study - Courier Tracking (Kotlin, Spring Boot, Mapstruct, JUnit Tests, Integration Tests, Docker, CI/CD - Github Actions, Gradle)

Notifications You must be signed in to change notification settings

Rapter1990/couriertracking

Repository files navigation

Case Study - Courier Tracking (Spring Boot - Kotlin)

Main Information

📖 Information

  • This project demonstrates a Spring Boot application for managing courier travel data. It logs courier locations, tracks travel distances, and manages interactions with stores within a specific radius.
  • The application incorporates various design patterns including Facade, Builder, and Strategy patterns, and provides endpoints for logging locations, retrieving travel data, and querying total travel distances.
  • Logging Courier Locations:
    • The application logs a courier's location details (time, latitude, longitude) whenever they enter within a 100-meter radius of a Store.
    • Reentries within one minute to the same store are not counted.
  • Querying Travel Data:
    • It provides endpoints to retrieve past travel data of couriers.
    • Includes filtering by store name and time range.
  • Calculating Travel Distances:
    • The application can calculate and return the total travel distance covered by a courier.

Explore Rest APIs

Endpoints Summary

Method Url Description Request Body Path Variable Response
POST /api/couriers/log-location Log courier's location. LogCourierLocationRequest None CustomResponse<String>
GET /api/couriers/travels/{courierId} Get past travels of a courier by courier ID. None courierId (UUID) CustomResponse<List<CourierResponse>>
GET /api/couriers/travels Get travels of a courier by courier ID, store name, and time range. TravelQueryRequest None CustomResponse<List<CourierResponse>>
GET /api/couriers/travels/{courierId}/total-distance Get total travel distance of a courier by courier ID. None courierId (UUID) CustomResponse<String>

Technologies


  • Kotlin
  • Spring Boot 3.0
  • Restful API
  • Mapstruct
  • Open Api (Swagger)
  • Gradle
  • Junit5
  • Mockito
  • Integration Tests
  • Docker
  • Docker Compose
  • CI/CD (Github Actions)
  • Postman
  • TestContainer
  • MySQL

Postman

Import postman collection under postman_collection folder

Prerequisites

Define Variable in .env file for product service and user service

DATABASE_USERNAME={DATABASE_USERNAME}
DATABASE_PASSWORD={DATABASE_PASSWORD}

Open Api (Swagger)

http://localhost:1231/swagger-ui/index.html

  • Gradle or Docker

Docker Run

The application can be built and run by the Docker engine. The Dockerfile has multistage build, so you do not need to build and run separately.

Please follow directions shown below in order to build and run the application with Docker Compose file;

$ cd couriertracking
$ docker-compose up -d

If you change anything in the project and run it on Docker, you can also use this command shown below

$ cd couriertracking
$ docker-compose up --build

Gradle Run

To build and run the application with Gradle, please follow the directions shown below;

$ cd couriertracking
$ ./gradlew clean build
$ ./gradlew bootRun

Docker Image Location

https://hub.docker.com/repository/docker/noyandocker/couriertracking/general

Screenshots

Click here to show the screenshots of project

Figure 1

Figure 2

Figure 3

Figure 4

Figure 5

Figure 6

Figure 7

Figure 8

Figure 9

Figure 10

Contributors

About

Case Study - Courier Tracking (Kotlin, Spring Boot, Mapstruct, JUnit Tests, Integration Tests, Docker, CI/CD - Github Actions, Gradle)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published