MM Cloud Api Documentation

MM Cloud API

The API for BFF (Back-end for front-end) and Importer Service (internal API, used by BFF or other internal services only)

Introduction

This is a document for MM Cloud Architecture and API.

BFF and Architecture

(Back-end for Front-end), a common name in micro service, in a common Micro Service architecture, only the BFF is used in Front-end application, all other internal service is hidden from internet, and be used in BFF or other services.

The two diagrams below are the comparison between general purpose api and BFF.

https://samnewman.io/pattern-img/bff/single-api.jpg

img

Currently, we probably have only on front-end client, there are only one BFF for now.

SQL Importer

As in the diagram above, Importer is one downstream service in the architecture, BFF or other services can directly talk to Importer.

It can transfer a SQLite3 db to a PostgreSQL db.

API

  • ? stands for optional
  • * must have

BFF

The current back-end entry point for out front-end app.

This document only cover the core features for the MVP.

Requirements

  • Provide CRUD for front-end app
  • Requires to be asynchronous
  • Authentication (after MVP, after all functional features work)

Endpoints

url METHOD Descrtiption
/transactions get get all transactions
post create a new transaction
/transactions/ get get one
put replace an existed transaction
patch update one
delete delete one
/accounts similar to the above
/categories
/subcategories

Example

  1. create a transaction

Use transactions as an example, similar to other models.

Request

The 3 parameters below, either one exist the API can work,

1
2
3
4
5
6
7
8
9
10
11
{
"TransCode": -1, // -1 withdraw, 1 deposit, 0 transfer
"AccountID": 1,
"ToAccountID": null, // only have value when transfer
"SubCategoryID": 1,
"CategoryID": 1,
"PayeeID": 1,
"Notes": "shopping",
"Amount": 100,
"ToAmount": 0, // be 0, if it is not transfer
}

Response

1
2
3
{
"id": 123
}

Models Examples

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
{
"transactions": [
{
"id": 1,
"TransCode": -1,
"AccountID": 1,
"ToAccountID": null,
"SubCategoryID": 1,
"CategoryID": 1,
"PayeeID": 1,
"Notes": "shopping",
"Amount": 100,
"ToAmount": 0
},
{
"id": 2,
"TransCode": 0,
"AccountID": 1,
"ToAccountID": 2,
"SubCategoryID": -1,
"CategoryID": -1,
"PayeeID": -1,
"Notes": "transfer to bank",
"Amount": 100,
"ToAmount": 100
}
],
"subCategories": [
{
"id": 1,
"Name": "Drink",
"Category": {}
}
],
"accounts": [
{
"id": 1,
"Name": "ANZ",
"Type": "Cash",
"CurrencyID": 1
},
{
"id": 2,
"Name": "BNZ",
"Type": "Cash",
"CurrencyID": 1
}
],
"payees": [
{
"id": 1,
"Name": "Kiwi House",
"Category": {},
"SubCategory": {}
}
],
"currencies": [
{
"id": 1,
"Name": "United States dollar",
"PFX_Symbol": "$",
"Symbol": "USD",
"Scale": 100,
"BaseConvRate": 1
}
]
}

We focus on transactions, categories, subcategories and accounts for the current stage.

Importer

  • Language: Python? JS? SQL (mainly sql)

Requirements

  • Transfer a SQLite3 Db to a Postgres DB efficiently
  • Better to be asynchronous(should be not a concern for the current stage)
  • Keep the tables and attributes the same as the original schema (google MMEX db schema)

Endpoints

There should be at least one endpoint

url Method descrition
/import post to import the SQLite3 DB to Psql DB

Example

Request

The 3 parameters below, either one exist the API can work,

1
2
3
4
5
{
db_path: [?a local sqlite3 db path],
db_binary: [?sqlite3 data as a binary file uploaded as requestt body],
s3_key: [?an AWS s3 resource key]
}

Response

1
2
3
{
db_name: [*a unique name for the db]
}

References