Skip to content

RAG App — Operational Reference

Full reference for apps/rag/. For behavior rules and architecture overview see apps/rag/CLAUDE.md.

Stats

Metric Value
Embeddings 11,536 chunks
Documents 270 PDFs (NCERT Classes 10-12)
Embedding Model Vertex AI text-embedding-004 (768 dims)
Vector DB Cloud SQL PostgreSQL + pgvector (HNSW index)
Search Latency 50–100 ms

Environment Variables

# Production (Cloud Run Job) — secrets via Secret Manager
DATABASE_URL=postgresql+asyncpg://...

# Local development
DATABASE_URL=postgresql+asyncpg://postgres:password@localhost:5432/vidyanet
GCP_PROJECT_ID=vidyanet-prod
GCP_LOCATION=asia-south1
# Auth: gcloud auth application-default login

Vertex AI uses Application Default Credentials — no API key needed.

CLI Command Reference

python -m src.cli.main init-db
python -m src.cli.main ingest <folder_id> --board NCERT --recursive
python -m src.cli.main search "quadratic equations" --class 10 --subject Mathematics
python -m src.cli.main stats
python -m src.cli.main server --port 8001 --reload
python -m src.cli.main setup-gdrive --credentials credentials/client_secret.json

Cloud Run Job

Setting Value
Job Name vidyanet-rag-ingestion
Project / Region vidyanet-prod / asia-south1
Memory / CPU 2 Gi / 2
Timeout 3600 s

Execute textbook ingestion

gcloud run jobs execute vidyanet-rag-ingestion \
  --project=vidyanet-prod --region=asia-south1 \
  --update-env-vars="^:^JOB_TYPE=textbook:CLASSES=10,11,12:SUBJECTS=Mathematics,Physics,Chemistry,Biology,Accountancy"

Execute Google Drive ingestion

gcloud run jobs execute vidyanet-rag-ingestion \
  --project=vidyanet-prod --region=asia-south1 \
  --update-env-vars="JOB_TYPE=gdrive,GDRIVE_ROOT_FOLDER_ID=<folder-id>,BOARD=NCERT,RECURSIVE=true"

Vector Index Notes

  • HNSW index on curriculum_embeddings(embedding) — 768 dims.
  • Rebuild index after bulk ingestion if recall degrades; ef_construction=64 is the current default.
  • For datasets > 1 M rows consider switching to IVFFlat with lists = sqrt(rows).

Database Tables

Table Rows (approx.) Purpose
curriculum_embeddings 11,536 Vector embeddings + metadata
rag_document_metadata 270 Document tracking and ingestion status