Real-Time Cryptocurrency Monitoring System

Production-ready data streaming pipeline for real-time cryptocurrency exchange rate monitoring using Apache Kafka and Cassandra

Apache KafkaApache CassandraAWS EC2Alpha Vantage API

System Architecture

Alpha Vantage API

Real-time crypto data source

Apache Kafka

Message streaming platform

Apache Cassandra

Distributed NoSQL database

1

Ingest

API Consumer fetches real-time exchange rates for BTC, ETH, XRP against USD/EUR every 30 minutes

2

Stream

Kafka producer streams formatted cryptocurrency data to topic for real-time processing

3

Store

Kafka consumer processes messages and inserts structured data into Cassandra for persistence

Technical Implementation

API Consumer Logic

# Scheduled Data Fetching
scheduler = BlockingScheduler()
scheduler.add_job(fetch_and_send_data, 
                 "interval", minutes=30)

# Kafka Producer
producer = KafkaProducer(
    bootstrap_servers="localhost:9092",
    value_serializer=lambda v: 
        json.dumps(v).encode('utf-8')
)

Multi-Currency Support

Tracks BTC, ETH, XRP against USD and EUR simultaneously

Real-time Streaming

Automated 30-minute intervals with APScheduler

Consumer & Storage

# Kafka Consumer
consumer = KafkaConsumer(
    "crypto_prices",
    auto_offset_reset="earliest",
    value_deserializer=lambda x: 
        json.loads(x.decode("utf-8"))
)

# Cassandra Insert
INSERT INTO crypto_prices VALUES 
(%s, %s, %s, %s, %s, %s)

Message Processing

Continuous listening and processing of Kafka messages

Persistent Storage

Structured data storage with bid/ask prices and timestamps

Data Schema & Structure

Cassandra Table: crypto_prices

timestamp
TEXT
Date and time of data retrieval
from_currency
TEXT
Cryptocurrency (BTC, ETH, XRP)
to_currency
TEXT
Fiat currency (USD, EUR)
exchange_rate
FLOAT
Current exchange rate
bid_price
FLOAT
Highest buyer price
ask_price
FLOAT
Lowest seller price

System Features & Capabilities

Real-Time Streaming

30-minute intervals with continuous data flow

AWS Deployment

Production-ready EC2 instance with 24/7 uptime

Secure Architecture

Environment variables and secure API key management

Scalable Design

Modular architecture ready for horizontal scaling

Deployment & Technology Stack

Production Environment

AWS EC2 Instancet2.small

Ubuntu server with 24/7 availability

Process Managementnohup

Background processes for continuous operation

Technology Components

Python 3Core Language
APSchedulerJob Scheduling
kafka-pythonMessage Streaming
cassandra-driverDatabase Client

Future Enhancements & Roadmap

Visualization Dashboard

Grafana or Streamlit dashboard for real-time monitoring and analytics

Enhanced Scalability

Managed services upgrade and horizontal scaling capabilities

Advanced Monitoring

Comprehensive logging, error handling, and system health monitoring