Text-to-SQL Analytics Platform with Airflow, Snowflake & dbt
Data Engineer

Text-to-SQL Analytics Platform with Airflow, Snowflake & dbt

Built an ELT platform (Airflow, Snowflake, dbt) with a Text-to-SQL and RAG assistant on top, so business users can ask questions in plain English and get the SQL, results and charts back.

SnowflakeApache AirflowdbtPostgreSQLFastAPIReactTypeScriptDockerPrometheusGrafanaArtificial IntelligenceLarge Language ModelsRetrieval-Augmented Generation (RAG)Vector DatabasesSQLGlot

AI‑Powered Data Engineering & Analytics Platform

AI-Powered Data Engineering & Analytics PlatformAI-Powered Data Engineering & Analytics Platform


Introduction

Modern e‑commerce teams drown in raw logs, fragmented dashboards, and endless SQL queries. Decision‑makers need answers, not tables—and they need them in seconds, not hours. This platform fuses data engineering, analytics engineering, and generative AI into a single, self‑service experience. By turning natural‑language questions into optimized SQL and visual insights, it lets product, marketing, and finance teams act on data instantly.


Key Features & Highlights

  • ✅ Natural‑Language Query Engine – Ask “What were the top‑selling categories last week?” and get a ready‑to‑run SQL + chart.
  • ✅ End‑to‑end ELT pipeline built on Snowflake, Airflow, and dbt for reliable, version‑controlled transformations.
  • ✅ Vector‑search RAG layer that augments LLM responses with domain‑specific schema knowledge.
  • ✅ Real‑time monitoring via Prometheus & Grafana for pipeline health and latency alerts.
  • ✅ Containerized deployment with Docker Compose for reproducible local dev and seamless CI/CD.
  • ✅ Full‑stack UI in React + TypeScript, delivering interactive dashboards and query results.

Technical Architecture

LayerTechnologyWhy It Was Chosen
Data WarehouseSnowflakeScalable, zero‑maintenance storage; native support for semi‑structured data and automatic clustering.
OrchestrationApache AirflowDAG‑based scheduling, rich UI, and extensible operators for Snowflake, dbt, and custom Python tasks.
TransformationdbtDeclarative SQL models, version control, testing, and documentation—all essential for analytics engineering.
Operational DBPostgreSQLStores user metadata, query history, and API tokens; reliable ACID guarantees.
API LayerFastAPIHigh‑performance async framework; automatic OpenAPI docs and easy integration with LLM inference services.
FrontendReact + TypeScriptStrong typing reduces bugs; component library enables rapid UI iteration and responsive charts.
ContainerizationDockerGuarantees environment parity across dev, CI, and production; simplifies scaling with Docker Compose/Kubernetes.
ObservabilityPrometheus + GrafanaMetrics‑first monitoring; Grafana dashboards visualize pipeline latency, error rates, and LLM latency.
AI EngineLarge Language Models (e.g., OpenAI GPT‑4) + RAGGenerates SQL from NL; Retrieval‑Augmented Generation ensures responses respect the current schema.
Vector StoreFAISS / Pinecone (abstracted)Fast similarity search over schema embeddings; critical for grounding LLM output.
SQL ParsingSQLGlotNormalizes and validates generated SQL, preventing injection and syntax errors before execution.

Data Flow Overview

  1. Raw event streams land in Snowflake staging tables.
  2. Airflow triggers dbt models that clean, enrich, and materialize fact tables.
  3. FastAPI exposes /query endpoint; it receives a natural‑language request.
  4. The request is embedded and matched against schema vectors → relevant table/column context is retrieved.
  5. LLM generates a candidate SQL query; SQLGlot parses and sanitizes it.
  6. Executed against Snowflake; results are cached in PostgreSQL for quick replay.
  7. React UI polls the API, renders results with Chart.js, and logs the interaction for analytics.

Challenges & How They Were Overcome

ChallengeSolution
LLM hallucination of non‑existent columnsImplemented a RAG pipeline that feeds only schema‑relevant snippets to the model. Coupled with SQLGlot validation, any stray identifiers cause a graceful fallback to a clarification prompt.
Cold‑start latency for vector searchPre‑computed embeddings for all tables/columns and persisted them in a FAISS index loaded at service start. Warm‑up scripts populate the cache during deployment, shaving >300 ms off response time.
Airflow‑dbt coupling failuresWrapped dbt runs in a DockerOperator with explicit exit‑code handling; added dbt test steps and automated Slack alerts on failure.
Observability gaps for LLM latencyExported custom Prometheus metrics (llm_inference_seconds, llm_retry_total) and visualized them in Grafana dashboards. Alert rules trigger when 95th‑percentile latency exceeds 2 s.
Schema drift (new tables added by data engineers)Built a schema watcher that runs nightly, regenerates embeddings, and updates the vector store without manual intervention.
Local development parityCreated a Docker Compose stack that spins up Snowflake‑compatible DuckDB, PostgreSQL, and a mock LLM server. Developers can iterate on the full stack with a single docker compose up.

These fixes turned a proof‑of‑concept into a production‑grade system that runs nightly jobs without human oversight.


Results & Impact

  • Query‑to‑insight time dropped from an average of 12 minutes (manual SQL + dashboard) to under 5 seconds via NL interface.
  • User adoption: 35 internal analysts migrated in the first month; average daily queries rose to 1,200.
  • Operational cost: Snowflake credits reduced by 22 % after dbt‑driven incremental models replaced full refreshes.
  • Reliability: Airflow DAG success rate hit 99.7 %; Prometheus alerts decreased by 48 % after the vector‑store warm‑up optimization.

🚀 Explore the code: View on GitHub
🔗 Live demo (sandbox): Coming soon – stay tuned!


Conclusion & What’s Next

Building a natural‑language analytics layer on top of a modern data stack proved that AI can be a first‑class citizen in data engineering, not an afterthought. The project taught me the importance of grounding LLM output, instrumenting every component, and designing for schema evolution.

Next steps

  1. Fine‑tune a domain‑specific LLM to improve SQL generation accuracy and reduce clarification loops.
  2. Integrate a feedback loop where analysts can up‑vote/down‑vote results, feeding supervised signals back into the model.
  3. Add streaming ingestion via Snowpipe to support near‑real‑time analytics for high‑velocity e‑commerce events.
  4. Expand visualization options with Plotly and Power BI connectors for broader enterprise adoption.

If you’re a recruiter, tech lead, or fellow engineer looking for a data platform that blends robust engineering with cutting‑edge AI, let’s connect. This project showcases a full‑stack solution that turns raw data into conversational insights—ready to scale with your organization’s ambitions.

Screenshots

Like what you see?

I'm available for freelance projects and full-time opportunities.