An AI-powered travel assistant for US hotels. Chat with it to find hotels by location, price, and rating; browse results as cards; pick one and ask what guests actually say about it β answered from real reviews via hybrid (vector + metadata) retrieval.
Built as a production-grade MVP with three subsystems:
- ETL pipeline (Apache Airflow) β populates a single Postgres + pgvector DB from public data sources.
- LangGraph agent (Gemini) β constrained, typed tools + RAG over reviews, with durable conversation state.
- FastAPI + Streamlit β streaming chat API and a step-by-step chat UI.
- Conversational hotel search β "hotels in NYC under $300, 4+ stars" β ranked results.
- Dynamic slot-filling β asks for a location when it's missing; applies price/rating filters when given.
- Pick & drill in β select a hotel and ask follow-ups ("is it quiet?", "good for families?"); context persists across turns.
- Review-grounded answers β sentiment/aspect Q&A from real guest reviews (hybrid pgvector search), never fabricated.
- Step-by-step chat UX β the agent emits messages as actions (
say/show_hotels); the UI streams a loader β cards carousel β answer. - Production-grade ETL β idempotent upserts, raw-payload staging, a monthly API-budget guardrail, and runtime-configurable params.
- Observability β LangSmith tracing of every tool call and token.
ββββββββββββββββββββββββββββββββ
β Streamlit UI (:8501) β chat, hotel-card carousel
βββββββββββββββββ¬ββββββββββββββββ
β SSE
βββββββββββββββββΌββββββββββββββββ
β FastAPI (:8000) /chat /healthβ
β ββ LangGraph ReAct agent β gemini-2.5-flash
β tools: search_locations, β
β search_hotels, get_hotel_β
β details, search_reviews, β
β say, show_hotels β
β ββ Postgres checkpointer β durable per-thread state
βββββββββββββββββ¬ββββββββββββββββ
β psycopg3
βββββββββββββββββΌββββββββββββββββ
β PostgreSQL 16 + pgvector β cities, locations, hotels,
β (data DB, host :5433) β reviews, review_embeddings
βββββββββββββββββ²ββββββββββββββββ
β idempotent upserts
βββββββββββββββββ΄ββββββββββββββββ
β Airflow 3 DAG `travel_mitra_etl`β
β load_cities β resolve_locations β
β β fetch_hotels β fetch_reviews β
β β embed_reviews β
β (UI :8080, own metadata DB) β
ββββββββββββββββββββββββββββββββββ
- simplemaps CSV β
cities(no API). - TripAdvisor Content API (
category=geos) βlocations(city β geo id), and/reviewsβ review text. - Xotelo API (free) β
hotelsper location (price range, rating, mentions, image, URL). - Gemini
gemini-embedding-001(768-dim) βreview_embeddingsfor hybrid RAG.
| Layer | Tech |
|---|---|
| UI | Streamlit |
| API | FastAPI + SSE (sse-starlette) |
| Agent | LangGraph (prebuilt ReAct) + langchain-google-genai (gemini-2.5-flash) |
| Conversation state | langgraph-checkpoint-postgres (AsyncPostgresSaver) |
| Embeddings | Gemini gemini-embedding-001 (768-dim, via REST) |
| Data layer | psycopg3 + pgvector (no ORM β "code owns the SQL") |
| DB | PostgreSQL 16 + pgvector |
| ETL | Apache Airflow 3 (LocalExecutor) |
| Observability | LangSmith |
| Infra | Docker Compose |
Travel-mitra-2.0/
ββ docker-compose.yml # full stack: postgres x2, airflow x4, api, ui
ββ .env.example # required secrets/config
ββ requirements-api.txt # API image deps
ββ requirements-ui.txt # UI image deps
ββ requirements-agent.txt # local venv (notebook + api + ui)
ββ db/migrations/ # 0001_init, 0002_api_tables, 0003_embedding_model (auto-applied)
ββ data/ # simplemaps uscities CSV (seed)
ββ etl/ # ETL package (sources, transforms, load, embed, budget)
ββ airflow/
β ββ Dockerfile # Airflow 3 + ETL deps
β ββ dags/travel_mitra_dag.py # the staged, idempotent DAG
ββ agent/ # LangGraph agent (tools, queries, graph, prompts, llm)
ββ app/ # FastAPI app (main, runtime, schemas) + Dockerfile
ββ ui/ # Streamlit app + Dockerfile
ββ notebooks/01_agent_prototype.ipynb
- Docker + Docker Compose
- A Gemini API key (https://aistudio.google.com/apikey)
- A TripAdvisor Content API key (only needed to run the ETL; the demo works on already-loaded data)
cp .env.example .envFill in .env:
GEMINI_API_KEY=your_gemini_key
TRIPADVISOR_API_KEY=your_tripadvisor_key # for ETL only
TRIPADVISOR_REFERER=https://your-allowlisted-domain.com # must match the key's domain restriction
# Optional tracing:
LANGSMITH_TRACING=false
LANGSMITH_API_KEY=A Fernet key and an Airflow JWT secret are pre-filled for local dev β rotate for anything non-local.
docker compose up airflow-initdocker compose up -d
docker compose ps| Service | URL | Notes |
|---|---|---|
| Chat UI | http://localhost:8501 | Streamlit |
| Chat API | http://localhost:8000/health | FastAPI |
| Airflow | http://localhost:8080 | admin / admin |
| Data DB | localhost:5433 |
app / app / travelmitra |
The data DB schema auto-applies on first volume init (via docker-entrypoint-initdb.d).
- Open Airflow at http://localhost:8080.
- Enable & trigger
travel_mitra_etl(βΆ Trigger DAG w/ config). - Tune runtime params (all defaulted) β e.g. start small:
top_n_cities = 5review_hotels_per_location = 20
Stages: load_cities β resolve_locations β fetch_hotels β fetch_reviews β embed_reviews.
Everything is idempotent (ON CONFLICT upserts) and budget-aware (a monthly
TripAdvisor call cap, tracked in api_call_log) β re-running never duplicates rows or
re-spends API calls.
The free TripAdvisor reviews endpoint returns ~5 reviews/hotel; reviews are fetched for a price-stratified top-K per city to keep coverage across budget/mid/luxury tiers.
Open http://localhost:8501 and try:
- "Hotels in New York under $300, 4+ stars" β a lead-in + a scrollable card carousel.
- Click π¬ Ask on a card (or "tell me about the second one") β drills into that hotel.
- "Is it quiet and good for families?" β a review-grounded answer.
- Use the sidebar to start a New chat or switch between previous conversations (each keeps its own context).
Run the agent or notebook against the containerized DB without rebuilding images:
python -m venv .venv
.venv/Scripts/activate # Windows; source .venv/bin/activate on macOS/Linux
pip install -r requirements-agent.txt
# Notebook prototype
jupyter notebook notebooks/01_agent_prototype.ipynb
# Or run the API locally (DB at localhost:5433)
uvicorn app.main:app --reload --port 8000
# Or the UI locally
streamlit run ui/streamlit_app.pyThe agent reads DATABASE_URL (default localhost:5433 on the host) and GEMINI_API_KEY
from the environment / .env.
| Variable | Used by | Purpose |
|---|---|---|
GEMINI_API_KEY |
agent, ETL embed | Gemini LLM + embeddings |
TRIPADVISOR_API_KEY |
ETL | locations + reviews |
TRIPADVISOR_REFERER |
ETL | must match the key's domain allowlist (sent as Referer) |
DATABASE_URL |
agent/API | data DB DSN (psycopg3) |
AGENT_MODEL |
agent | defaults to gemini-2.5-flash |
LANGSMITH_* |
agent/ETL | optional tracing |
TRIPADVISOR_MONTHLY_BUDGET |
ETL (Airflow Variable) | hard call cap (default 4500) |
ETL operational knobs (top_n_cities, review_hotels_per_location, price tiers, β¦) are
DAG params, overridable per run with sensible defaults.
- Constrained, typed tools β not a free-form SQL agent. The LLM picks a tool and fills args; our code owns the SQL. Safe, deterministic, testable.
- psycopg3, no ORM. Hybrid vector+metadata queries are clean in raw SQL; same driver as the LangGraph checkpointer.
- Hybrid review search.
review_embeddingsdenormalizeslocation_id / city_id / price / hotel_rating / accommodation_type, so vector similarity + structured filters run in one query. - "Talking is an action." The agent communicates only via
say()/show_hotels(), emitting messages step by step and stopping at success β the app renders each as its own bubble. - Embedding model tracked per row (
review_embeddings.model) so a model change can re-embed only stale rows.
- Live date-based pricing via Xotelo
/rates(anestimate_staytool β schema already supports it). - Evals (golden Q&A: tool-selection accuracy + answer relevance).
- Test suite (pytest, unit + integration) toward 80% coverage.
- Containerized UI live-reload / CI.
- US hotels only, for the cities loaded into the catalog. No booking, availability, or date-specific pricing in v1.
- Secrets live in
.env(gitignored). Never commit real keys; rotate anything exposed.