# Kirana AI — RAG-Powered Brand Product Search Engine This is the v2.0 upgrade of the Indian FMCG product catalog project: the same discovery/enrichment pipeline (Ollama + pgvector + S3 image storage), now with a **Retrieval-Augmented Generation (RAG) layer** and a **React UI** in place of the old Streamlit app. Two independent pieces: - **`backend/`** - FastAPI service. Browse/search/chat endpoints over a pgvector-backed catalog; a RAG chat endpoint that retrieves relevant products and asks a local Ollama model to answer grounded in them. - **`frontend/`** - React + Vite single-page app: product search/browse grid, a conversational "Ask AI" panel with source citations, and an admin page to ingest new brands. See **`docs/`** for the full architecture write-up, setup guide, and API reference — including **`docs/SKU_RESOLVER.md`** for the Product Resolver library (`POST /api/resolve`), which accepts any BigBasket product ID, Amazon ASIN, or Internal SKU, resolves it against the database or the matching external source, and stores it for next time. The two component READMEs (`backend/README.md`, `frontend/README.md`) are quick local references once you've read the main docs once. ## Fastest path to a working demo ```bash # 1. Backend cd backend python3 -m venv .venv && source .venv/bin/activate # Windows: .venv\Scripts\activate pip install -r requirements.txt cp .env.example .env # edit DB_PASSWORD, see docs docker compose -f ../docker-compose.yml up -d # local Postgres+pgvector (skip if you already have one) python scripts/seed_sample_data.py # loads bundled sample catalogs - no LLM needed ollama pull qwen2.5:1.5b # one-time uvicorn app.main:app --reload --port 8000 # 2. Frontend (new terminal) cd frontend npm install npm run dev ``` Open http://localhost:5173, pick a brand, try the search bar, then switch to **Ask AI** and ask something like "recommend a low sugar biscuit". ## Why this exists (what changed from v1.0) The original project (`Project_LLM`) could discover, enrich, and store products with embeddings in pgvector - but nothing ever read those embeddings back out. There was no similarity-search function, no API layer (`app/api/` was an empty folder), and the UI was a Streamlit app that only ever queried the catalog by exact brand/category, never by meaning. This project adds the missing retrieval layer (`vector_store.semantic_search`), a RAG orchestration service (`rag_service.py`), a full FastAPI surface, and a React UI to use it. It also fixes a real security issue: `app/infrastructure/settings.py` used to hard-code a live database host/port/password as Python literal fallbacks. Every credential now comes only from environment variables/`.env` - see `backend/app/infrastructure/settings.py` for details, and `docs/` for the full write-up.