Phoenix/LiveView demo app: HackerNews Top 10

Hello All,

first time poster and very recent Elixir/Phoenix/LiveView fan here.

I present to you: HNLive, a Phoenix/LiveView web app showing the top 10 (by score or number of comments) newest HackerNews stories in “real time”.

You should find the app running on https://hntop10.gigalixirapp.com - please note that this is running on the free tier with limited memory and resources.

GitHub: https://github.com/gstipi/hnlive

My motivation for building HNLive was twofold:

  • I had read and heard many good things about Elixir, Phoenix and LiveView, and after watching Chris McCord`s demo “Build a real-time Twitter clone in 15 minutes with LiveView and Phoenix 1.5”, I finally said to myself: “That looks awesome, time to learn Elixir and Phoenix!” HNLive is the app I built over the last couple of days while on this learning journey, so don’t expect idiomatic or bug-free code - feel free to point out potential improvements!
  • I love browsing HackerNews, but for me the selection of stories on the front page, the “newest” page and the “best” page is not ideal if I want to see at a glance which new stories (say, submitted over the course of the last 12 hours) have received the most upvotes or are discussed particularly controversially (as judged by the number of comments). HNLive attempts to address this using data from the HackerNews API to provide the top 10 submissions, sorted by score or number of comments, taking into account only the last 500 submissions. I also wanted to see updates to the top 10 (and scores and number of comments) in real time, which was made easy by using LiveView.
10 Likes

:wave:

I love browsing HackerNews, but for me the selection of stories on the front page, the “newest” page and the “best” page is not ideal

Sorry for being off-topic, but you might find https://hckrnews.com useful.

1 Like

Thank you for this demo. It’s very nice to see the potential of LiveView in concrete use-cases and not only graphical demos.

2 Likes

That’s great! Good example how to get people interested in Elixir/Phoenix/LiveView!

Although next time ask me for help with the front-end design :wink: Or throw in something like Tailwind or UIKit micro css frameworks.

Next step: sentiment analysis of the comments (to sort by “most heated” discussions) using python’s TextBlob https://textblob.readthedocs.io/en/dev/ – any suggestions by more experienced colleagues how to plug this in? I assume very simple separate microservice via genserver or something? edit: here’s a repo of the sentiment analysis using twitter api, would be fairly easy to adapt: https://github.com/k2datascience/twitter_filter/tree/master/6_flask

1 Like

Thanks for the suggestion, I’ll explore the idea of adding sentiment analysis!

I think I could do a simple version without relying on an external dependency or API, there are many word lists available for that purpose, e.g. AFINN-165.

For the front-end design, I will gladly take you up on the offer, it’s certainly not my forte :wink:

I just sent you a pull request :wink:

2 Likes

Awesome, thank you very much! I really like the clean style and the Phoenix logo blends in perfectly!

I’ve merged the PR and deployed the new version to gigalixir.

1 Like