Stock price fluctuations have been quite common during the COVID-19 crisis. As an aspiring investor in financial markets, I've often felt the need to set price alerts for some of my favorite stocks to stay in-the-know. Alerting tools exist, but they're almost always tied to a specific broker like Robinhood or a specific corporation like Yahoo Finance, Bloomberg which requires you to go through many hoops (like signups, subscriptions, authentication, collecting user data etc) to be able to just use the simple alerting tool.

What it does

Alert me! is a lightweight, open-source tool that leverages AlphaVantage's ( free and open API to provide real-time stock price tracking and alerting capabilities. It is an attempt to streamline subscribing to alerts and requires no signups and tie-ups (just your email to send you the alert!). The tool allows you to set a price for which you would like an alert on a particular stock (similar to high limit orders and stop losses get triggered on exchanges).

For example, say the current price of TSLA is $820. If you were to set an alert for $750, you would receive an email notification when the price of TSLA falls to or below $750 (similar to a stop loss alert). If you were to set an alert for $900, you would receive an email notification when the price of TSLA hits $900 or more (similar to a limit order alert)

How I built it

The application is divided into 3 components: frontend, backend, and Redis datastore. The frontend talks to the backend via HTTP and REST protocols and the backend talks to Redis through the Redis Lettuce Client which exposes a neat set of APIs to leverage Redis data structures and streams.

For the frontend, I used node.js, javascript, jquery, and heavily used chart.js' financial graph to track stock prices.

For the backend, I used Java with a maven project structure and a few libraries (like Gson) for JSON parsing. The backend is laid out as two independent microservices: StockService and EmailService.


Exposes 2 frontend-facing APIs to query for current prices of a given stock and to create an alert for a given stock. Alerts are internally stored in Redis' sorted sets with a specific keys format (eg: TSLA#up, TSLA#down) with the user's target price as the score of the sorted set entry. This particular design was chosen to allow fast range queries (eg: "get all emails for current price $750 for which target price is > $750").

When an alert is triggered on the backend, email events with all the necessary metadata are pushed to a Redis queue using Redis Streams (pub/sub) to be consumed by the EmailService for real-time email notifications.


As mentioned, this service continuously monitors the email queue for incoming messages. Intuitively, streams seemed like a good fit for this use case since it is very likely the EmailService will be bombarded with email alert events for many users. For future work, simply adding more servers (horizontal scaling) for the email service can allow the service as a whole to consume many email messages at once improving throughput.

Challenges I ran into

Being a backend developer by profession, I found it initially daunting to design the frontend. However, once I got the stock chart working, I felt more confident about implementing the rest of the application.

Accomplishments that I'm proud of

I think the overall design of the application was quite good. Having separation of services like StockService and EmailService and an event-driven architecture made data management and coding a lot easier and enjoyable. I am also quite happy with how most of the Redis capabilities turned out!

What I learned

At a high level, I learned a lot about Redis, frontend code, and maven.

What's next for Alert me!

Future work will focus on:

  1. Alerts for foreign exchanges (eg: USD <-> CAD)
  2. Edit/Delete existing alerts via email threads and the website
  3. Integrations with Google's search API to allow users to create alerts when looking up information about a stock
  4. Facebook messenger bot integrations

Built With

+ 4 more
Share this project: