Simple backend service for managing transactions and user accounts.
- Make sure you have
cargo
installed. - Make sure you have PostgreSQL installed and it is up and running. Try using PostgreSQL 15 or later.
- You can optionally use
psql
to connect to the postgresql database.
- Create a database with the name
dodo_payments
.
$ psql
user=# create database dodo_payments;
- Start the application. It starts at port 3030.
$ cargo run
- Use the APIs listed in the next section via
curl
or a tool of your choice.
The application provides the following features.
- User Management
POST /register
{
"email": "test@email.com",
"password": "testpass"
}
Response
User Added
POST /login
{
"email": "test@email.com",
"password": "testpass"
}
Response
"<authorization token>"
- Transaction Management
POST /credit
Content-Type: application/json
Authorization: <token>
Request
{
"amount": 4.32
}
Response
{
"ttype": "Credit",
"amt": 4.32
}
POST /debit
Content-Type: application/json
Authorization: <token>
Request
{
"amount": 1.50
}
Response
{
"ttype": "Debit",
"amt": 1.50
}
- Account Balances
GET
/transactions
Authorization: <token>
Response
[
{
"id": 2,
"ttype": "Debit",
"amt": 1.50
},
{
"id": 1,
"ttype": "Credit",
"amt": 4.32
}
]
GET /balance
Authorization: <token>
Response
{
"amount": 2.82
}