<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Ridhic Toms Rijo on Medium]]></title>
        <description><![CDATA[Stories by Ridhic Toms Rijo on Medium]]></description>
        <link>https://medium.com/@ridhicrijo.2000?source=rss-1ec1de7707fa------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*_Vg0_6TcnuUAk9t1</url>
            <title>Stories by Ridhic Toms Rijo on Medium</title>
            <link>https://medium.com/@ridhicrijo.2000?source=rss-1ec1de7707fa------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 06:09:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ridhicrijo.2000/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Building a Real-Time and Batch Data Pipeline with Apache Spark, Kafka, Airflow, PostgreSQL, and…]]></title>
            <link>https://medium.com/@ridhicrijo.2000/building-a-real-time-and-batch-data-pipeline-with-apache-spark-kafka-airflow-postgresql-and-a17cf9a5a12c?source=rss-1ec1de7707fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/a17cf9a5a12c</guid>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[batch-processing]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[etl]]></category>
            <category><![CDATA[spark]]></category>
            <dc:creator><![CDATA[Ridhic Toms Rijo]]></dc:creator>
            <pubDate>Tue, 06 May 2025 13:56:56 GMT</pubDate>
            <atom:updated>2025-05-06T13:56:56.233Z</atom:updated>
            <content:encoded><![CDATA[<h3>Building a Real-Time and Batch Data Pipeline with Apache Spark, Kafka, Airflow, PostgreSQL, and Elasticsearch — End-to-End in Docker</h3><p>As a data engineer with close to 3 years of experience, I’ve worked across multiple pipelines, often needing to stitch together tools for ingestion, transformation, storage, and visualization. To sharpen my architectural skills and showcase my grasp on real-time and batch processing paradigms, I built an <strong>end-to-end IMDB Data Pipeline</strong>, fully containerized with Docker.</p><p>This project simulates the kind of infrastructure you’d build in a production-grade system, using tools like <strong>Apache Spark, Kafka, PostgreSQL, Elasticsearch, Prometheus, Grafana</strong>, and <strong>Airflow</strong> for orchestration.</p><h3>Architecture Overview</h3><p>This pipeline scrapes IMDB data, validates and transforms it through batch and stream processing, and sends it to Elasticsearch for querying and visualization. Monitoring is handled through Prometheus + Grafana. The entire infrastructure runs inside Docker.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/817/1*0BNoO9dUAHfn8nkKGEN1xw.jpeg" /></figure><h3>Key Components</h3><ol><li><strong>Scraper DAG</strong>: Scrapes IMDb data and writes to PostgreSQL + Kafka.</li><li><strong>Streaming Job</strong>: Reads from Kafka, validates, transforms, writes to Elasticsearch (imdb_stream).</li><li><strong>Batch Job</strong>: Reads from PostgreSQL, transforms using Spark, writes to Elasticsearch (imdb_batch).</li><li><strong>Monitoring</strong>: Pushes metrics to Prometheus using Pushgateway. Dashboards on Grafana.</li><li><strong>Orchestration</strong>: Airflow handles the scheduling and triggering of all components.</li></ol><h3>Data Flow Breakdown</h3><h4>1. Web Scraping with Airflow</h4><ul><li>The <strong>scrape_imdb_data_dag.py</strong> is the entry point.</li><li>It runs a Python scraper that extracts IMDb movie data.</li><li>Writes the raw records simultaneously to — <strong>PostgreSQL</strong> for batch jobs and <strong>Kafka</strong> (imdb_movies_stream topic) for real-time stream processing.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K4GsfTHZcllafOEtxmLaEw.png" /></figure><h4>2. Real-Time Processing with Spark Structured Streaming</h4><ul><li>A <strong>streaming Spark job</strong> reads the JSON movie records from Kafka.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zPBQ12FMMgbseXnoXy-yXg.png" /></figure><ul><li>Applies Schema enforcement and Validation rules.</li><li>Filters out invalid records and counts them using Prometheus metrics.</li><li>Writes valid data to <strong>Elasticsearch</strong> under imdb_stream index.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*91edhRNh9Bs8vJyewPgD2w.png" /></figure><h4>3. Batch Processing with Spark</h4><ul><li>A daily batch DAG (spark_batch_process_dag.py) triggers a Spark job.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KIimJwfaqHiFtQLPrnQBEg.png" /></figure><ul><li>Reads records from <strong>PostgreSQL</strong>.</li><li>Applies validation, transformations.</li><li>Writes results to Elasticsearch under imdb_batch index.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tBu6tdRYxblG-Nzn6YLm5g.png" /></figure><h4>4. Monitoring with Prometheus and Grafana</h4><p>All Spark jobs and scraping steps push key metrics to <strong>Prometheus Pushgateway</strong>. These include:</p><ul><li>valid_rows_processed</li><li>invalid_rows_processed</li><li>spark_batch_success</li><li>stream_valid_rows_total</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wfgEpuh-6pPtBQMYn4OwWA.png" /></figure><p>These are visualized in <strong>Grafana</strong> using real-time dashboards.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W_UD0x7ei5rFCLG_79dijQ.png" /></figure><h3>Dockerized Setup</h3><p>Everything runs in isolated Docker containers:</p><ul><li><strong>Airflow</strong></li><li><strong>Kafka + Zookeeper</strong></li><li><strong>Spark</strong></li><li><strong>PostgreSQL</strong></li><li><strong>Elasticsearch</strong></li><li><strong>Prometheus + Pushgateway + Grafana</strong></li></ul><p>The docker-compose.yml wires all these together for seamless orchestration.</p><h3>Key Learnings</h3><ul><li>Designing and orchestrating hybrid pipelines (batch + streaming) requires a strong grasp of coordination and idempotency.</li><li>Pushing custom metrics to Prometheus allows real-time insights into pipeline health.</li><li>Dockerizing everything forced me to understand inter-container communication deeply.</li><li>Elasticsearch provides near real-time search capabilities, making it ideal for analytics.</li></ul><p>This project was an incredible learning experience in designing a <strong>production-style data pipeline</strong> from scratch. For anyone looking to strengthen their grasp of the <strong>modern data stack</strong>, building something like this is an excellent challenge.</p><p>Feel free to connect or drop a feedback!</p><p><strong>GitHub Repo</strong>: <a href="https://github.com/Ridhic/imdb_pipeline">https://github.com/Ridhic/imdb_pipeline</a><br><strong>LinkedIn</strong>: <a href="https://www.linkedin.com/in/ridhic-toms-rijo/">https://www.linkedin.com/in/ridhic-toms-rijo/</a><br><strong>Medium Profile</strong>: <a href="https://medium.com/@ridhicrijo.2000">https://medium.com/@ridhicrijo.2000</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a17cf9a5a12c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Full-Fledged Crypto Data Pipeline: Local & Cloud Implementations]]></title>
            <link>https://medium.com/@ridhicrijo.2000/building-a-full-fledged-crypto-data-pipeline-local-cloud-implementations-c6988ea3f5e9?source=rss-1ec1de7707fa------2</link>
            <guid isPermaLink="false">https://medium.com/p/c6988ea3f5e9</guid>
            <category><![CDATA[etl]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[data-engineering]]></category>
            <category><![CDATA[airflow]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[Ridhic Toms Rijo]]></dc:creator>
            <pubDate>Wed, 09 Apr 2025 21:31:31 GMT</pubDate>
            <atom:updated>2025-04-09T21:31:31.624Z</atom:updated>
            <content:encoded><![CDATA[<p>As a Data Engineer with over 2 years of experience, I&#39;m exploring ways to level up my portfolio with hands-on projects. As part of this, I decided to build a full-fledged data pipeline project that simulates real-world architecture — using both AWS cloud services and a local Docker-based setup.</p><p>This article is a walkthrough of my Crypto Pipeline Project — a dual-version pipeline that takes real-time cryptocurrency data, processes it, and visualizes the output. The goal was to simulate how data moves through ingestion, transformation, and reporting in an actual production environment.</p><h3>Project Overview</h3><p>Objective: Ingest cryptocurrency data from a public API, store and transform it, and finally visualize it through dashboards.</p><p>I built two parallel versions of the pipeline:</p><p>Docker Track (Local Setup):</p><ul><li>Apache Airflow (Docker Compose) for orchestration</li><li>PostgreSQL for storage</li><li>Apache Spark for transformation (via Airflow tasks)</li><li>Metabase for visualization</li></ul><p>AWS Track (Cloud Setup using Free Tier):</p><ul><li>Apache Airflow for orchestration</li><li>Amazon S3 for raw data storage</li><li>AWS Glue for transformation</li><li>Amazon Redshift for visualization</li></ul><h3>Architecture Overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*d1HQ2J7841gbTF4YDIc7Hw.png" /></figure><h3>Data Source: Public Crypto API</h3><p>The data is fetched from <a href="https://www.coingecko.com/en/api">CoinGecko’s public API</a>, which returns real-time cryptocurrency prices and metrics like market cap, volume, and more.</p><p>Here’s a sample response:</p><pre>[<br>  {<br>    &quot;id&quot;: &quot;bitcoin&quot;,<br>    &quot;symbol&quot;: &quot;btc&quot;,<br>    &quot;name&quot;: &quot;Bitcoin&quot;,<br>    &quot;image&quot;: &quot;https://coin-images.coingecko.com/coins/images/1/large/bitcoin.png?1696501400&quot;,<br>    &quot;current_price&quot;: 76979,<br>    &quot;market_cap&quot;: 1527865829247,<br>    &quot;market_cap_rank&quot;: 1,<br>    &quot;fully_diluted_valuation&quot;: 1527865829247,<br>    &quot;total_volume&quot;: 48317570622,<br>    &quot;high_24h&quot;: 80802,<br>    &quot;low_24h&quot;: 76516,<br>    &quot;price_change_24h&quot;: -1975.9331231031392,<br>    &quot;price_change_percentage_24h&quot;: -2.50262,<br>    &quot;market_cap_change_24h&quot;: -39226693183.95288,<br>    &quot;market_cap_change_percentage_24h&quot;: -2.50315,<br>    &quot;circulating_supply&quot;: 19848556.0,<br>    &quot;total_supply&quot;: 19848556.0,<br>    &quot;max_supply&quot;: 21000000.0,<br>    &quot;ath&quot;: 108786,<br>    &quot;ath_change_percentage&quot;: -29.23451,<br>    &quot;ath_date&quot;: &quot;2025-01-20T09:11:54.494Z&quot;,<br>    &quot;atl&quot;: 67.81,<br>    &quot;atl_change_percentage&quot;: 113428.61304,<br>    &quot;atl_date&quot;: &quot;2013-07-06T00:00:00.000Z&quot;,<br>    &quot;roi&quot;: null,<br>    &quot;last_updated&quot;: &quot;2025-04-08T21:24:10.141Z&quot;<br>  }<br>]</pre><h3>Local Setup Using Docker</h3><p>I containerized all local services using Docker Compose:</p><p>- Apache Airflow — Orchestration (with DAG: `crypto_pipeline_dag`)<br>- PostgreSQL — Storage for raw and cleaned data<br>- Spark (via Airflow — Data transformation<br>- Metabase — Data visualization dashboards</p><h4>Docker Containers</h4><pre>CONTAINER ID   IMAGE                  COMMAND                  CREATED         STATUS         PORTS                                       NAMES<br>198a0d24927e   apache/airflow:2.6.3   &quot;/usr/bin/dumb-init …&quot;   3 minutes ago   Up 3 minutes   8080/tcp                                    airflow_scheduler<br>be344b07bf71   apache/airflow:2.6.3   &quot;/usr/bin/dumb-init …&quot;   3 minutes ago   Up 3 minutes   0.0.0.0:8080-&gt;8080/tcp, :::8080-&gt;8080/tcp   airflow_web<br>e6dbcd5f9950   metabase/metabase      &quot;/app/run_metabase.sh&quot;   3 minutes ago   Up 3 minutes   0.0.0.0:3000-&gt;3000/tcp, :::3000-&gt;3000/tcp   crypto_metabase<br>17dd9a7dbf6d   postgres:13            &quot;docker-entrypoint.s…&quot;   4 minutes ago   Up 3 minutes   0.0.0.0:5432-&gt;5432/tcp, :::5432-&gt;5432/tcp   crypto_postgres</pre><ul><li><strong>airflow_scheduler</strong>: Responsible for triggering tasks in the DAG (crypto_pipeline_dag) at scheduled intervals.</li><li><strong>airflow_web</strong>: Provides the web UI where you can view DAG runs, logs, and manage tasks.</li><li><strong>crypto_postgres</strong>: Stores the ingested and filtered cryptocurrency data.</li><li><strong>crypto_metabase</strong>: Connects to PostgreSQL and visualizes the data in the form of charts and dashboards.</li></ul><h3>Airflow DAG: crypto_pipeline_dag</h3><p>This DAG has **two main tasks**:</p><h4>Task 1: ingest_data</h4><ul><li>Fetches real-time crypto data via API</li><li>Stores raw JSON:<br> — in <strong>Postgres</strong> (raw table)<br> — and <strong>S3</strong> (for the AWS version)</li></ul><h4>Task 2: transform_data</h4><ul><li>Filters top cryptocurrencies based on market cap</li><li>Stores cleaned data into a **separate Postgres table**</li></ul><blockquote>I used Spark for this step within the Docker setup — not because it was necessary, but to simulate real-world tools often used in data engineering pipelines.</blockquote><h3>Metabase Dashboard</h3><p>After transforming the data, I connected Metabase to my Postgres instance and created an interactive dashboard.</p><p>The dashboard includes:</p><ol><li>Bar chart — Top 10 Cryptos by Market Cap</li><li>Scatter plot — Price vs Market Cap</li><li>Line chart — Top 5 Cryptos by Price</li><li>Pie chart — Market Cap Share</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oa7Olq4vb8JireVU4DGCSQ.png" /></figure><h3>AWS Cloud Version — Free Tier</h3><p>In this version of the pipeline, I replicated a real-world production-like cloud architecture using free-tier AWS services. The goal was to store, transform, and query crypto data using scalable AWS tools.</p><h4>1. Amazon S3 — Raw Data Storage</h4><p>In the first task of my Airflow DAG (`ingest_data`), the same cryptocurrency API data is stored in an **S3 bucket** as raw JSON.</p><ul><li>I used the `boto3` Python SDK to interact with S3</li><li>Files are stored with timestamp-based naming like:</li></ul><pre>s3://my-bucket/crypto/raw/crypto_2025-04-05T21-44-04.json</pre><h4>2. AWS Glue — ETL &amp; Transformation</h4><p>I created an AWS Glue Job to:</p><ul><li>Read raw JSON from S3</li><li>Filter</li><li>Write clean data to Redshift</li></ul><pre>import sys<br>import json<br>import boto3<br>from pyspark.context import SparkContext<br>from awsglue.context import GlueContext<br>from awsglue.job import Job<br>from awsglue.utils import getResolvedOptions<br><br>args = getResolvedOptions(sys.argv, [&quot;JOB_NAME&quot;])<br>sc = SparkContext()<br>glueContext = GlueContext(sc)<br>spark = glueContext.spark_session<br>job = Job(glueContext)<br>job.init(args[&quot;JOB_NAME&quot;], args)<br><br>secret_name = &quot;redshift/crypto-user&quot;<br>region_name = &quot;us-east-1&quot;<br><br>session = boto3.session.Session()<br>client = session.client(service_name=&quot;secretsmanager&quot;, region_name=region_name)<br>get_secret_value_response = client.get_secret_value(SecretId=secret_name)<br>secret = json.loads(get_secret_value_response[&quot;SecretString&quot;])<br><br>redshift_user = secret[&quot;username&quot;]<br>redshift_password = secret[&quot;password&quot;]<br>redshift_host = secret[&quot;host&quot;]<br>redshift_port = secret[&quot;port&quot;]<br>redshift_db = secret[&quot;database&quot;]<br><br>s3_path = &quot;s3://ridhic-crypto/raw/&quot;<br>df = spark.read.json(s3_path)<br><br>df_filtered = df.select(<br>    &quot;id&quot;, &quot;symbol&quot;, &quot;name&quot;, &quot;current_price&quot;, &quot;market_cap&quot;<br>)<br><br>df_filtered.write \<br>    .format(&quot;jdbc&quot;) \<br>    .option(&quot;url&quot;, f&quot;jdbc:redshift://{redshift_host}&quot;) \<br>    .option(&quot;user&quot;, redshift_user) \<br>    .option(&quot;password&quot;, redshift_password) \<br>    .option(&quot;dbtable&quot;, &quot;crypto_filtered&quot;) \<br>    .option(&quot;driver&quot;, &quot;com.amazon.redshift.jdbc.Driver&quot;) \<br>    .mode(&quot;overwrite&quot;) \<br>    .save()<br><br>job.commit()</pre><blockquote>While trying to write data from my Glue job into Amazon Redshift, I initially skipped creating a Glue connection, thinking AWS Secrets Manager alone would be enough.</blockquote><blockquote>However, I hit a connection error because the necessary network configuration was missing. Here’s what I learned:</blockquote><blockquote>- I went to AWS Glue → Connections → Add connection, chose Amazon Redshift, and provided the host, port, database name, and credentials (using AWS Secrets Manager).<br>- I made sure to choose the correct VPC, subnet, and security group.</blockquote><blockquote>Even then, the job couldn’t connect because it was running in a private subnet. I had to manually create the following VPC endpoints:</blockquote><blockquote>- com.amazonaws.&lt;region&gt;.redshift<br>- com.amazonaws.&lt;region&gt;.secretsmanager<br>- com.amazonaws.&lt;region&gt;.glue<br>- com.amazonaws.&lt;region&gt;.sts</blockquote><blockquote>After assigning the correct route tables and ensuring the IAM role used by the job had access to Secrets Manager and Redshift, it finally worked.</blockquote><h4>3. Redshift — Data Warehousing</h4><p>After cleaning and filtering the data using AWS Glue, I loaded it into Amazon Redshift Serverless, which served as the data warehouse layer in this project.</p><ul><li>Set up a Redshift Serverless Workgroup and Namespace</li><li>Used the public schema to store the transformed data</li><li>Ran SQL queries directly from the Redshift query editor to analyze and explore the dataset</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*inQYeciMFr1O8Cq_eWatSg.png" /></figure><p>To follow best practices and avoid hardcoding sensitive credentials (like username and password), I used AWS Secrets Manager to securely manage Redshift access credentials.</p><p>Inside the Glue job, I accessed these secrets using boto3, enabling secure and dynamic connection to Redshift.</p><h4>4. IAM — Roles &amp; Permissions</h4><p>To securely enable data flow between services, I created an IAM Role for Glue with access to S3 and Redshift and gave the following permissions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eYbW2XQ7rl3-HDdZjUrtrQ.png" /></figure><h3>Key Takeaways</h3><p>Here’s what I learned while building this project:</p><ul><li>Creating <strong>two versions of the same pipeline</strong> — one local and one on AWS — really helped me understand the differences between working on-prem vs in the cloud.</li><li>Running <strong>Spark inside Airflow locally</strong> felt close to what you’d deal with in real production setups, which was great practice.</li><li>The AWS setup gave me hands-on experience with:</li><li>Setting up S3 buckets</li><li>Configuring Glue jobs</li><li>Handling IAM roles and VPCs to connect Glue and Redshift</li><li>Putting everything into a <strong>dashboard made it super easy to see results</strong> and explain what’s going on at a glance.</li></ul><p>Overall, this project was a fun way to build something close to production without spending a ton — and it helped me get more comfortable with tools I’ll actually use in the field.</p><h3>GitHub Repository</h3><p>You can find the full code, README, and instructions here:</p><p>(<a href="https://github.com/Ridhic/crypto_pipeline">https://github.com/Ridhic/crypto_pipeline</a>)</p><p>Make sure to:</p><ul><li>Run `docker compose up airflow-init`</li><li>Then `docker compose up -d`</li><li>Check Airflow UI at `localhost:8080`</li><li>Check Metabase at `localhost:3000`</li></ul><p>This project was my way of pushing beyond tutorials — I wanted to **build something that simulates how real data engineering pipelines work**, both locally and in the cloud.<br>If you’re also a data engineer or aspiring one, I highly recommend creating a similar project to practice real-world skills.</p><p>Feel free to connect or drop a feedback!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c6988ea3f5e9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>