Drone Service REST API in Spring boot

Overview

Drones Service REST API


📜 START

Introduction

There is a major new technology that is destined to be a disruptive force in the field of transportation: the drone. Just as the mobile phone allowed developing countries to leapfrog older technologies for personal communication, the drone has the potential to leapfrog traditional transportation infrastructure.

Useful drone functions include delivery of small items that are (urgently) needed in locations with difficult access.


Task description

We have a fleet of 10 drones. A drone is capable of carrying devices, other than cameras, and capable of delivering small loads. For our use case the load is medications.

A Drone has:

  • serial number (100 characters max);
  • model (Lightweight, Middleweight, Cruiserweight, Heavyweight);
  • weight limit (500gr max);
  • battery capacity (percentage);
  • state (IDLE, LOADING, LOADED, DELIVERING, DELIVERED, RETURNING).

Each Medication has:

  • name (allowed only letters, numbers, ‘-‘, ‘_’);
  • weight;
  • code (allowed only upper case letters, underscore and numbers);
  • image (picture of the medication case).

Develop a service via REST API that allows clients to communicate with the drones (i.e. dispatch controller). The specific communicaiton with the drone is outside the scope of this task.

The service should allow:

  • registering a drone;
  • loading a drone with medication items;
  • checking loaded medication items for a given drone;
  • checking available drones for loading;
  • check drone battery level for a given drone;

Feel free to make assumptions for the design approach.


Requirements

While implementing your solution please take care of the following requirements:

Functional requirements

  • There is no need for UI;
  • Prevent the drone from being loaded with more weight that it can carry;
  • Prevent the drone from being in LOADING state if the battery level is below 25%;
  • Introduce a periodic task to check drones battery levels and create history/audit event log for this.

Non-functional requirements

  • Input/output data must be in JSON format;
  • Your project must be buildable and runnable;
  • Your project must have a README file with build/run/test instructions (use DB that can be run locally, e.g. in-memory, via container);
  • Required data must be preloaded in the database.
  • JUnit tests are optional but advisable (if you have time);
  • Advice: Show us how you work through your commit history.

How to build

Requirements

  • Java 8
  • Java IDE (Eclipse)
  • MYSQL databse (Optional you can use in-memory databse)
  • Postman(For testing )

Steps by step for building and runing the project locally

clone.png

  • Open the cloned project in eclipse

  • Go to maven the update Project to update all the maven dependencies

  • Maven Build the project and run

  • Before running you can run the JUnit test cases to assert that everything is working correctly (I have included some of the JUnit tests)


Testing the API

  • Some of the assumption made for the purpose of this API design are:-

  • Once the Medication is loaded to a specific drone it cannot be loaded to another drone at the same time.

Open Postman For testing purpose the API is secured and you will have to specify the Authorization in the headers as Basic Auth

Username admin

Password admin

Note: the ContentType is application/json

basic-auth.png


  • Registering a drone localhost:8082/api/drone/register The payload should be in json format like this

reg-drone-payload.png

The response should be

reg-drone-response.png


  • Checking available drones for loading;

Before loading a drone with Medication you can first check the available drones to confirm that the drone is not in use

localhost:8082/api/drone/available

available.png


  • Loading a drone with medication items;

localhost:8082/api/drone/load

The payload will have the following fields

  • serialNumber is the unique serial for the drone being loaded
  • code id the unique code for the medication load being loaded to the drone
  • source is the loading point
  • destination is where the load is being taken

the Medication items to be loaded for testing are code : WE232344, WE232345, WE232346, WE232347, WE232348, WE232349, WE2323510, WE2323511, WE2323512, WE2323513

the destination and the source are any places

  • The serialNumber is the unique serialNumber a drone that you register

load-drone.png


  • Checking loaded medication items for a given drone;

localhost:8082/api/drone/details/Q23RT5676695

  • Check which medication item is loaded to a specific drone.

details.png


  • Check drone battery level for a given drone;

localhost:8082/api/drone/battery

battery.png


  • Delivery of medication item

localhost:8082/api/drone/deliver

When the drone delivers the item it call this end-point and its status is change drop loaded to delivering then delivered

deliver.png


📜 END

You might also like...

A simplistic configuration API

Config API This is just a simple configuration API I made a while back because I needed one, code is pretty outdated. Current Supported Data Types We

Nov 21, 2021

Drone - A service via REST API that allows clients to communicate with drones

Drone - A service via REST API that allows clients to communicate with drones (i.e. **dispatch controller**). The specific communication with the drone is outside the scope of this task.

Jan 10, 2022

Govern Service is a lightweight, low-cost service registration, service discovery, and configuration service SDK.

Govern Service is a lightweight, low-cost service registration, service discovery, and configuration service SDK.

Govern Service is a lightweight, low-cost service registration, service discovery, and configuration service SDK. By using Redis in the existing infrastructure (I believe you have already deployed Redis), it doesn’t need to bring extra to the operation and maintenance deployment. Cost and burden. With the high performance of Redis, Govern Service provides ultra-high TPS&QPS (10W+/s JMH Benchmark).

Nov 22, 2022

该仓库中主要是 Spring Boot 的入门学习教程以及一些常用的 Spring Boot 实战项目教程,包括 Spring Boot 使用的各种示例代码,同时也包括一些实战项目的项目源码和效果展示,实战项目包括基本的 web 开发以及目前大家普遍使用的线上博客项目/企业大型商城系统/前后端分离实践项目等,摆脱各种 hello world 入门案例的束缚,真正的掌握 Spring Boot 开发。

该仓库中主要是 Spring Boot 的入门学习教程以及一些常用的 Spring Boot 实战项目教程,包括 Spring Boot 使用的各种示例代码,同时也包括一些实战项目的项目源码和效果展示,实战项目包括基本的 web 开发以及目前大家普遍使用的线上博客项目/企业大型商城系统/前后端分离实践项目等,摆脱各种 hello world 入门案例的束缚,真正的掌握 Spring Boot 开发。

Spring Boot Projects 该仓库中主要是 Spring Boot 的入门学习教程以及一些常用的 Spring Boot 实战项目教程,包括 Spring Boot 使用的各种示例代码,同时也包括一些实战项目的项目源码和效果展示,实战项目包括基本的 web 开发以及目前大家普遍使用的前

Dec 30, 2022

Spring Boot Login and Registration example with MySQL, JWT, Rest Api - Spring Boot Spring Security Login example

Spring Boot Login and Registration example with MySQL, JWT, Rest Api - Spring Boot Spring Security Login example

Spring Boot Login example with Spring Security, MySQL and JWT Appropriate Flow for User Login and Registration with JWT Spring Boot Rest Api Architect

Jan 5, 2023

循序渐进,学习Spring Boot、Spring Boot & Shiro、Spring Batch、Spring Cloud、Spring Cloud Alibaba、Spring Security & Spring Security OAuth2,博客Spring系列源码:https://mrbird.cc

Spring 系列教程 该仓库为个人博客https://mrbird.cc中Spring系列源码,包含Spring Boot、Spring Boot & Shiro、Spring Cloud,Spring Boot & Spring Security & Spring Security OAuth2

Jan 6, 2023

Spring REST service built with Spring initializr and Spring Data.

Spring REST Service Generated with start.spring.io, using Spring Data. Documented using Spring REST Docs. Spring Initializr - Generate new Spring Rest

Jan 28, 2022

Spring Boot JdbcTemplate example with SQL Server: CRUD Rest API using Spring Data JDBC, Spring Web MVC

Spring Boot JdbcTemplate example with SQL Server: Build CRUD Rest API Build a Spring Boot CRUD Rest API example that uses Spring Data Jdbc to make CRU

Dec 20, 2022

CoSky is a lightweight, low-cost service registration, service discovery, and configuration service SDK.

CoSky is a lightweight, low-cost service registration, service discovery, and configuration service SDK.

High-performance, low-cost microservice governance platform. Service Discovery and Configuration Service

Nov 22, 2022

Rest.li is a REST+JSON framework for building robust, scalable service architectures using dynamic discovery and simple asynchronous APIs.

Rest.li is a REST+JSON framework for building robust, scalable service architectures using dynamic discovery and simple asynchronous APIs.

Rest.li is an open source REST framework for building robust, scalable RESTful architectures using type-safe bindings and asynchronous, non-blocking I

Dec 29, 2022

Spring JPA Many To Many example with Hibernate and Spring Boot CRUD Rest API - ManyToMany annotation

Spring JPA Many To Many example with Hibernate and Spring Boot CRUD Rest API - ManyToMany annotation

Dec 28, 2022

Automation Tests (REST-API with REST-ASSURED examples)

Automation Tests (REST-API with REST-ASSURED examples) Technology Stack IDEA Java Junit5 Gradle Selenide Allure Jenkins Rest-Assured See details: src/

Apr 11, 2022

The Quotation Management application is a API REST created using Spring Boot framework.

The Quotation Management application is a API REST  created using Spring Boot framework.

✅ Quotation Management API - Done ✅ About • Features • Setup • Technologies • Author • License 💻 About The Quotation Management application is a API

Apr 29, 2022

A template for Spring Boot REST API tested with JUnit 5 and Cucumber 6

demo-bdd Un template Spring Boot pour lancer un BDD/ATDD avec Cucumber 6 et JUnit 5. Maven et le JDK 17 seront nécessaires. Exécuter les tests Le proj

Jul 19, 2022

Spring Boot REST API authentication best practices using JWT

 Spring Boot REST API authentication best practices using JWT

Spring Boot REST API authentication best practices using JWT Token based API authentication with Spring Security and JWT (JSON web Token) Overview Thi

Dec 22, 2022

See how simple it is to build a REST API with a database using Java and Spring Boot

See how simple it is to build a REST API with a database using Java and Spring Boot

Seu primeiro projeto Java Web no Spring Boot 2022 Veja como é simples construir uma API REST com banco de dados usando Java e Spring Boot Realização D

Dec 26, 2022

Spring Boot Rest API unit test with Junit 5, Mockito, Maven

Spring Boot Rest API unit testing with Junit 5, Mockito, Maven Apply Spring Boot @WebMvcTest for Rest Controller Unit Test with JUnit 5 and Mockito. F

Dec 22, 2022

Web-based restaurant management system with spring boot and rest API for school final-year project.

Restaurant Management System Developing this for my school as first final year project. It shall be able to handle most of the challanges that encount

Mar 10, 2022
Owner
Moses-K
Moses-K
CoSky is a lightweight, low-cost service registration, service discovery, and configuration service SDK.

High-performance, low-cost microservice governance platform. Service Discovery and Configuration Service

Ahoo Wang 61 Nov 22, 2022
Annotation/Reflection Based Bukkit Command API. Containing many features such as help-service, command providers, tab completion, and many more!

CommandAPI Annotation/Reflection Based Command API that just does what you want it to do without any problems. Importing Maven <repository> <id>

damt 1 Jun 13, 2022
AWS Service registry for resilient mid-tier load balancing and failover.

Eureka Eureka is a REST (Representational State Transfer) based service that is primarily used in the AWS cloud for locating services for the purpose

Netflix, Inc. 11.6k Dec 30, 2022
Define Java service providers by annotating them directly

Annotated Service Provider Define JVM service providers by annotating the provider class directly. This annotation processor will add to the class-pat

Emily 5 Oct 31, 2021
Microserver is a Java 8 native, zero configuration, standards based, battle hardened library to run Java Rest Microservices via a standard Java main class. Supporting pure Microservice or Micro-monolith styles.

Microserver is a Java 8 native, zero configuration, standards based, battle hardened library to run Java Rest Microservices via a standard Java main class. Supporting pure Microservice or Micro-monolith styles.

AOL 936 Dec 19, 2022
LINE 4.1k Jan 2, 2023
Sample application demonstrating an order fulfillment system decomposed into multiple independant components (e.g. microservices). Showing concrete implementation alternatives using e.g. Java, Spring Boot, Apache Kafka, Camunda, Zeebe, ...

Sample application demonstrating an order fulfillment system decomposed into multiple independant components (e.g. microservices). Showing concrete implementation alternatives using e.g. Java, Spring Boot, Apache Kafka, Camunda, Zeebe, ...

Bernd Ruecker 1.2k Dec 14, 2022
KBE Spring Boot Microservices

SFG Beer Works - Brewery Microservices This project has a services of microservices for deployment via Docker Compose and Kubernetes. You can access t

John Thompson 29 Nov 2, 2022
Java client for Consul HTTP API

consul-api Java client for Consul HTTP API (http://consul.io) Supports all API endpoints (http://www.consul.io/docs/agent/http.html), all consistency

Ecwid 402 Jan 6, 2023