Just Write Code

Just Write Code
FootballMeme.net

One of the things we often lose sight of as marketing leaders in developer products and services is the importance of staying close to the actual code. It's so easy to get caught up in the maelstrom of our day jobs that we forget the reason we got into the industry to begin with: coding is really, really fun!

With copious time on my hands these days, I decided to get back into the thick of writing real applications. I've been using ChatGPT and Cursor to help, but they only get you about 25% of the way there. If you don't know how and when to refactor code, how and when to stop and look for more efficient ways of doing things, and how and when to challenge the AI as it spins in circles and gives you wrong advice, you can get stuck quickly. "Coding with words" shows much promise, but we're not there yet. You kinda still need to know what you're doing.

Not that I'm complaining about the AI tools. I'm a much faster developer than I was before. And I can do things now that would have taken me a few days of Googling. In that regard, I feel really sad for Google (not really). You know the end is near when even your barber talks about ChatGPT.

So anyway, what did I build?

Introducing FootballMeme

I love the NFL, and I miss watching games live now that I live in Portugal. I can usually catch the early Sunday games, but the later games and the Sunday Night, Monday Night, and Thursday Night games are at 1am here. I'm too old to stay up for that nonsense. And with the demise of Twitter, I have been struggling to keep up with NFL news.

So, I wrote FootballMeme, an NFL-focused homage to TechMeme, my favorite tech site.

FootballMeme.net

The tech stack

Building FootballMeme has given me a chance to learn about a bunch of awesome cloud services, as well as knock the rust off my coding skills. Here's my tech stack:

  • Vercel because all the hyperscalers are way too damn complicated and expensive. Vercel has a fantastic free tier for hobbyist projects.
  • Supabase is my database. Not just because I work there. It's awesome.
  • My stack is Next.js.
  • I use the OpenAI API.

Queues and cron jobs

I have a Supabase cron job running every 30 minutes that scrapes all the major American football sites for new articles and content. When it finds a link, it puts it on a Supabase queue.

I have a second cron job that runs every 30 seconds and dequeues one link from the Supabase queue and determines if it is a new link. If it is, it examines the domain and puts the link in a different queue. I maintain a queue for each domain (profootballtalk.com, espn.com, nfl.com, YouTube, etc.)

Each of these domain-specific queues has its own corresponding cron job. Every 15 seconds it checks the queue for new links and if it finds one, it dequeues the link and processes it.

Upon processing the link, I use the OpenAI API to identify the following based on the content of the article:

  • Players
  • Coaches
  • Owners
  • Teams

I then store the content of the article, an embedding (using pgvector) of the article, as well as all the players, coaches, owners, and teams associated with the article.

My front-end app then queries for the latest articles and displays the headline and tags. I also have a search bar in the front-end app so you can filter by players, coaches, owners, and teams.

Trending topics

A feature I miss a ton now that I've ditched Twitter is being able to see who is currently trending in the NFL. It was always an easy way for me to get caught up on what was happening right now.

So, I wanted to build a trending topics feed into FootballMeme.

  • Whenever a player, team, coach, or owner is mentioned, I ascribe some points depending on the context. For example, news about an injury is one point, but news about winning an award is nine points. These points are determined by using OpenAI to analyze the article's contents.
  • On top of that, every time someone clicks on an article, I add a point to the players, teams, coaches, or owners mentioned in the article.
  • Together with the publication date of the article or post, this helps me determine which players and teams are currently trending.

Trending topics are stored in Supabase. Using Supabase Realtime, and each time the database is updated, the front-end updates with the latest trending topics.

Social media

Now, the real magic of TechMeme is not just the article links but the related social media posts for each article. TechMeme shows you not only what is happening, but also what prominent people are saying about it. It’s a great filter on the noise of social media.

I wanted to build this feature as well, but this has proven much, much more challenging.

I can appreciate the human curation angle that TechMeme uses, but I don't have time for that as one person running a hobby project. So, I need to automate the process of finding social media posts, associating them with articles, and displaying the links to these posts with each article.

But automation has been impossible. I have no desire to pay Elon money for the Twitter API. And I'm disappointed that Threads doesn't offer a robust API for this purpose.

As a result, while the scaffolding is in place for my Python script to turn social media posts into pgvector embeddings in Neon, I can’t really do much with it now. Once I’m able to get social media posts at scale, I’ll be able to attach social media posts to all related articles.

For now, I can add the posts manually, and they'll be stored as embeddings. My periodic Python script will later associate them with an article, which you can see here:

Tweets associated with an article

Get to the code!

Overall, this has been a really fun exercise. I cannot stress enough the importance of stepping out of the submarine of work and looking around, breathing fresh air, and writing some real code.