Sitemap
DevOps.dev

Devops.dev is a community of DevOps enthusiasts sharing insight, stories, and the latest development in the field.

Update — Visualize E-commerce Public Data

3 min readApr 4, 2024

--

Press enter or click to view image in full size
Photo by Markus Winkler on Unsplash

In the previous post, I wrote about creating a dashboard/data visualization with Streamlit, I use public data that I get from dicoding.com. It’s created with static data from a CSV file and no other technology I used, besides Streamlit.

Get Muhamad Insan R’s stories in your inbox

Join Medium for free to get updates from this writer.

So now, I want to share the updated project data visualization.

  1. Use the Clickhouse database to read data, migrate from CSV file to database
  2. Create engine ETL to export from CSV file, clean and transform data, and load to Clickhouse database
  3. Containerized ETL and Dashboard Streamlit services
  4. Refactor all services running with the docker-compose (Clickhouse, ETL, Dashboard Streamlit)
Press enter or click to view image in full size
ETL Pipeline

Use Clickhouse database

I tried to migrate the data source from CSV files to the Clickhouse database, I considered using Clickhouse because it is lightweight enough, easy to use because it is similar to SQL, and integrating with Python is effortless.

$ pip install clickhouse_connect 
import clickhouse_connect 

# connect to client clickhouse with your credential
client = clickhouse_connect.get_client(host='your-host', username='your-user', password='your-password', port=your-port)

# query
client.command('select * from table-name')

Create ETL engine

ETL engine is responsible for extracting data from CSV files, cleaning and transforming data, and saving the data to the Clickhouse database.

Tree file
Tree of ETL engine

The picture above shows the utilitiesdirectory responsible for connecting to the database, extracting data, transforming data, and loading data to the database. Thus, elt.py running all files utilities as a main file.

Containerize with Docker

ETL and Dashboard Streamlit are built with docker for an easier deployment process. In the picture below I show you a line of code of the Dockerfile for both dashboard and ETL services.

Press enter or click to view image in full size
dockerfile
Dockerfile ETL and Dashboard

Wrap all with docker-compose

Lastly, create docker-compose to wrap all services within one file docker-compose that consists of Clickhouse container, ETL container, and dashboard container.

Press enter or click to view image in full size
Compose file

So, with these updates, I hope people who want to use the project can be more helpful.

Next update

Next update for this project.

  1. Refactoring to add unit testing
  2. Add orchestration with Apache Airflow

Source:
https://github.com/muhamadInsan/da-with-python-dicoding-submission

--

--

Written by Muhamad Insan R

Experienced Software System Analyst | Designing Innovative IT Solutions | Problem Solver & Technology Enthusiast

Published in DevOps.dev

Devops.dev is a community of DevOps enthusiasts sharing insight, stories, and the latest development in the field.