Skip to content

kazeka/nemiga

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Start codespace as per https://datasette.io/tutorials/codespaces

Setup the dependencies:

python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install -r requirements.txt
datasette install \
  datasette-vega \
  datasette-cluster-map \
  datasette-copyable \
  datasette-configure-fts \
  datasette-edit-schema \
  datasette-upload-csvs

Initialize the DB:

./preprocess.py

The script preprocess.py accepts a single filename as argument. The default is data.json, can also be used as ./preprocess.py data_new.json.

Start Datasette to view SQLite DB:

datasette mmm.db &

A popup inside codespaces web UI will ask to open Datasette at redirected port 8001.

Launch the FastAPI app at default port 8000:

uvicorn mmm:app --reload &

The app provides the following endpoints:

/
/docs
/get_level_for/{user_id}
/get_payouts_for/{user_id}

More info about the API is available at the /docs endpoint.

Need for clarification

I implemented skipping payouts for users with higher level but lower down the recommendation chain in pairwise manner. Is this the intention? An alternative would be to look at the chain as a whole.

Highlights of the implementation

Datasette provides an interface for exploring underlying SQLite DB. FastAPI was chosen for clarity and readability. NetworkX was chosen to represent the referential tree as directed graph because it provides sophisticated graph API. Future work includes adding endpoint to extend the referential tree by adding new users at the appropriate nodes, testing module, and refactoring (incl. DB).

Releases

No releases published

Packages

No packages published

Languages