An end-to-end application combining an e-commerce shop for Himalayan trail maps/books, a RAG-powered AI chatbot, a data engineering pipeline, and a data contracts framework — all themed around Nepal's Great Himalaya Trail.
┌─────────────────────────────────────────────────────────────────────┐
│ Frontend (React/Vite) │
│ Pages: Home, Journeys, Plan, Culture, Shop, Admin Dashboard │
│ Components: CartDrawer, ChatWidget, MapProductCard, BookCard │
└────────────────────────────────────┬────────────────────────────────┘
│ REST API
┌────────────────────────────────────▼────────────────────────────────┐
│ Backend (FastAPI + SQLAlchemy) │
│ Routes: /api/products, /api/checkout, /api/chat, /api/admin │
│ Models: Product, Order, OrderItem │
│ Integrations: Stripe Payments, SMTP Email, RAG Chatbot │
└────────────────────────────────────┬────────────────────────────────┘
│
┌────────────────────────────────────▼────────────────────────────────┐
│ AI / RAG Pipeline (LangChain) │
│ Embeddings: sentence-transformers/all-MiniLM-L6-v2 │
│ Vector Store: FAISS (in-memory) │
│ LLM: MockLLM (pluggable for OpenAI/Ollama) │
│ Knowledge: Trail conditions, permits, logistics, weather, health │
└─────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────┐
│ Data Engineering Pipeline (Airflow + PySpark) │
│ ELT DAG: Extract → Load → Transform │
│ Structured: weather/flight logs (dedup, type coercion, quarantine) │
│ Unstructured: trail reviews (deduplication) │
└─────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────┐
│ Data Contracts (Pydantic + Pandas) │
│ YAML contract → Schema check → Quality assertions → Freshness SLA │
│ Output: clean records + quarantine records + violation details │
└─────────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────────┐
│ Reverse ETL (Push to CRM) │
│ Reads cleaned leads from warehouse → pushes to mock CRM API │
│ Personalised trek recommendations for sales teams │
└─────────────────────────────────────────────────────────────────────┘
- React + Vite single-page application
- Pages: Homepage, Journeys (trek routes), Plan (logistics), Culture, Shop (maps & books)
- E-commerce: cart, Stripe checkout, order success/cancel flows
- Admin panel: dashboard, products CRUD, orders, fulfillment, inventory
- AI chatbot widget for trail/logistics questions
- FastAPI REST API with SQLAlchemy ORM (SQLite dev / Postgres prod)
- Products: digital maps, physical books, donations, bundles
- Checkout: Stripe payment sessions with webhook handling
- Admin: CRUD, order management, revenue dashboard, inventory alerts
- Secure downloads: HMAC-SHA256 time-limited tokens
- Rate limiting via slowapi
- LangChain RetrievalQA chain
- Knowledge base: 20 documents covering flights, trails, permits, accommodation, weather, health
- Embeddings: HuggingFace
all-MiniLM-L6-v2(local, no API key needed) - Vector store: FAISS in-memory index
- LLM: MockLLM (formats retrieved context into answers; pluggable for OpenAI/Ollama)
- Endpoint:
POST /api/chatwith rate limiting
- Apache Airflow DAG (
himalayan_ai_elt) with 3 sequential tasks:- Extract: Generate mock structured (weather/flight logs) + unstructured (trail reviews) data
- Load: Stage raw data into warehouse (simulates Snowflake/Databricks)
- Transform: PySpark cleansing — deduplication, type coercion, null handling, quarantine flagging
- Standalone PySpark script for development/testing without Airflow
- YAML-defined contracts with schema, quality assertions, and freshness SLAs
- Schema check: column presence + dtype validation
- Quality check:
not_null,is_numericrules → row-level clean/quarantine split - Freshness check: daily SLA violation detection
- Pydantic models for contract definitions
- Comprehensive test suite (schema, quality, freshness, public API)
- Reads cleaned customer-lead data from the data warehouse
- Pushes enriched trekking leads to a mock CRM (Salesforce/HubSpot style)
- Lead scoring and filtering before sync
- Enables personalised trek recommendations for sales teams
Components 1–5 are wired together so a single user question in the browser can be answered with data that flowed all the way through the pipeline. Below is exactly how each hand-off is implemented.
[Data Pipeline] PySpark transform → curated/ (flights_clean, trail_reviews_clean)
│ data_pipeline/spark_transform.py
▼
[Data Contracts] validate_with_contract() loads contract.yaml and runs
schema + quality + freshness checks over curated flights
│ data_contracts/validator.py :: validate()
▼
[RAG] build_corpus(curated_dir) reads trail_reviews_clean and
merges it with the static DOCUMENTS list before indexing
│ backend/rag_pipeline.py :: load_curated_reviews / build_corpus
▼
[Backend API] POST /api/chat invokes the RetrievalQA chain
│ backend/routes/chat.py
▼
[Frontend] ChatWidget posts the user's question to /api/chat
src/components/ChatWidget.jsx
data_pipeline/spark_transform.py added a validate_with_contract(curated_dir) step that runs after the Spark transform finishes:
- Reads
curated/flights_clean/*.json(JSON Lines written by Spark) into a Pandas DataFrame. - Loads the YAML contract via
data_contracts.load_contract("data_contracts/contract.yaml"). - Calls
data_contracts.validate(df, contract, last_refreshed=now)— schema, quality, and freshness assertions run together; failed rows go to a quarantine set, and freshness violations are reported. - Prints
clean=N quarantine=N freshness_violated=boolso the pipeline (and Airflow logs) record contract status.
backend/rag_pipeline.py gained two helpers that let the chatbot consume the warehouse's curated unstructured data:
load_curated_reviews(curated_dir)— walkscurated/trail_reviews_clean/*.json, parses each JSON Lines record, and returns a list ofreview_textstrings. Returns[]when the directory does not exist, so the RAG service still boots without a pipeline run.build_corpus(curated_dir=None)— concatenates the staticDOCUMENTSknowledge base withload_curated_reviews(curated_dir). Callers pass this list tobuild_vector_store()so FAISS indexes both static facts and freshly-validated trail reports.
backend/routes/chat.py builds the vector store and RetrievalQA chain at module load and exposes them via POST /api/chat. Request: { "question": str }. Response: { "answer": str, "sources": [{ "text": str }, ...] }. Rate-limited to 10/min via slowapi.
src/components/ChatWidget.jsx issues fetch("/api/chat", { method: "POST", body: JSON.stringify({ question }) }) and renders the returned answer inside the floating chat widget mounted in src/App.jsx.
The end-to-end wiring is locked in by a single integration test, backend/tests/test_integration_e2e.py, which:
- Runs a Pandas stand-in of the Spark transform (same dedup + quarantine logic, no JVM) and writes JSON Lines into a
tmp_path/curated/directory. - Loads
data_contracts/contract.yamland asserts the curated flights pass schema + quality + freshness checks. - Calls
build_corpus(curated_dir)and asserts the curated trail reviews end up in the FAISS-indexed corpus and are retrievable. - POSTs a question to
/api/chatthrough FastAPI'sTestClientand asserts the response shape matches what the frontend'sChatWidgetconsumes.
# Run just the integration test
pytest backend/tests/test_integration_e2e.py -v
# Or the full suite (85 tests)
pytest backend/tests/ data_contracts/tests/# Install backend dependencies
pip install -r backend/requirements.txt
# Install frontend dependencies
npm install
# Run backend (mock Stripe mode)
STRIPE_MOCK=true uvicorn backend.main:app --reload --port 8000
# Run frontend
npm run dev
# Run data contracts demo
python data_contracts/demo.py
# Run PySpark transforms (standalone)
pip install pyspark
python data_pipeline/spark_transform.py
# Run reverse ETL demo
python reverse_etl/push_to_crm.py# Backend tests
cd backend && pytest
# Data contracts tests
pytest data_contracts/tests/
# Frontend E2E tests (Playwright)
npx playwright test
# Run RAG pipeline demo
python backend/rag_pipeline.py| Layer | Tech |
|---|---|
| Frontend | React, Vite, React Router |
| Backend | FastAPI, SQLAlchemy, Alembic, Stripe |
| AI/ML | LangChain, FAISS, sentence-transformers, HuggingFace |
| Data Engineering | Apache Airflow, PySpark, Pandas |
| Data Quality | Pydantic, PyYAML, custom validator |
| Testing | pytest, Playwright |
| Infrastructure | Docker, Docker Compose |