rooteco / tweetscape

the supercharged twitter feed
https://prototype.tweetscape.co
GNU Affero General Public License v3.0
18 stars 2 forks source link

Design and develop iteration one mvp #393

Closed nicholaschiang closed 2 years ago

nicholaschiang commented 2 years ago

Imported from @nicholaschiang's original Linear issue TS-12.

From the README:

How it works

High level

Tweetscape uses hive.one to determine who are the most reputable (i.e. the "smartest") people in a specific field (e.g. who are the experts in ETH, BTC, NFTs, or Tesla) on Twitter; hive.one acts as a reputation layer for the internet, determining who you can trust through a weighted graph of who follows who (e.g. a reputable user following another user raises that other user's "attention score" by more than if some random Joe follows them).

Tweetscape then uses Twitter's API and that list of "smartest" people to get links to the articles most abundantly (and most recently) shared by the "smartest" people on Twitter for a given topic (e.g. ETH, BTC, NFTs, or Tesla). It also shows you the conversation around each link; you get to see the best links and what the smartest people are saying about them.

Low level

Tweetscape is a full-stack React application built with Remix and React Router.

Every 24 hours, when a user visits tweetscape.com, we:

  1. Fetch the top influencers from hive.one (using an ETag to de-dupe requests):

GEThttps://api.hive.one/v1/influencers/top

  1. Fetch the top 50 links that were most abundantly (and most recently) shared by those influencers on Twitter:

TODO: Figure out the best, most performant way to do this. Perhaps I'll setup a webhook or use some type of persistent storage to only query for changes (i.e. new Tweets) shared by our top influencers.

  1. Server-side render that list of links (and their corresponding conversations) to send to the client—you.

The aforementioned fetched data and generated HTML are both cached at the edge with Redis and SWR, respectively. We actually run the application at the edge too with Fly.io. One of our goals with Tweetscape is to save you time—primarily by rescuing you from Twitter's arbitrary wormhole of a feed—but also by optimizing our app to run even faster than Twitter, saving you milliseconds that you can then spend learning about the wisdom age 😎.

nicholaschiang commented 2 years ago

From @nicholaschiang on Monday, 2/28/22, 1:09 PM PST:

Iteration two:

Trying to run all of that with Cloudflare Workers probably isn't the best idea. I tried building it--and got something that kinda works--but working within Cloudflare's serverless constraints (e.g. max 50 subrequests--including cache calls--per worker invocation, max 16 recursive calls per worker invocation, etc) greatly hinders my ability to generate a complete truth dataset that accounts for every tweet (accessible from Twitter's API) from every influencer (from Hive's API). Thus, it's impossible to say if this whole Tweetscape algorithm would even work to surface useful "insider" information and articles. Currently, it kinda works for Tesla, but is quite low quality everywhere else (and even the links in the Tesla topic are greatly skewed towards a few reporting companies that write solely about Tesla).

I think iteration three would look something like:

nicholaschiang commented 2 years ago

From @nicholaschiang on Sunday, 2/27/22, 12:22 AM PST:

Update:

The aforementioned algorithm works OK for tesla, but isn't as effective for other topics.

nicholaschiang commented 2 years ago

From @nicholaschiang on Friday, 2/25/22, 11:27 PM PST:

See: https://tweetscape.nicholaschiang.workers.dev/tesla for WIP

nicholaschiang commented 2 years ago

From @nicholaschiang on Friday, 2/25/22, 11:27 PM PST:

Working fine right now; I'll need access to our custom domain name to further optimize performance (which is currently quite slow as I'm fetching data from both Hive and Twitter on each page load).

To optimize performance on Remix + Cloudflare:

To optimize performance on Next.js + Vercel:

Now that I've developed a basic working version, I'm actually thinking that this would be a perfect application for ISR. However, I'm also intrigued by Remix's blog post which demonstrates that hosting Remix entirely on the edge (e.g. on Fly.io or Cloudflare) is actually faster than Next.js ISR. However, as the time it takes to fetch page data and generate dynamic content increases, using ISR begins to make more and more practical sense. The attraction of Remix is based on the assumption that whatever APIs you're consuming in your loader function will respond in ms and not sec.