How harsh-vardhhan/ai-agent-flight-scanner works
Project type and purpose
• This is a full-stack, retrieval-augmented generation (RAG) service for flight-price queries.
• It consists of a dedicated backend (FastAPI + LangChain + LLMs + SQLite + Chroma) plus a separate frontend repo.
• Purpose: accept natural-language flight queries, retrieve policy and flight data, generate/verify SQL via LLMs, fetch results, and return an answer.
File structure
Top-level:
• app/
– main.py: REST entry point
– config.py: environment & API-key management
– database.py & models.py: ORM + connection to SQLite
– vector_db.py: Chroma vector store wrapper
– llm.py: LLM client abstractions (Groq, Ollama, Qwen, Llama)
– query_chain.py: LangChain agent orchestrator
– *.py (prompts, validators, extractors): modular prompt‐engineering
• data/
– flight_data.json: seed flight records
– indigo_policy.txt, vietjet_policy.txt: airline policy docs
• README + requirements.txt: dep list & architecture spec
README for additional insights
• Tech stack table: details on LLM platforms, vector & SQL DBs, REST framework.
• Architecture image: shows flow from frontend → FastAPI → LangChain chain → LLMs & DBs → response.
• Environment variables: GROQ_API_KEY, OPENAI_API_KEY, DEEPSEEK_API_KEY.
Main components & interactions
a. Components
1. Client / Frontend
2. API Layer (FastAPI server; main.py)
3. Orchestration Layer (LangChain QueryChain)
4. LLM Services
– Groq (large LLM)
– Ollama (small LLM for embeddings)
– Qwen (SQL generation/verification)
– Llama (vector embedding model)
5. Data Stores
– SQLite (flight_data & query logs)
– Chroma Vector DB (embedding index over policies & flights)
6. Configuration / Secrets (.env)
b. Relationships & data flow
1. User → Frontend → HTTP request → FastAPI
2. FastAPI loads config → passes prompt → QueryChain
3. QueryChain splits work:
• Runs embedding retriever → Chroma → returns context
• Runs SQL‐generation LLM → generates SQL
• Runs SQL‐verification LLM → validates SQL
4. Verified SQL → SQLite → result rows
5. Results + context → LLM response prompt → final answer
6. FastAPI → JSON response → Frontend → User
c. Architectural patterns
• Layered (API / orchestration / data)
• Modular prompt‐engineering
• LLM‐as‐service (polyglot LLM strategy)
• Retrieval + generation pipeline (RAG)
d. Key technologies
• FastAPI
• LangChain
• Groq, Ollama, Qwen, Llama
• SQLite (+ SQLAlchemy models)
• Chroma