Skip to content

Latest commit

 

History

History
120 lines (116 loc) · 1.83 KB

README.md

File metadata and controls

120 lines (116 loc) · 1.83 KB

Dodo

Simple backend service for managing transactions and user accounts.

Demo link

Prerequisites

  1. Make sure you have cargo installed.
  2. Make sure you have PostgreSQL installed and it is up and running. Try using PostgreSQL 15 or later.
  3. You can optionally use psql to connect to the postgresql database.

How to run

  1. Create a database with the name dodo_payments.
$ psql
user=# create database dodo_payments;
  1. Start the application. It starts at port 3030.
$ cargo run
  1. Use the APIs listed in the next section via curl or a tool of your choice.

APIs and Features

The application provides the following features.

  1. User Management

Registration

POST /register

{
    "email": "[email protected]",
    "password": "testpass"
}

Response

User Added

Login/Authentication

POST /login

{
    "email": "[email protected]",
    "password": "testpass"
}

Response

"<authorization token>"
  1. Transaction Management

Credit amount

POST /credit

Content-Type: application/json
Authorization: <token>

Request

{
    "amount": 4.32
}

Response

{
    "ttype": "Credit",
    "amt": 4.32
}

Debit amount

POST /debit

Content-Type: application/json
Authorization: <token>

Request

{
    "amount": 1.50
}

Response

{
    "ttype": "Debit",
    "amt": 1.50
}

List transactions

  1. Account Balances GET /transactions
Authorization: <token>

Response

[
    {
        "id": 2,
        "ttype": "Debit",
        "amt": 1.50
    },
    {
        "id": 1,
        "ttype": "Credit",
        "amt": 4.32
    }
]

Get balance

GET /balance

Authorization: <token>

Response

{
    "amount": 2.82
}