https://github.com/kaushik-puttaswamy/crypto-data-processing-and-analysis-pipeline
This project processes real-time cryptocurrency transactions using AWS Glue, Kinesis, DynamoDB, and Apache Hudi for ETL and analytics. The data is analyzed with Athena and visualized in QuickSight for insights.
https://github.com/kaushik-puttaswamy/crypto-data-processing-and-analysis-pipeline
aws dataanalysis dynamodb firehose glue glue-job hudi kinesis-stream python quicksight-dashboard spark sql
Last synced: 6 months ago
JSON representation
This project processes real-time cryptocurrency transactions using AWS Glue, Kinesis, DynamoDB, and Apache Hudi for ETL and analytics. The data is analyzed with Athena and visualized in QuickSight for insights.
- Host: GitHub
- URL: https://github.com/kaushik-puttaswamy/crypto-data-processing-and-analysis-pipeline
- Owner: Kaushik-Puttaswamy
- Created: 2025-02-04T18:19:22.000Z (8 months ago)
- Default Branch: main
- Last Pushed: 2025-02-09T17:12:45.000Z (8 months ago)
- Last Synced: 2025-02-09T17:34:56.184Z (8 months ago)
- Topics: aws, dataanalysis, dynamodb, firehose, glue, glue-job, hudi, kinesis-stream, python, quicksight-dashboard, spark, sql
- Language: Python
- Homepage: https://www.datascienceportfol.io/kaushikputtaswamy/projects/14
- Size: 4.4 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Crypto Data Processing and Analysis Pipeline Using AWS Glue, Kinesis, DynamoDB, Athena and QuickSight
## π Project Overview
The Crypto Data Processing Pipeline is an end-to-end data processing solution designed to handle cryptocurrency transactions in real time. It leverages AWS Glue, AWS Lambda, Kinesis Firehose, DynamoDB Streams, and Hudi for efficient ETL and analytics. The project processes raw transaction data, performs transformations, categorizes trades based on risk, and stores processed data in an S3-based Hudi table for further analysis uisng AWS QucikSight.
β’ Real-time data ingestion from DynamoDB streams
β’ CDC (Change Data Capture) processing with Kinesis Firehose
β’ Spark-based ETL with AWS Glue and Apache Hudi
β’ Data lake storage with S3 and AWS Glue Catalog
β’ Interactive analytics with Athena and QuickSight
## π Project Structure
Crypto-Data-Processing/
βββ crypto_nrt_etl_glue_job.py # AWS Glue ETL script for data transformation & storage
βββ lambda_transformer.py # AWS Lambda function for processing DynamoDB Streams
βββ mock_crypto_data_to_dynamodb.py # Script to simulate crypto transactions and insert them into DynamoDB
βββ Project Execution Screenshots/ # Folder containing setup and execution screenshots
βββ Project architecture # High-level architecture and data flow
βββ README.md # Project documentation (this file)
## β¨ Key Features
β’ Real-Time Risk Analysis: Flag high-value trades (>$500k)
β’ Multi-Exchange Normalization: Price adjustments per exchange
β’ Dynamic Fee Calculation: Volume-based fee discounts
β’ Time-Bucket Aggregation: Hourly trade analysis
β’ ACID Compliance: Apache Hudi for UPSERT operations
## β Prerequisites
Before setting up the Crypto Data Processing and Analysis Pipeline, ensure you have the following:
1. AWS Account & Services
β’ An AWS Account with access to:
β’ AWS Glue (for ETL and data transformation)
β’ AWS DynamoDB (for storing raw crypto transactions)
β’ AWS Kinesis Firehose (for real-time streaming)
β’ AWS Lambda (for data transformation)
β’ AWS S3 (for storing raw and processed data)
β’ AWS Athena (for querying processed data)
β’ AWS QuickSight (for visualizing insights)2. AWS CLI & SDKs
β’ Install and configure AWS CLI:```pip install awscli```
```aws configure```
3. Python & Dependencies
β’ Install Python 3.x and required libraries:```pip install faker```
```pip install boto3```
4. Permissions & IAM Roles
β’ Create IAM roles with the following policies:
β’ Glue Service Role (AWSGlueServiceRole)
β’ Lambda Execution Role (AWSLambdaBasicExecutionRole)
β’ Kinesis Firehose Access Policyβ’ DynamoDB Stream Access Policy
5. AWS S3 Bucket for Storage
β’ Create an S3 bucket for storing raw and processed data.6. Enable DynamoDB Streams
β’ Enable DynamoDB Streams on the CryptoTransactions table for real-time data ingestion.
## π Project Architecture

### Data Flow:
β’ 1, Mock data generator β DynamoDB
β’ 2, 3, DynamoDB Stream β Kinesis Firehose
β’ 4, Firehose β Lambda (Transformation)
β’ 5, 6, 7, 8, 9, Raw S3 β Glue ETL (Hudi Processing)
β’ 10, 11, Processed S3 β Athena β QuickSight
This project follows a real-time data ingestion and processing pipeline:
1. Data Generation (Mock Transactions)β’ A Python script (mock_crypto_data_to_dynamodb.py) continuously generates mock crypto transactions.
β’ The data is inserted into AWS DynamoDB.
2. Data Streaming & Transformation
β’ DynamoDB Streams captures changes and forwards them to AWS Kinesis Firehose.
β’ A Lambda function (lambda_transformer.py) transforms the data from DynamoDBβs format to JSON.
3. Real-Time ETL Processing (AWS Glue)β’ AWS Glue reads data from S3 (landing zone).
β’ Performs data transformations, including:
β’ Risk flagging based on trade value.
β’ Price normalization across exchanges.
β’ Fee adjustments based on transaction size.
β’ User categorization based on trade volume.
β’ Writes processed data into an AWS S3-based Hudi table.
4. Data Storage & Analyticsβ’ Processed Data: Stored in an S3 Hudi table (processed_crypto_txn).
β’ Querying: AWS Athena is used to query Hudi tables.
β’ Visualization: QuickSight dashboards are built on Athena queries.
## π Setup & Execution Steps
Step 1: Configure AWS DynamoDB
β’ Create a DynamoDB Table (CryptoTransactions).
β’ Enable DynamoDB Streams to capture changes.
π Screenshot: DynamoDB_Table_Setup_with_Data_stream_and_CDC_enabled.png

Step 2: Setup AWS Kinesis Firehose
β’ Create a Kinesis Firehose delivery stream.
β’ Configure Firehose to read from DynamoDB Streams and deliver data to S3.π Screenshot: Firehose_Stream_Setup.png

π Screenshot: Kinesis_Setup_with_Shard_Showing_Records.png

Step 3: Create & Deploy AWS Lambda Function
β’ Deploy lambda_transformer.py to process data from Kinesis Firehose.
β’ This function:
β’ Converts DynamoDB JSON format into standard JSON.
β’ Adds metadata (event type, timestamp, event ID).
β’ Outputs transformed data to Kinesis Firehose.π Screenshot: Lambda_Function_for_Data_Transformation.png

π Screenshot: Lambda_Function_Permission_Policies.png

Step 4: Setup AWS Glue for ETL
β’ Create an AWS Glue Crawler to catalog data from S3 (Raw Transactions).
β’ Define a Glue ETL Job to process data using crypto_nrt_etl_glue_job.py.
β’ Glue ETL performs:
β’ Data Transformation
β’ Trade Risk Classification
β’ Price Normalization
β’ User Categorization
β’ Hudi-based storage in S3π Screenshot: Glue_Database_Setup.png

π Screenshot: Glue_Table_for_Raw_Processed_Data.png

π Screenshot: Glue_ETL_Setup.png

π Screenshot: Glue_ETL_Job_Status.png

Step 5: Query Data using AWS Athena
β’ AWS Athena is used to run SQL queries on processed crypto transactions stored in Hudi tables.
β’ Sample query:``` select * from crypto.processed_crypto_txn limit 10; ```
``` select count(*) from crypto.processed_crypto_txn limit 10; ```
``` SELECT * FROM crypto.processed_crypto_txn WHERE risk_flag = 'MEDIUM_RISK'; ```
π Screenshot: Athena_Query_Execution_for_Processed_Data.png

Step 6: Visualize Data using QuickSight
β’ AWS QuickSight connects to Athena and visualizes trade risk trends, price normalization, and user activity.
Insights include:β’ Trade Fee Collected
β’ Exchange Comparison
β’ Trading Volume per Trading Pair
β’ Risk Distribution
β’ Number of Trades by Status
β’ Order Type Distribution
β’ User Category Distributionπ Screenshot: QuickSight_File_Screenshot.png
π Screenshot: Crypto_Trading_Insights_Dashboard_using_QuickSight.png

π link: https://us-east-1.quicksight.aws.amazon.com/sn/dashboards/78dd677e-34d1-4a4f-9b78-82a2f97863ba/views/fe261a5f-630c-404e-ac18-8429d246000e?directory_alias=DataEngineering-QuickSight-Dashboard
Step 7: Automate Execution with AWS Triggers
β’ Set up AWS Glue triggers to run ETL jobs automatically based on new data arrival.π Screenshot: Trigger_Setup.png

## π₯ Key Features & Enhancements
β Real-Time Processing: Uses DynamoDB Streams + Kinesis Firehose for event-driven processing.
β Risk-Based Classification: Flags transactions based on trade value.
β Price Normalization: Adjusts price across multiple exchanges for fair comparison.
β User Categorization: Identifies VIP Traders, Active Traders, and Casual Traders.
β Athena & QuickSight Analytics: Enables ad-hoc analysis and business intelligence dashboards.
β Efficient Storage with Hudi: Ensures incremental updates & faster queries using Apache Hudi.
## π How to Run Locally?
Step 1: Install Dependencies
Ensure you have Python 3.x and the required AWS libraries:
``` pip install boto3 faker ```
Step 2: Simulate Transactions (Mock Data)
Run the script to insert transactions into DynamoDB:
``` python mock_crypto_data_to_dynamodb.py ```
Step 3: Deploy AWS Resources
1. Deploy Lambda function (lambda_transformer.py).
2. Configure Kinesis Firehose and connect it to DynamoDB Streams.
3. Setup Glue Crawler & Glue ETL Job.Step 4: Run AWS Glue ETL
Manually trigger the Glue ETL job:
``` aws glue start-job-run --job-name crypto_nrt_etl_glue_job ```
Step 5: Query & Analyze Data
Use AWS Athena or QuickSight to analyze processed data.
## π Future Enhancements
πΉ Add Machine Learning Anomaly Detection for fraud detection.
πΉ Implement Kafka instead of Kinesis for higher scalability.
πΉ Support Multi-Region Data Processing for global transaction tracking.
πΉ Enhance Data Governance with AWS Lake Formation.
## π€ Project Author
β’ Kaushik Puttaswamy - Aspiring Data Engineer (https://www.linkedin.com/in/kaushik-puttaswamy-data-analyst/)π§ For queries, reach out at ```kaushik.p9699@gmail.com```
## π― Conclusion
This project demonstrates real-time crypto transaction processing using AWS Glue, DynamoDB, and Apache Hudi. The system is scalable, efficient, and provides insights into high-risk transactions, exchange price variations, and trading behaviors.