Giter Site home page Giter Site logo

rinha-v2's Introduction

Rinha Backend V2

Project developed to participate in the "Rinha de Backend V2" challenge. The objective of the challenge is to create an API for handle debit and credit transactions, using database and load balancer to manage two API instances, all in a limited way environment with 1.5vCPUs and 550MB of memory.

Technologies

Practices adopted

  • SOLID
  • API REST
  • Automated Tests [Unit Tests and Integration Tests]
  • Resource optimization
  • Queries with Spring Data R2DBC
  • Dependency Injection
  • Containerization with docker
  • Load Distribution with Load Balancer

Get started

In the project, an example environment variables file will be available. The project will start using it, if you want to change the database user and password, or some other value, feel free

  1. Clone git repository with modules

     git clone https://github.com/WeversonL/rinha-v2.git
     cd rinha-v2
    

Running the application with docker-compose

  1. Start with docker-compose

    docker compose -f docker/docker-compose.yml up -d

You can access the API via load balancer, sending requests to localhost:9999. Due to resource limitations, it is necessary to wait a while for the entire application to be up and running.

API Endpoints

The endpoints offered are based on those requested by the challenge!!

To make the HTTP requests below, the httpie tool was used:

  • Create a credit transaction
$ http POST :9999/clientes/1/transacoes valor=1000 tipo="c" descricao="Credit cash"

{
    "limite": 100000,
    "saldo": 1000
}
  • Create a debit transaction
$ http POST :9999/clientes/1/transacoes valor=1001 tipo="d" descricao="Debit cash"

{
    "limite": 100000,
    "saldo": -1
}
  • Obtaining customer statement
$ http GET :9999/clientes/1/extrato

{
    "saldo": {
        "total": -1,
        "limite": 100000,
        "data_extrato": "2024-02-22T16:36:08.250670122"
    },
    "ultimas_transacoes": [
        {
            "valor": 1000,
            "tipo": "c",
            "descricao": "Credit cash",
            "realizada_em": "2024-02-22T16:34:35.122608"
        },
        {
            "valor": 1000,
            "tipo": "d",
            "descricao": "Debit cash",
            "realizada_em": "2024-02-22T16:21:31.282657"
        }
    ]
}

License

Rinha Backend V2 is MIT licensed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.