AI Engineer Interview — Project Walkthrough

Dual-Mode Financial Research Agent

A production-grade AI system combining a multi-agent LangGraph workflow, a fully-engineered RAG pipeline, and a memory-augmented chatbot — built for high-precision equity research across US and Indian markets.

LangGraphGemini EmbeddingsQdrant CloudGPT-OSS 1.12BRe-rankingYFinance APILogfireGuardrailsMemory Chatbot

End-to-End Pipeline

How a single ticker request flows through the full system — from raw API call to rendered report.

Data Ingestion — YFinance API + SEC EDGAR
STEP 1YFinanceSEC 10-K

Data Ingestion — YFinance API + SEC EDGAR

User submits a ticker. The backend calls the YFinance API for structured financials and fetches unstructured risk text from SEC EDGAR 10-K filings. For Indian stocks (.NS/.BO), Yahoo Finance is used directly.

Gemini Embedding + Semantic Chunking
STEP 2Gemini EmbeddingsChunking

Gemini Embedding + Semantic Chunking

Documents are split by semantic boundaries — not arbitrary token counts — ensuring each chunk is a coherent financial concept. Each chunk is then encoded into a dense vector using Google Gemini embedding models.

STEP 3Qdrant CloudDense + Sparse

Qdrant Cloud — Hybrid Vector Store

Vectors are persisted in Qdrant Cloud. Retrieval runs a hybrid search: dense similarity scores combined with metadata filters (ticker symbol, fiscal year) to guarantee strict isolation between different stocks and time periods.

Why Hybrid?

Pure dense search risks retrieving contextually similar but temporally wrong chunks (e.g., 2022 risks for a 2024 query). The sparse filter layer acts as a hard guardrail on top of semantic similarity.

STEP 4Re-rankingPrecision

Cross-Encoder Re-ranking

The top-K retrieved chunks are passed to a cross-encoder model that jointly scores the query and each chunk together — unlike bi-encoders that score independently. This dramatically improves the signal-to-noise ratio of context fed to the LLM.

Why Re-rank?

Bi-encoder retrieval optimizes for recall. Re-ranking optimizes for precision. In financial RAG, hallucinations from low-quality context are far more dangerous than missing a chunk — so we prioritize precision.

STEP 5LangGraphGPT-OSS 112BMulti-Agent

LangGraph Orchestration — GPT-OSS (120B params)

Re-ranked context is injected into a LangGraph workflow. Specialized nodes run in sequence: (a) Financial KPI analysis & peer comparison, (b) Deterministic DCF + WACC valuation, (c) Investment thesis generation with bull/bear cases.

Why LangGraph?

Declarative graph-based orchestration makes each agent step inspectable and testable independently. State is persisted across nodes, enabling the Reflection Loop to access all upstream outputs.

STEP 6Self-CritiqueHallucination Guard

Reflection Loop — Senior Analyst Agent

A second LangGraph agent reviews the complete draft report. It checks for logical contradictions, unsupported valuations, and consistency between DCF outputs and textual conclusions. The report is revised before being returned.

Output Guardrails & Schema Validation
STEP 7GuardrailsJSON Schema

Output Guardrails & Schema Validation

Before leaving the backend, all agent outputs are validated against a strict Pydantic schema. Guardrails reject malformed financial data, out-of-range valuations, and prevent prompt injection from making it into the stored report.

Logfire Observability + Frontend Render
STEP 8LogfireTracing

Logfire Observability + Frontend Render

Every pipeline step is traced via Pydantic Logfire — LLM latency, retrieval scores, re-ranking deltas, and LangGraph state transitions. The validated report is returned as structured JSON and rendered in the Next.js dashboard with a memory-augmented chatbot for follow-up questions.

1

Production RAG Pipeline

Ingestion & Semantic Chunking

Ingestion & Semantic Chunking

YFinance + SEC

Fetches structured financial data via YFinance API and unstructured SEC 10-K filings. Documents are chunked using semantic boundaries to preserve contextual integrity of risk disclosures.

Gemini Embeddings

Gemini Embeddings

Dense Vectors

Each chunk is encoded into high-dimensional dense vectors using Google Gemini embedding models, capturing deep financial semantics beyond keyword matching.

Qdrant Cloud Vector DB

Hybrid Search

Vectors stored in Qdrant Cloud DB. Retrieval combines dense similarity with sparse metadata filters (ticker, fiscal year) — preventing cross-stock contamination.

Cross-Encoder Re-ranking

Precision Boost

Retrieved candidates pass through a cross-encoder re-ranker. This second-pass scoring penalizes context mismatches and surfaces the most relevant chunks, drastically cutting hallucinations.

2

LLM Engine & Guardrails

GPT-OSS (120B Parameters)

1.12B Params

Uses an open-source 1.12B parameter model served via Groq for ultra-low latency inference. Right-sized for structured financial reasoning — DCF math, peer analysis, and thesis generation.

Input / Output Guardrails

Input / Output Guardrails

Safety Layer

Implemented guardrails that enforce strict JSON schema output, block prompt injection, and validate financial math consistency before the response is returned to the client.

3

LangGraph Multi-Agent Workflow

Financials & Peer Analysis Node

Agent Node

Dedicated LangGraph node that pulls live KPIs (YoY revenue, operating margin), auto-discovers industry peers, and computes comparative performance differentials.

DCF Valuation Node

Deterministic

Runs a fully deterministic DCF + WACC calculation — no LLM math guessing. Generates a sensitivity grid across WACC and terminal growth rate scenarios.

Senior Analyst Reflection Loop

Self-Critique

A second LangGraph agent critiques the draft report before finalization. It checks for internal contradictions, unsupported claims, and logical consistency — functioning as an automated QA gate.

4

Chatbot & Observability

Memory-Augmented Chatbot

Memory-Augmented Chatbot

Stateful

Conversational agent with persistent session memory. Users can interrogate the generated report — asking follow-up questions about DCF assumptions, risks, or peer comparisons contextually.

Logfire Observability (Pydantic)

Logfire Observability (Pydantic)

Full Tracing

Every LLM call, vector retrieval, re-ranking score, and LangGraph state transition is traced via Pydantic Logfire. Provides deep visibility into latency, token usage, and agent decision paths.