0% found this document useful (0 votes)
3 views4 pages

Interview Prep

This document serves as a preparation guide for technical interviews related to the Agentic RAG for Time-Series Analysis project, detailing its architecture, technology stack, and component functionalities. It outlines the full-stack AI application that integrates data engineering, machine learning, and generative AI, along with potential interview questions and answers. Key technologies include PostgreSQL, Apache Airflow, FastAPI, and React, emphasizing the project's innovative use of AI agents and anomaly detection methods.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

Interview Prep

This document serves as a preparation guide for technical interviews related to the Agentic RAG for Time-Series Analysis project, detailing its architecture, technology stack, and component functionalities. It outlines the full-stack AI application that integrates data engineering, machine learning, and generative AI, along with potential interview questions and answers. Key technologies include PostgreSQL, Apache Airflow, FastAPI, and React, emphasizing the project's innovative use of AI agents and anomaly detection methods.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Agentic RAG for Time-Series

Analysis: Interview
Preparation Guide
This document is designed to help you explain every technical aspect of this project in-depth during a technical interview.
It breaks down the architecture, the technology stack, what every component does, and common interview questions you
might face.

1. High-Level Architecture & Tech Stack


This project is a Full-Stack AI Application that combines traditional Data Engineering, Machine Learning, and cutting-
edge Generative AI (Agentic workflows and RAG).

The Tech Stack:

Database & Vector Store: PostgreSQL 16 + pgvector


Data Ingestion: Apache Airflow, yfinance (Python)
Data Transformation: dbt (Data Build Tool)
Machine Learning: scikit-learn (Isolation Forest), xgboost, statsmodels (ARIMA)
AI Agents & LLM: LangGraph, Google Gemini 1.5 Flash, langchain-google-genai
Backend API: FastAPI (Python), Uvicorn
Frontend UI: React, Vite, Axios, Recharts (Vanilla CSS with Glassmorphism)

2. Component Breakdown: What Each File


Does
Phase 1 & 2: Data Engineering (Ingestion & Transformation)
[Link] & init/[Link]
What it does: Sets up a PostgreSQL database and installs the pgvector extension. [Link] creates
specific schemas (metrics, marts, embeddings) and tables, including the HNSW index for fast vector
similarity search.
Interview Talking Point: Emphasize that you used a single database for both relational data (time-series)
and vector embeddings (RAG) to reduce infrastructure complexity.
seed_data.py (and airflow/dags/ingest_real_data.py)
What it does: Uses the yfinance library to download the last 30 days of real stock market data (Apple,
Google, S&P 500) and inserts it into the metrics.raw_data table.
Interview Talking Point: Shows you know how to pull real-world API data and interact with SQL
databases using SQLAlchemy and Pandas.
dbt/models/
What it does: Transforms raw incoming data. It aggregates timestamps to hourly/daily intervals and
computes ML features like rolling averages and lag features (e.g., what was the price 24 hours ago).
Interview Talking Point: Demonstrates best practices in modern data stacks (ELT instead of ETL). You
didn't just write python scripts; you used dbt for version-controlled, testable SQL transformations.

Phase 3: Machine Learning Hub


models/time_series_hub.py
What it does: Contains the core statistical and ML logic.
ARIMA: A classic statistical model used for univariate forecasting (predicting the future based
strictly on past trends of the same variable).
XGBoost: A powerful gradient-boosted tree model used for multivariate forecasting (predicting the
future using all those lag features generated by dbt).
Isolation Forest: An unsupervised anomaly detection algorithm. It finds data points that are "few
and different" (spikes or crashes in stock price).
Interview Talking Point: You used Isolation Forests to detect anomalies, and then automatically triggered
Gemini to write a natural language summary of that anomaly. You then converted that text summary into a
vector embedding and stored it in pgvector. This marries traditional ML with GenAI!

Phase 4: Agentic AI Workflow (LangGraph)


agents/langgraph_agents.py
What it does: Defines the individual "skills" of the AI.
Master Router: Takes the user's prompt and asks Gemini which sub-agents are needed (Intent
Classification).
SQL Agent: Runs SQL queries against the dbt marts to get exact numerical data.
Time-Series Agent: Runs the ARIMA/XGBoost models dynamically to predict the future.
Vector RAG Agent: Converts the user's prompt into an embedding and does a cosine similarity
search (<->) in pgvector to find explanations for past anomalies.
agents/main_graph.py
What it does: Uses LangGraph to wire these agents together into a Directed Acyclic Graph (DAG). The
Router sends the user to the sub-agents in parallel using a conditional_edge. Then, all agents send
their data to the Synthesis Agent, which uses Gemini to combine the raw numbers, forecasts, and RAG
context into a conversational response.
Interview Talking Point: Explain the difference between a standard LLM Chain and an Agentic Workflow.
In a chain, execution is linear. In your LangGraph setup, the AI makes decisions about what tools to use,
runs them in parallel, and synthesizes the results.
Phase 5: Full-Stack Application
backend/[Link]
What it does: A lightweight FastAPI server that exposes the LangGraph workflow via a /api/chat
POST endpoint. It handles CORS so the frontend can securely communicate with it.
frontend/src/[Link]
What it does: A modern React application (built with Vite) that provides the chat UI. It uses axios to talk
to the backend, and Recharts to dynamically render the historical stock data alongside the future AI
predictions.
Interview Talking Point: Demonstrates you aren't just a backend/data engineer, but you can build
premium, user-facing products with modern hooks (useState), asynchronous API fetching, and dynamic
data visualization.

3. Potential Interview Questions &


Answers
Q1: Why did you use pgvector instead of a dedicated vector database like Pinecone or Milvus? Answer: "For
this project, the vector data (anomaly summaries) is tightly coupled with the relational time-series data. By using
PostgreSQL with the pgvector extension, I simplified the infrastructure, eliminated the need to synchronize data
between two different databases, and could theoretically perform hybrid queries (e.g., joining relational stock metadata
with vector similarity searches) in a single SQL query."

Q2: How does your system handle Hallucinations from the LLM? Answer: "The system is designed with a strict
Agentic RAG architecture. The LLM is not allowed to guess stock prices. Instead, the Master Router identifies the intent,
delegates to a deterministic SQL Agent (to fetch exact hard numbers) and a Time-Series Agent (to run deterministic ML
forecasting algorithms). The final Synthesis Agent is strictly prompted to base its answer only on the hard data provided
by these sub-agents, significantly reducing hallucinations."

Q3: What is LangGraph, and why use it over standard LangChain? Answer: "Standard LangChain is great for linear
pipelines (Prompt -> LLM -> Output). However, building complex AI requires state management and cycles. LangGraph
allows me to define the AI workflow as a State Machine (a Directed Acyclic Graph). It maintains an AgentState object
that gets passed around and updated by different nodes, allowing for dynamic branching (running agents in parallel) and
much more robust error handling."

Q4: Explain how you detect anomalies and use RAG. Answer: "First, the system runs an Isolation Forest algorithm
over the time-series data to detect statistical outliers. When an outlier is found, I pass the raw numbers to the Gemini API
to generate a human-readable summary of the event (e.g., 'AAPL dropped 5% on Tuesday'). I then use Google's
embedding model to convert that text into a vector and store it in PostgreSQL. Later, when a user asks 'Why did Apple
drop?', the Vector RAG Agent embeds their question, does a similarity search in Postgres, retrieves that exact context,
and feeds it to the LLM to answer the user."
Q5: Why did you choose FastAPI and React/Vite? Answer: "FastAPI is the modern standard for Python backends
because it's asynchronous, incredibly fast, and automatically generates Swagger documentation via Pydantic models.
Vite was chosen for the React frontend because it uses native ES modules for lightning-fast Hot Module Replacement
(HMR) during development, making the UI iteration process much faster than traditional Webpack/Create-React-App."

You might also like