Build Interactive Data Apps: Streamlit + Snowflake on AWS (Part 1)

Data Engineering Blogpost
5 min readFeb 6, 2024

--

  • Do you dream✨ of building interactive web apps for data analysis, even without extensive web development experience?
  • Want to deploy your data-driven creations to the cloud, making them accessible from anywhere?

If you answered Yes to any of these questions, you’ve arrived at the perfect destination! 🌟 This is where our exciting project comes into play.

Project overview📊💡

In this project, our goal is to create a web app using Streamlit that analyzes online retail data loaded from a Snowflake table. We’ll walk you through a step-by-step process, demonstrating how to deploy this Streamlit app onto an AWS EC2 server 🚀. This hands-on journey ensures that by the end, you not only have a functional data analysis tool but also the knowledge to extend its reach to the vast cloud canvas of AWS EC2☁️.

Project Architecture🛠️🏗️

Project Architecture
  • Streamlit Web App: This is the user interface where data analysis and visualization will take place.
  • Snowflake Database: The source of our online retail data, enabling us to efficiently retrieve the required information.
  • AWS EC2 Instance: The cloud server where our Streamlit app will be deployed, providing accessibility from anywhere in the world.

Join us on this innovative and exploratory journey! ✨

Prerequisites

  1. AWS Account ☁️: An AWS account is necessary for deployment. You can obtain a free trial version with a debit or credit card.
  2. Snowflake Account ❄️: Obtain a free 30-day trial of Snowflake using your Gmail account. For step-by-step instructions, refer to this blog.
  3. Python Installed 📄: Ensure Python is installed on your machine to run the project scripts and dependencies.
  4. Git Bash 🖥️: Make sure Git Bash is installed on your machine.

What you’ll learn from this blog🤔:

  • Create a Streamlit web app for data visualization📈.
  • Retrieve data efficiently from a table in Snowflake❄.
  • Deploy an AWS EC2☁️️ instance to the cloud for hosting your Streamlit app.

Topics covered.

The entire project will be divided into Two parts.

▷Part 1: Create a Customer Purchase Analytics App with Streamlit and Snowflake (This Blog):

In this part, we will create an online analytical app using Streamlit with data loaded from Snowflake. Let’s dive into the steps together!

▷Part 2: Deploy the App to AWS EC2 for Global Access:

After creating your analytics app, it’s time to make it accessible worldwide. Follow these steps to deploy it on AWS EC2 for a smooth online experience:

Let’s kick off Part 1 of this exciting project! Follow these steps to create a Customer Purchase Analytics App with Streamlit and Snowflake:

Before you begin coding, ensure to load the provided CSV file into the Snowflake table (ONLINERETAILTABLE) using the internal staging. Watch this video tutorial for guidance; the link to the CSV file is available here. 📄

For the complete code📄, head over to the GitHub link provided: - Click here👨🏽‍💻

Step 1: - Connects to Snowflake to retrieve online retail data❄️.

The provided code efficiently establishes a Snowflake session, retrieves data from a specified table, and stores it in a Dataframe.

🔍 Locate this code section📄 in our GitHub repository for reference👨🏽‍💻.

Step 2: - Initiate the app with an intriguing title and interactive country selection 🌐🛍️

The code snippet below swiftly creates an engaging title, descriptive text, and an interactive dropdown menu for selecting and tailoring a country from your dataset.

🔍 Locate this code section📄 in our GitHub repository for reference👨🏽‍💻.

Step 3: - Presents key insights: purchase amounts, quantities and frequent products📊💡.

This code snippet offers a comprehensive overview of key metrics, including Total purchase amount, quick views on Quantities, and a glimpse of Frequently bought products.

🔍 Locate this code section📄 in our GitHub repository for reference👨🏽‍💻.

Step 4: - Visualizes daily revenue trends data with charts and tables 📈📉.

The provided code seamlessly uses Streamlit and Altair to visually track and present daily sales data, empowering users to explore trends and make better decisions.

🔍 Locate this code section📄 in our GitHub repository for reference👨🏽‍💻.

Conclusion🚀

This blog post has set the stage for building an interactive customer purchase analytics app with Streamlit and Snowflake. We’ve covered setting up the environment, connecting to Snowflake, and creating engaging sections to display key insights and visualize daily revenue trends.

Stay tuned for Part 2, where we’ll take your app to the next level by deploying it to an AWS EC2 instance for global access!

Thanks for Reading📖💙

if you like my work the way to support me ….

  1. The best way is to support me is by following me on medium.
  2. Feel free to give claps so I know how helpful this post was to you.

--

--

Data Engineering Blogpost

Data engineering enthusiast ️ Building pipelines, wrangling data, & unlocking insights. AWS, Snowflake, Python . Join me on the journey!