Skip to content

raulinoneto/atm-withdrawal-analisys

Repository files navigation

ATM Withdrawal Analysis

Based in real coins with value 50, 10, 5, and 1, this api calculate how many coins will be used based on value.

Install Requirements:

  • docker 19 or latest
  • docker-compose 1.27 or latest
  • make command

Commands:

Unit test:
$ make test 
Run application:
$ make run-docker \\ Runs docker-compose with application image and its requirements
$ make run-docke-clean \\ Run a clean build image from docker application 

How to use

Open API Docs at ./docs/swagger.yml

/withdrawal

GET

Summary

Analise the coins for amount

Parameters
Name Located in Description Required Schema
amount query Pass the amount you want withdrawal Yes number
Responses
Code Description Schema
200 Complete analysis AnalysisResponse
400 bad input parameter

Models

AnalysisResponse

Name Type Description Required
amount number Example: 1987 Yes
coins Coins Yes

Coins

Name Type Description Required
1 integer Example: 2 No
5 integer Example: 1 No
10 integer Example: 3 No
50 integer Example: 39 No

Example:

  • [GET] http://0.0.0.0:8080/withdrawal?amount=1987
{
  "amount": 1987,
  "coins": {
    "1": 2,
    "5": 1,
    "10": 3,
    "50": 39
  }
}

Project Organization

Third Part Packages

Withdrawal Flow

The application will consult the redis before to analise the value.

Directory Structure

   ├── build ##Docker configuration
   │   └── docker
   │       ├── Dockerfile
   │       └── start.server.sh
   ├── config
   │   ├── container ## Injection Container
   │   │   ├── container.go
   │   │   └── container_test.go
   │   └── routes ## Routes
   │       ├── routes.go
   │       └── routes_test.go
   ├── docker-compose.yml
   ├── docs 
   │   ├── swagger.yml
   │   └── withdrawal.get.v1.plantuml
   ├── go.mod
   ├── go.sum
   ├── internal
   │   ├── httpserver ## net/http abstraction
   │   │   ├── errors.go
   │   │   ├── httpserver.go
   │   │   ├── httpserver_test.go
   │   │   └── responses.go
   │   ├── primary ## Primari ports
   │   │   └── v1.withdrawalhttp
   │   │       ├── withdrawal.go
   │   │       └── withdrawal_test.go
   │   └── secondary ## Secondary ports
   │       └── cache
   │           ├── redis.go
   │           └── redis_test.go
   ├── LICENSE
   ├── main.go
   ├── Makefile
   ├── pkg
   │   └── domain ## main logic
   │       └── v1.withdrawal
   │           ├── enum.go
   │           ├── service.go
   │           ├── service_test.go
   │           └── types.go
   ├── README.md
   └── tools
       └── logger
           ├── logger.go
           └── logger_test.go

Biography

  1. My Talk About Hexagonal Architecture
  2. Clean Architecture - Uncle Bob
  3. The Proposed Project Structure

License

MIT license

Releases

No releases published

Packages

No packages published

Languages