Hello! Welcome to the final lesson of our "Data Pipeline Fundamentals" module.
So far, we've explored the core concepts that underpin modern data engineering: the distinction between ETL and ELT, the trade-offs of batch versus streaming, the critical importance of idempotency, and the organizational power of the medallion architecture.
In this lesson, we will bring all these pieces together. Our goal is to outline the complete target architecture for your personal project. We will create a blueprint that shows exactly how your chosen tools—PostgreSQL, Airflow, dbt, Python, and Kafka—will work in concert to ingest, transform, and serve data. This high-level map will guide us through the hands-on building process in the upcoming modules.
By the end of this lesson, you will have a clear, comprehensive vision of the data pipeline you are about to build.
The Architectural Blueprint
Every complex system needs a blueprint. For our data pipeline, this blueprint defines not just the components but also how data and control signals flow between them. Our architecture is designed to handle both your batch sources (APIs, CSVs) and your streaming source, process them through the medallion layers, and prepare them for your analytics dashboard and NLP service.
Let's begin by looking at a diagram that illustrates this kind of event-driven, layered architecture. While it uses a few different technologies, the pattern is precisely what we will implement.

This diagram elegantly combines the medallion pattern with a modern data stack. We will use it as our guide, adapting it to your specific technology choices. Our object storage will be PostgreSQL, and our processing will be a combination of Python and dbt.
Let's break down the roles of each component in your stack.
Core Components and Their Roles
A successful architecture ensures that each component has a clearly defined responsibility. Here’s how your chosen tools fit together.
This article provides an excellent overview of how the core tools for our batch pipeline—Airflow, dbt, and Postgres—interact.
Please read the "Tooling Foundations" section. It concisely describes the role of each technology. As you read, notice how the author defines Airflow as the control plane, dbt for transformations, and PostgreSQL as the data warehouse. We will also touch upon Docker later.
As the article explains, these tools form a powerful, modern stack. Let's place them within our architectural blueprint:
-
Storage (The Warehouse): PostgreSQL
- Role: PostgreSQL will serve as the central data warehouse for your entire pipeline. It's not just a temporary holding area; it is the permanent home for all your data, from raw to refined.
- Implementation: We will implement the medallion architecture using PostgreSQL schemas. You will have a
bronzeschema for raw data, asilverschema for cleaned and conformed data, and agoldschema for business-ready, aggregated data marts. Your experience with PostgreSQL will be invaluable here.
-
Orchestration (The Conductor): Apache Airflow
- Role: Airflow is the brain of your batch operations. It will schedule, execute, and monitor all the tasks involved in getting data from your batch sources into the
bronzelayer and triggering the subsequent transformations. - Implementation: You will write Directed Acyclic Graphs (DAGs) in Python. For instance, one DAG might be scheduled to run daily. Its tasks would be: 1) fetch data from an API, 2) load it into the
bronzePostgres schema, and 3) trigger the dbt transformation jobs.
- Role: Airflow is the brain of your batch operations. It will schedule, execute, and monitor all the tasks involved in getting data from your batch sources into the
-
Ingestion & Transformation (The Workers): Python & dbt
- Python Scripts: Your proficiency in Python will be used for the ingestion tasks. These scripts, orchestrated by Airflow, will handle the logic for connecting to APIs, parsing files, and loading the raw data into the
bronzePostgreSQL tables using idempotent patterns. - dbt Models: dbt will be your primary tool for transformation. It will handle everything that happens after the data lands in the
bronzelayer. Using your advanced SQL skills, you will write dbt models to clean, join, and aggregate data, moving it progressively from thebronzeschema tosilverand finally togold.
- Python Scripts: Your proficiency in Python will be used for the ingestion tasks. These scripts, orchestrated by Airflow, will handle the logic for connecting to APIs, parsing files, and loading the raw data into the
-
Streaming (The Real-Time Channel): Apache Kafka
- Role: Kafka will handle your streaming data source. It acts as a durable, high-throughput message queue that decouples the data source from the processing logic.
- Implementation: A data source will produce messages to a Kafka topic. A separate, continuously running Python service (a "consumer") will subscribe to this topic, read messages in small batches, and write them into the
bronzelayer of PostgreSQL.
Tying It All Together: The Data Flow
Now, let's trace the journey of data through this system, using the diagram as our reference.
The Batch Workflow (APIs, CSVs)
This flow is for data that you process on a schedule (e.g., once a day, once an hour).
- Orchestration: An Airflow DAG is triggered on its schedule.
- Ingestion (Python):
- The first task in the DAG executes a Python script. This script fetches data from an API or reads a CSV file. This corresponds to step
1(Manual Upload) in the diagram, though ours will be automated. - The script loads this raw data into the
bronzeschema in PostgreSQL.
- The first task in the DAG executes a Python script. This script fetches data from an API or reads a CSV file. This corresponds to step
- Transformation (dbt):
- Once the ingestion task succeeds, Airflow triggers the next task:
dbt run. - dbt executes its models. It reads from the
bronzetables, applies transformations (cleaning, joining), and materializes the results in thesilverschema. This is the "Data Cleaning" part, analogous to steps4and5in the diagram. - dbt then runs models that read from the
silverschema, perform aggregations, and create the final data marts in thegoldschema, ready for your dashboard. This is the "Data Aggregation" part, analogous to steps8and9.
- Once the ingestion task succeeds, Airflow triggers the next task:
The following video provides a fantastic walkthrough of building this exact batch architecture.
How to build an automated data pipeline using Airflow, dbt, Postgres, and Superset (Windows 11 WSL)
This video by Calvin Yoon demonstrates the integration of Airflow, dbt, and Postgres. It perfectly visualizes the batch portion of our target architecture.
First, watch the architecture overview from the beginning. Notice how it maps directly to our plan: Python for extraction, dbt for transformation, Postgres for storage, and Airflow for automation. Next, watch the segment where the ingestion task and transformation task are combined into a single DAG. Pay attention to how the presenter sets up the task dependency, ensuring that the dbt transformation runs only after the initial data ingestion is complete. This task1 >> task2 relationship is the core of Airflow orchestration.
The Streaming Workflow (Kafka)
This flow is for data that arrives continuously and needs to be captured in near real-time.
- Ingestion (Kafka):
- Your streaming source sends an event message (a piece of data) to a Kafka topic. In our reference diagram, this is represented by steps
2and6. We'll start with a single topic. Let's call it thebronze_topic.
- Your streaming source sends an event message (a piece of data) to a Kafka topic. In our reference diagram, this is represented by steps
- Consumption (Python):
- A dedicated Python consumer service, running independently of Airflow, is constantly listening to this
bronze_topic(step3). - When a message arrives, the consumer processes it (e.g., parsing JSON) and loads it into the appropriate table in the
bronzePostgreSQL schema. This is an ongoing, low-latency process.
- A dedicated Python consumer service, running independently of Airflow, is constantly listening to this
- Unification (dbt & Airflow):
- The streaming data now resides in the
bronzelayer alongside the data from your batch sources. - When the next scheduled Airflow DAG runs the
dbt runcommand, dbt is completely agnostic to how the data arrived. It simply sees new rows in thebronzetables and processes them into thesilverandgoldlayers, effectively unifying your batch and streaming data.
- The streaming data now resides in the
This hybrid approach gives you the best of both worlds: scheduled, robust processing for batch sources and low-latency capture for streaming sources, all unified for transformation in a single, consistent framework.
Conclusion
Let's recap the blueprint for your data pipeline:
- Central Storage: PostgreSQL will house all data in
bronze,silver, andgoldschemas. - Batch Processing: Airflow will orchestrate Python scripts for ingestion from APIs/CSVs into the
bronzeschema, followed by dbt jobs to transform data through thesilverandgoldlayers. - Streaming Processing: A standalone Python consumer will read from a Kafka topic and write data into the
bronzeschema in near real-time. - Data Unification: dbt acts as the great unifier, transforming all raw data in the
bronzelayer—regardless of its origin—into a single, cohesive source of truth in thesilverandgoldlayers.
You now have the complete architectural diagram for your project. This blueprint will be our guide for the rest of the course as we move from theory into practice.
Next time
With our architectural plan in place, the next logical step is to set up the workshop where we'll build it. The next module, "Local Development Stack with Docker," is entirely dedicated to this. In the very next lesson, we will begin by structuring our project and setting up a reproducible Python environment, the first practical step toward turning this blueprint into a reality.