Skip to content

etl-system for tpscore application (tps tracker in Polkadot ecosystem)

License

Notifications You must be signed in to change notification settings

BCS-Labs/tpscore-etl-system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TPScore

Description

TPScore simplifies TPS Data Analysis for non-technical users in the Polkadot Ecosystem.

TPScore aims to provide non-technical users in the Polkadot ecosystem with an accessible and user-friendly platform for analyzing TPS (Transactions per Second) data. Our goal is to bridge the gap between technical intricacies and user-friendly visualization, empowering individuals to make informed decisions about blockchain adoption, investment, and development.

The project consists of two main parts:

  1. ETL System
  2. User Interface (UI) with Data Visualizations

This repository contains the ETL system, responsible for collecting blockchain data from Polkadot parachains, calculating the Transactions Per Second (TPS) for transactions of type Balance, and storing the processed data in a MySQL database. This repository is a part of Milestone 1 submission for the Grants-Program.

Table of Contents

Installation

Before running this project, make sure you have the following prerequisites installed:

  1. Docker
  2. Python 3.9

Follow these steps to set up and run the project:

Clone the Project

  1. Clone this repository using git clone command.

Create and Run MySQL Database Container

  1. Navigate to the 'db' directory from the project's root directory: cd db.
  2. Build the Docker image using the Dockerfile: docker build -t mysql_tpscore .
  3. Run a container with the MySQL database: docker run --name db_mysql -d mysql_tpscore

Create and Run Airflow Container

  1. Navigate to the 'airflow' directory from the project's root directory: cd airflow.
  2. Launch the airflow-init container: docker compose up airflow-init
  3. Build an image using the Dockerfile and docker-compose files: docker build .
  4. Start Airflow services: docker compose up -d

Create a Network and Add Containers

  1. Create a Docker network: docker network create net_tpscore
  2. Connect the 'db_mysql' container: docker network connect net_tpscore db_mysql
  3. Connect the 'airflow_scheduler' container: docker network connect net_tpscore airflow_scheduler

Usage

The application can be interacted with in two ways:

Airflow GUI

  1. Access the Airflow GUI at http://localhost:8080/
  2. Log in using the credentials (airflow, airflow) Airflow Login
  3. Find the get_data_tpscore DAG and activate it by moving toggle to the right Run DAG
  4. Click on the DAG to verify successful execution (squares will be dark green, indicating error-free execution). DAG Run Success

MySQL Connection from Inside the Container

  1. Connect to the container: docker exec -it db_mysql bash
  2. Log in to MySQL: mysql -u user_tpscore -p
  3. Enter the password: pass_tpscore
  4. Select the database: USE tpscore_data;
  5. Run queries on the MySQL database, for example, select the top 3 TPS values: SELECT * FROM tps ORDER BY tps DESC LIMIT 3; SQL Result

Testing Guide

The core logic of the application is in get_data_tpscore.py. The script defines functions for database connection, fetching blockchain data, transformation, and data upload to the database. Tests for get_data_tpscore.py are in test_get_data_tpscore.py. Follow these steps to run the tests:

  1. Create a virtual environment by running the command from the root project directory: python -m venv venv_tpscore
  2. Activate the environment: source venv_tpscore/bin/activate
  3. Install dependencies from requirements.txt: pip install -r requirements.txt
  4. Run tests: pytest Tests Result

Credits

This open-source project was developed for the Polkadot community and relies on various open-source components and Python libraries:

License

This project is licensed under GPLv3. For more details, refer to the license document.

About

etl-system for tpscore application (tps tracker in Polkadot ecosystem)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published