tryunearth / rfcs Goto Github PK
View Code? Open in Web Editor NEWRFCs for changes to Unearth
Home Page: https://www.tryunearth.com
RFCs for changes to Unearth
Home Page: https://www.tryunearth.com
When a user first registers for Unearth and goes through the onboarding process, they sync their Reddit saves with our backend. This is a necessary step in order to generate the personalized newsletters that are delivered at the user's preferred frequency.
One issue, however, that is not addressed by the current architecture of Unearth is the ability to re-sync Reddit saves. For example, if an Unearth user has saved five new things and unsaved a couple others via any Reddit client, Unearth has no way of knowing about these changes. Thus, the Unearth and Reddit databases do not have parity.
This RFC outlines one method in which to achieve parity across the two services by utilizing a serverless function to compare changes in the two databases and save the normalized version.
TODO
It only makes sense for Unearth to have parity with a Redditor's saves on Reddit to continue using our service. Without it, eventually all of their Reddit saves will be surfaced and they will no longer need to receive their Unearth newsletter, unless they delete their account and re-register (in which case they will see many of the same emails).
I also think this is an interesting technical challenge to tackle, one I do not want to shy away from.
On the frontend client, we can offer a button to "re-sync Reddit saves" (or perhaps do it periodically using scheduled jobs). When clicked, an HTTP request would be sent to our main Express server which contains the REST API. An example request might look like:
POST /api/v1/reddit/sync
{
username,
id,
}
Our API would receive this request and then make a request of its own to the serverless function via another HTTP request, passing along the user's ID (to be used later).
The serverless function, once spun up and ready to do work, would then need to do the following tasks:
GET /api/v1/username/<username>/saved
requestdifferenceWith
method—see a basic example here: https://codesandbox.io/s/stupefied-shadow-wk8qeINSERT INTO…
statements (things the user has saved since joining Unearth)DELETE FROM…
statements (things the user unsaved since joinging Unearth)Once the above steps have been completed, the serverless function can spin down as now the Unearth database should mirror Reddit's into terms of the user's saved things.
The Detailed Design section outlines using serverless one-off functions. I'll be honest and admit that I'm not entirely sure how these differ from something like a job queue (like RabbitMQ or Bull for Node.js). From my preliminary research, the changes I have proposed appear manageable for either process (serverless or job/messaging queue). This is a big reason for creating this RFC—I do not know which strategy to adopt. Thus, any and all comments are greatly appreciated!
Alternatively, we could also just not offload the data computation and leave it on the main Express server. I'd imagine this would become a bottleneck but then again, maybe we shouldn't worry about scaling prematurely.
Being the sole developer of the project at this point, these changes would be widely adopted. If all goes well, we could even extend the serverless or job queue system to other tasks to improve scaling.
Documentation would be key and is my preferred method of teaching any new concept. Tests would also be highly beneficial.
General implementation / design is major blocker at this time. A discussion of how to accomplish this in the most cost-effective manner would be awesome.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.