Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend for managing User IDs #22

Open
ainsleys opened this issue Mar 27, 2020 · 15 comments
Open

Backend for managing User IDs #22

ainsleys opened this issue Mar 27, 2020 · 15 comments
Assignees
Labels
help wanted Extra attention is needed
Milestone

Comments

@ainsleys
Copy link
Contributor

ainsleys commented Mar 27, 2020

This server should store userID, email, and password, and enable users to log-in to their userID in the front-end application. It should also enable the front-end to submit the userID along with other user-submitted data via the SafeTrace API

@ainsleys ainsleys added the help wanted Extra attention is needed label Mar 27, 2020
@ainsleys ainsleys added this to the MVP milestone Mar 27, 2020
@cmalfesi
Copy link
Contributor

Hi @ainsleys ,
What architecture we should use here? I think would be good a nodejs + MongoDB working as Rest-API.

Questions:

  • It is possible that we use the Google sign-in service or we want to avoid using any external service that identifies the user?
  • I think we need to save more data like:
    createDate, agreeToBeNotified, typeOfUser? (reporter vs observer), testResults, testDate
  • User can report more that one test results?
  • Should save a log of every time that user report or upload positions?

@ainsleys
Copy link
Contributor Author

Hey @cmalfesi

That architecture seems reasonable to me!

re: questions

  1. I think I fall on the side of using google sign-in for the following reasons:
  • account recovery is simpler
  • bar for security for password management is higher (i.e., account security supports 2fa and authenticator apps)
    But, I would like to consult with @lacabra on the risks of this approach.
  1. can you let me know what each of these i.e. what data is expected (just to ensure 100% we're on the same page)?

  2. we think yes-- they can report with no test, and then update if they receive a positive or negative yes. Right now the utility isn't 100% clear, but i think makes the app more re-usable and generalizable for different interventions.

  3. probably. This can help us reduce spam or load on the system if required. Any reason not to @lacabra ?

Thanks @cmalfesi !

@cankisagun
Copy link
Contributor

@cmalfesi I think a google sign in is OK also happy to do MongoDB + node js

Regarding other data fields:

  • createDate (time + date) makes sense
  • agreeToBeNotified (0, 1) makes sense
  • type of user -> in the future we are planning to add symptoms as well so we may want to create a status for the user like 0 = not tested, no symptons, 1 positive, 2 high risk symptoms (no need to worry about 2 now)
  • test date (i.e 3/22/2020) yes. We can either add submission date for all other users

@cmalfesi
Copy link
Contributor

cmalfesi commented Mar 31, 2020

@cankisagun @ainsleys I will create an MVP of this issue during the day, I hope I can have something tomorrow.

@cmalfesi
Copy link
Contributor

cmalfesi commented Apr 2, 2020

FYI: I have forked this project and added a backend subfolder for add the User API endpoints.
I have pushed the first changes. I will be adding more endpoints today.
https://github.com/cmalfesi/SafeTrace/tree/be-express-mongodb-docker/backend

@cankisagun cankisagun assigned cankisagun and cmalfesi and unassigned cankisagun Apr 2, 2020
@FishmanL
Copy link

FishmanL commented Apr 3, 2020

Wait, why nosql for this? this seems like a classic case for relationality, maybe postgres?

@ainsleys
Copy link
Contributor Author

ainsleys commented Apr 3, 2020

@FishmanL a request for more context in your comment please, many people need to follow this (please note what advantages postgres would confer over current mongoDB solution). We're unlikely to modify anything for the MVP unless the case is really compelling, and afaik mongoDB works fine for this. Appreciate the input & the clarification!

@FishmanL
Copy link

FishmanL commented Apr 3, 2020

Sure -- so, mongo (and similar nosql solutions) are good when you have unstructured data, that you might need to modify within DB, and that doesn't need to scale to lots of users quickly.

In this case, you have very structured data, it's static once posted (all you're doing is adding new rows) and it needs to scale to lots of rows quickly. All 3 of these point to using SQL/a similar structured RDBMS, and with postgres it takes like 3 min to stand up a normalized schema for something like this (user table mapping user info to IDs, location table mapping user IDs to lat,long,time)

@ainsleys
Copy link
Contributor Author

ainsleys commented Apr 3, 2020

@FishmanL Just to be really clear, this server is only managing unique userID -> email, password . It should never deal with lat/long/time, that needs to be passed directly from client to the SafeTrace server running code in the TEE.

I'll let @cmalfesi make the call on what approach is sufficient for MVP, but I think we can optimize down the road. At the end of the day, this setup (database + loginAPI + frontend) is all part of the client app, which for our purposes is a prototype that demonstrates the SafeTrace API, so optimization is probably out of scope for the time being. Open to other perspectives, tho.

@FishmanL
Copy link

FishmanL commented Apr 3, 2020 via email

@lacabra
Copy link
Contributor

lacabra commented Apr 3, 2020

I concur with @FishmanL's assessment.

@cmalfesi
Copy link
Contributor

cmalfesi commented Apr 4, 2020

Hey @FishmanL , thanks for your feedback! You are totally right, I agree with you. I have proposed just a quick solution for start asap the MVP without having the perfect analysis of the data structure and how it will change in the path. In general, I like to use MongoDB for things that are not 100% defined and we can always change with fewer efforts, different the case that we have exhaustive analysis about how the data will be used.

@cmalfesi
Copy link
Contributor

cmalfesi commented Apr 4, 2020

@ainsleys @cankisagun I have uploaded the last changes on my Github on this branch:
https://github.com/cmalfesi/SafeTrace/tree/be-express-mongodb-docker/backend
Alaa will work with this and I will continue later.

@cmalfesi
Copy link
Contributor

cmalfesi commented Apr 6, 2020

Hi @ainsleys , @cankisagun

This PR includes:

  • Docker-compose to run MongoDB+NodeJS
  • API rest endpoints
  • Signup, login, user info
  • Support for login with Google sign up
  • Report test result

In the readme, you can find the instructions to run it locally.
Let me know if you need that I let it run in a test server somewhere.

@cmalfesi
Copy link
Contributor

cmalfesi commented Apr 6, 2020

Hi,
I have fixed an issue in the PR. This is the new PR.
#52

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants