maple-syrup

command module
v0.0.0-...-b22ffeb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 12, 2021 License: Apache-2.0 Imports: 1 Imported by: 0

README


Logo

Maple Syrup API

Table of Contents

Project Structure

├── Maple Syrup                    
│   ├── api             # Functionality/features
│   ├── tests           # Testing endpoints  
│   └── main            # Run the application

The database used is PostgreSQL
Dockerize individually the app and the tests, simulating production database and testing database

Integration Guide

  • A Batch can be either dispatched or un-dispatched
  • A Batch is dispatched if it resulted in a Transaction being sent to the bank.
  • A Batch is un-dispatched if it didn't send a Transaction to the bank
  • There is exactly one un-dispatched Batch at any point of time
  • A Batch contains an accrued amount, with an initial value of 0
  • A User can send low volume amounts to a Batch and the accrued amount of the Batch increases
  • Once the accrued amount of the Batch goes above the threshold of 100, it gets dispatched. The created Transaction has a an amount equal to the accrued amount of the Batch
  • An history of all Batches, dispatched or un-dispatched must be kept

Step 1 When the application is firing up, it creates the first undispatched Batch and the User which is attached to

Step 2 Create a new User with only Name and keep the generated id

Step 3 Create a new Roundup with Amount and User id, and will automatically check the Undispatched Batch Summary

Step 4 If the Summary per Batch exceed 100, the Batch is being Dispatched and a Transaction with the Summary and the Batch id, is created

Step 5 A new Undispatched Batch with Summary 0 will be created which the next Roundups will be attached to, until the limit exceeds again

Step 6 The /batches?userid endpoint can be used to filter all the Batches per User related, with the parameter userid

Use the API

Endpoint
/users POST
/users GET
/roundups POST
/roundups GET
/batches GET
/batches GET ?userid=userid
/transactions GET

Clone the Application

git clone github.com/grokkos/maple-syrup.git

Run with Docker

Start up the application services by running:

docker-compose up

Call the API from http://localhost:8080

To stop the services run:

docker-compose down

Run the tests with Docker:

docker-compose -f docker-compose.test.yml up --build --abort-on-container-exit

Run the Application Locally

go run main.go

Clean tests cache if cached

go clean -testcache

Concurrent requests

ab - Apache HTTP server benchmarking tool is used

http://httpd.apache.org/docs/2.0/programs/ab.html WIP

Contributing

  1. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  2. Commit your Changes (git commit -m 'Add some AmazingFeature')
  3. Push to the Branch (git push origin feature/AmazingFeature)
  4. Open a Pull Request

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
api

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL