Count your money? Easy.
Implementation of distributed server system which tracks money transactions / balance summaries for high amout of users.
Technologies used:
- web-server: nginx
- client-server protocol: FastCGI (FastCGI-Daemon)
- database: MongoDB
- We don't care about numeration/sequence/timing of ids. So we expect server to generate them.
- I chose REST because my system well adapts to resource oriented paradigm.
timestamp
is Unix epoch time.
Returns list of accounts representations for specific user. Also provides overall balance for each used currency, e.g. if we have two accounts with 15$ and 25$ and three accounts with 20000BYR, 17000BYR, 13000BYR then we have 40$ and 50000BYR overall.
-
REQUEST
- URL:
/users/(user_id)
- Method:
GET
- URL:
-
RESPONSE
- Content-Type:
application/json
- Code:
200 HTTP_OK
- Body:
{ "user_id": "user123", "accounts": [ { "account_id": "abcdefg12345", "name": "Personal", "balance": "40", "currency": "USD" }, { "account_id": "abcdefg54321", "name": "Work", "balance": "50000", "currency": "BYR" } ], "overall": { "USD": "40", "BYR": "50000" } }
- Content-Type:
Returns list of accounts for specific user.
-
REQUEST
- URL:
/users/(user_id)/accounts
- Method:
GET
- URL:
-
RESPONSE
- Content-Type:
application/json
- Code:
- Success:
200 HTTP_OK
- Fail:
404 HTTP_NOT_FOUND
- Success:
- Body:
[ { "account_id": "abcdefg12345", "name": "Personal", "balance": "40", "currency": "USD" }, { "account_id": "abcdefg54321", "name": "Work", "balance": "50000", "currency": "BYR" } ]
- Content-Type:
Create account for specific user.
-
REQUEST
- URL:
/users/(user_id)/accounts
- Method:
POST
- Body:
{ "name": "Personal", "balance": "40", "currency": "USD" }
- URL:
-
RESPONSE
- Content-Type:
application/json
- Code:
- Success:
201 HTTP_CREATED
- Fail:
404 HTTP_NOT_FOUND
- Success:
- Headers:
- Location:
/users/(user_id)/accounts
- Location:
- Body:
{ "account_id": "abcdefg12345", }
- Content-Type:
Returns account representation.
-
REQUEST
- URL:
/users/(user_id)/accounts/(account_id)
- Method:
GET
- URL:
-
RESPONSE
- Content-Type:
application/json
- Code:
- Success:
200 HTTP_OK
- Fail:
404 HTTP_NOT_FOUND
- Success:
- Body:
{ "account_id": "abcdefg12345", "name": "Personal", "balance": "40", "currency": "USD", "transactions": [ { "transaction_id": "kjdsbkaljv342", "timestamp": "145235412341", "amount": "-40", "note": "Lunch at KFC." } ] }
- Content-Type:
Deletes spectific account.
-
REQUEST
- URL:
/users/(user_id)/accounts/(account_id)
- Method:
DELETE
- URL:
-
RESPONSE
- Content-Type:
application/json
- Code:
- Success:
200 HTTP_OK
- Fail:
404 HTTP_NOT_FOUND
- Success:
- Content-Type:
Adds transaction for specific account.
-
REQUEST
- URL:
/users/(user_id)/accounts/(account_id)/transactions
- Method:
POST
- Body:
{ "timestamp": "145235412341", "amount": "-40", "note": "Lunch at KFC." }
- URL:
-
RESPONSE
- Content-Type:
application/json
- Code:
- Success:
201 HTTP_CREATED
- Fail:
404 HTTP_NOT_FOUND
- Success:
- Headers:
- Location:
/users/(user_id)/accounts/(account_id)/transactions
- Location:
- Body:
{ "transaction_id": "kjdsbkaljv342" }
- Content-Type:
Deletes spectific transaction.
-
REQUEST
- URL:
/users/(user_id)/accounts/(account_id)/transactions/(transaction_id)
- Method:
DELETE
- URL:
-
RESPONSE
- Content-Type:
application/json
- Code:
- Success:
200 HTTP_OK
- Fail:
404 HTTP_NOT_FOUND
- Success:
- Content-Type: