ArboreumDev / credit-union-frontend

Frontend in Next.js + Typescript + GraphQL
https://frontend-two-sandy.vercel.app
1 stars 0 forks source link

Finish adding DB schemas to Hasura #9

Closed gparuthi closed 4 years ago

gparuthi commented 4 years ago

From https://github.com/ArboreumDev/high-level-planning/issues/11

DB Schema:

users:

  1. id
  2. type (borrower, guarantor, lender) (enum)
  3. User's financial parameters:
  4. Max exposure (number)
  5. Min Rate of interest (number)
  6. trusted_borrowers (name, email)

balances

  1. owner_id
  2. liquid_cash: how much each agent has ready for future investments
  3. liquid_guarantor: how much is put aside (in escrow to be used in order to guarantee)

central_risk

data provided from the central source on the individual default risk

  1. user_id
  2. risk_params
  3. last_updated

recommendation_risk

each agent keeps a list of recommendation risks of their neighbours

  1. agent_id
  2. neighbor_id
  3. role enum=("trustor", "trustee")
  4. recommendation_risk [alpha, beta]
  5. last_updated

edges

weight

  1. head (type id)
  2. tail (type id)
  3. weight (credit extended from head to tail, type int)

loan

  1. loan_id
  2. interest
  3. status (open, success, default)
  4. created_at

loan_participants

  1. loan_id
  2. lender_id
  3. lender_amount

payables

  1. loan_id
  2. payable_type enum ['guarantee', lent]
  3. pay_from_user_id
  4. pay_to_user_id
  5. amount
  6. repaid
  7. default
djudjuu commented 4 years ago

we also need to store the user's balances somewhere:

specifically:

total amount in financePeer Wallet, subdivided as:

Whether it makes sense to put that into its own table or put it into users too, I am not sure

Also, probably in users: the information we get provided by the central source (eg. financepeer) on that persons risk. We need @gsVAM input on whether we actually want to store the values we get e.g. CIBIL, Adhar and then process them when used, or whether we can already process them into betaparameters and store those. So it would be

@gparuthi here are some insights from the journey-sessions & from finishing the risk-module

djudjuu commented 4 years ago

so I added those to Hasura. Do I need to do anything in the repo too? @gparuthi

Also, I decided at some points to change some small stuff (e.g. adding an id_field to the loan_requests, because it would have been tricky to define a primary key otherwise). Question: How should we document this? What will be our source of truth for the DB schemas. Just the hasura website?

djudjuu commented 4 years ago

Oh snap... i though i was editing my new issue, but instead I was here...now I cant undo it, so we might have lost what info there was previously....snap!!!