/migroscouriertracking

Case Study - Migros One Courier Tracking (Java 21, Spring Boot, Mapstruct, JUnit Tests, Integration Tests, Docker, CI/CD - Github Actions, Maven)

Primary LanguageJava

Case Study - Migros Courier Tracking (Spring Boot - Java 21)

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>>
POST /api/couriers/travels/{courierId} Get travels of a courier by courier ID, store name, and time range. TravelQueryRequest courierId (UUID) 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


  • Java 21
  • Spring Boot 3.0
  • Restful API
  • Mapstruct
  • Open Api (Swagger)
  • Maven
  • 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:1226/swagger-ui/index.html

  • Maven 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 migroscouriertracking
$ 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 migroscouriertracking
$ docker-compose up --build

Maven Run

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

$ cd migroscouriertracking
$ mvn clean install
$ mvn spring-boot:run

Docker Image Location

https://hub.docker.com/repository/docker/noyandocker/migroscouriertracking/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

Figure 11

Figure 12

Figure 13

Contributors