Skip to content

A microservice for VAT validation and currency conversion.

Notifications You must be signed in to change notification settings

rafikbelas/currensee

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

84 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Currensee - API Documentation

Table of Contents

  1. Introduction
  2. What's in the project
  3. Running the application 3.1 Build - test - package from the source code 3.2 Run using docker or docker-compose 3.3 Run the Docker image from DockerHub
  4. About the code

1. Introduction

This project is a microservice that serves the following API endpoints:

2. What's in the project

  • Source code that you can review.
  • A micro-service that you can build, test & run yourselves.
  • Documentation, where relevant.
  • Incorporation of software engineering best-practices and design-patters where relevant.
  • Test coverage to ensure code-quality.
  • Service running on port 8081.
  • BONUS: Autogenerated Swagger documentation.
  • BONUS: Dockerfile with multi-layer build and relevant README instructions.
  • BONUS: Incorporate embedded DB/caching for API endpoints.

3. Running the application

You can either run the application by building, testing and running the project from the source code, OR spin-up a container using docker and docker-compose, OR use the Docker image provided on DockerHub to run a container.

3.1. Build - test - package from the source code.

Prerequisites: Maven 3.6.1, Java 11

  • Download source code or clone it using git clone https://github.com/rafikbelas/currensee.git
  • Go to the project folder cd currensee
  • Run the following command mvn clean
  • Test the application by running mvn test
  • Run the application by running: mvn spring-boot:run. This will start the application on port 8081 http:https://localhost:8081/api/
  • To test the API endpoints, head to the auto-generated Swagger documentation

3.2. Run using docker or docker-compose

Prerequisites: docker ordocker-compose

  • Download source code or clone it using git clone https://github.com/rafikbelas/currensee.git
  • Go to the project folder cd currensee
  • Option 1 (Using docker-compose): Run the following command docker-compose up or docker-compose up -d. This will build a new image using the and spin-up a container.
  • Option 2 (Using docker): Run the following commands docker build -t currensee:latest . && docker run -dp 8081:8081 currensee. This will build a new image if not existant and run a container from it.
  • To test the API endpoints, head to the auto-generated Swagger documentation

3.3. Run the Docker image from DockerHub

Prerequisites: docker

  • Run the following command docker run -dp 8081:8081 rafikbelas/currensee. This will download the currensee image from the DockerHub and run it.
  • To test the API endpoints, head to the auto-generated Swagger documentation

4. About the code

Project packages:
  • controller : entry-point of each API. calls the appropriate service(s) with the received parameters and returns the corresponding response.
  • service : Services that hold the business logic, independently from external APIs, in case those are changed. Eventually calls other services in the service > api related to an external API.
  • service > api: Services that call external APIs, separated from business logic.
  • dto: Object responses returned by controller or received by external services.
  • validator: Custom validators
  • configuration : Custom configuration
  • exception: Custom exceptions and a GlobalExceptionHandler to handle all exepctions thrown by the controller.
External APIs:

The external APIs used are CurrencyLayer and CloudMersive. The CloudMersive API provides a ready SDK that was used in the service to call the API.

Error responses:

The GlobalExceptionHandler provides exception handling to each error thrown by the controller and returns a custom response with

  • status
  • message
  • timestamp
  • debug message (Optional)
  • subErrors (Optional): list of fields that cause the error.
    • field
    • rejecteValue
    • message

Errors regarding the external APIs and API Keys are returned as INTERNAL_SERVER_ERROR for now.

About

A microservice for VAT validation and currency conversion.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published