Send your request Join Sii

In modern cloud computing, serverless architecture has been a buzzword, yet its practical applications often remain unexplored. This article aims to bridge this gap by demonstrating the development of a Price Tracker web application using serverless technology. Amidst the abundance of theoretical knowledge, the article focuses on a hands-on example to showcase how these concepts come to life in real-world scenarios.

Understanding serverless and AWS Cloud essentials

Serverless computing is a transformative cloud computing paradigm that enables developers to build and run applications without managing servers. It focuses on code, not infrastructure, allowing for agility and innovation.

AWS Cloud, a leader in cloud computing, offers a comprehensive ecosystem to implement serverless architecture effectively. Their suite of services includes:

  • AWS Lambda,
  • API Gateway,
  • and DynamoDB,

empowers developers to deploy scalable, highly available, and cost-effective applications. By leveraging AWS, the serverless concept transcends theory, offering a robust platform where it can be applied in the real world to solve complex problems and streamline operations.

About the app

The Price Tracker app is designed for those interested in observing how product prices change over time. It automatically follows the price changes, stores it in the database, and displays this information in visual graphs, offering a clear view of price trends. This tool is handy for educational or personal projects, highlighting the practical application of serverless technology in creating web applications.

Architecture overview

The architecture of the Price Tracker application, built on AWS, exemplifies a modern serverless design that leverages the power and flexibility of cloud resources. Below is a visual representation of the architecture, followed by a detailed explanation. 

The system operates through a series of coordinated actions between AWS services to track and manage data:

  • Tracking Lambda – this function is at the heart of the tracking operation. Its job is to gather and return relevant data about an item, including its value and timestamp.
  • EventBridge rule – AWS EventBridge is configured with a rule to trigger the Tracking Lambda function at regular intervals. This setup ensures that the item is tracked periodically, making the data collection process consistent and automated.
  • Handler Lambda – once the Tracking Lambda function gathers the data, the Handler Lambda function takes over. It processes this data and stores it in a DynamoDB table for persistence. In addition to storage, this function is also responsible for generating visual plots of the tracked data, which it then uploads to an AWS S3 bucket.
  • Gateway Lambda and API Gateway – the Gateway Lambda function interfaces with the AWS API Gateway, which acts as the front-end for user interactions. When a user requests the API Gateway, the Gateway Lambda function fetches and displays the relevant data and visualizations from the S3 bucket.
  • S3 bucket (public) – the S3 bucket is publicly accessible. This is essential as the API Gateway uses links from this bucket in HTML to display graphs on the webpage. The public setting allows all users to access and download these HTML-formatted graphs.

Hands-on

In this hands-on section, choose between two approaches:

  • manual setup of Price Tracker web app via the AWS Management Console (recommended) – the manual method through the console offers an in-depth, step-by-step understanding, while the script approach allows for a quick and automated setup,
  • a script-based deployment (experimental) – a script–based approach is for developers with at least basic knowledge of AWS.

Each provides a unique way to experience and interact with the application, catering to different preferences, experiences, and time constraints.

Regardless of which option we choose, the following steps need to be performed:

  1. Create policies.
  2. Create roles.
  3. Create a bucket (for more details, see section: Notes regarding S3 bucket).
  4. Create Tracking Lambda.
  5. Create Handler Lambda.
  6. Add Handler Lambda as a destination to Tracking Lambda.
  7. Add the EventBridge rule (start an event every two minutes).
  8. Create Gateway Lambda.
  9. create an HTTP endpoint, route, and integration in AWS Gateway.
  10. Test a page (it can take a few minutes until the graph is generated).

Requirements

  • Docker, install from docker.com.,
  • AWS Access AWS Management Console: link (Way 1).,
  • AWS CLI installed link and configured link (Way 2).

Notes regarding the S3 bucket

  1. The name of an Amazon S3 bucket must be unique across all existing bucket names in Amazon S3 not just within your own AWS account or a specific AWS region. It is a big chance that default name price-tracker-plots cannot be use. That is the reason why this name is customizable in app.config file. Keep S3 bucket name consistent in AWS environment and in app.config file. After changing app.config file, project should be re-builded.
  2. Bucket need to be public because end user needs to download graphs from it during loading a web page. It is always good practice to remove bucket or at least limit access to it when it is no longer necessary.

Way 1: AWS Management Console

  1. Download the repository: git clone [email protected]:czczajka/price-tracker-serverless.git
  2. Modify bucket name in app.config file (for more details see section: Notes regarding S3 bucket, point 1).
  3. Build all necessary artifacts: ./scripts/build.sh
  4. See the video and reproduce the steps:

Way 2: Automated, with AWS CLI (experimental)

In second method, we employ a script, which is using AWS CLI to do all the same work in automated way. the script is not yet mature and incorporates dirty hacks. Nice improvement will be get rid of those sleep commands. As an output from the script, you should receive url, where Price Tracker app is launched.

Note

To run successfully deploy_aws.sh and cleanup_aws.sh scripts you need to have AWS CLI access configured. In file policy/price-tracker-user.json is the example policy, which can be attached to the AWS user used for AWS CLI access.

  1. Modify bucket name in app.config file (for more details see section: Notes regarding S3 bucket, point 1).
  2. Run deployment script: ./scripts/deploy_aws.sh
  3. Go to the url (last line outputted from the script) and check if it is working correctly. It can take a couple of minutes before graph will be available.
  4. Run cleanup script: ./scripts/cleanup_aws.sh
  5. It’s good practice to check in AWS Management Console that all services has been removed correctly by cleanup script.

Summary

The article “Price Tracker: A Practical Dive into Serverless Applications” offers a hands-on guide to building a serverless price tracker using AWS. It covers serverless computing fundamentals, AWS Cloud essentials, and a step-by-step walkthrough of creating the application, from setting up AWS services like Lambda and DynamoDB to deploying the final web app.

The tutorial concludes by showcasing the web app interface and demonstrating the practical application of serverless technology in real-world scenarios.

***

If you’re interested in tool development in IT, also take a look at other articles by our authors.

4.9/5 ( votes: 7)
Rating:
4.9/5 ( votes: 7)
Author
Avatar
Cezary Czajka

Graduate of Computer Science at the Technical University of Lodz. He has many years of experience in developing software for IoT devices. He has been working at Sii as an embedded systems developer for more than half a year. He enjoys learning new technologies and then using them in practice. He spends his time after work reading books, mostly about psychology and economics, and playing sports. When there is a little more of this free time she uses it to explore the world

Leave a comment

Your email address will not be published. Required fields are marked *

You might also like

More articles

Don't miss out

Subscribe to our blog and receive information about the latest posts.

Get an offer

If you have any questions or would like to learn more about our offer, feel free to contact us.

Send your request Send your request

Natalia Competency Center Director

Get an offer

Join Sii

Find the job that's right for you. Check out open positions and apply.

Apply Apply

Paweł Process Owner

Join Sii

SUBMIT

Ta treść jest dostępna tylko w jednej wersji językowej.
Nastąpi przekierowanie do strony głównej.

Czy chcesz opuścić tę stronę?