How atharva-kulkarni123/aws-rag-pipeline works
This repository provides an AWS-hosted RAG API: clients submit PDFs for ingestion or ask questions grounded in ingested documents. The API routes dispatch ingestion into PDF extraction, chunking, embedding, and storage; query handling runs retrieval, reranking, prompt construction, and answer generation. The README also documents AWS infrastructure and a one-time database bootstrap, but sampled infrastructure source was not provided, so those deployment components are represented only at a high level. Relationships for internal query helpers rely on the excerpted RAG orchestrator; other unshown details are omitted.
Main entry points: main.py FastAPI app · ingestion.py Ingestion orchestration · rag_service.py RAG orchestration · query.py Query route
Components 26
API
- FastAPI app
RAG-codebase/api/main.py - Query route
RAG-codebase/api/routes/query.py - Ingest route
RAG-codebase/api/routes/ingest.py - Request and response models
RAG-codebase/api/models - Cognito auth middleware
RAG-codebase/api/middleware/auth.py - Request logging
RAG-codebase/api/middleware/logging.py
Ingestion
- Ingestion entry point
RAG-codebase/RAG-Ingestion/run_ingestion.py - Ingestion orchestration
RAG-codebase/RAG-Ingestion/ingestion/ingestion.py - S3 document access
RAG-codebase/RAG-Ingestion/s3_client.py - PDF page extraction
RAG-codebase/RAG-Ingestion/pdf_processor.py - Text chunking
RAG-codebase/RAG-Ingestion/ingestion/chunker.py - Titan embeddings
RAG-codebase/RAG-Ingestion/embedding/embedding.py - Chunk vector storage
RAG-codebase/RAG-Ingestion/vectorstore/vectordb.py
Retrieval and Generation
- RAG orchestration
RAG-codebase/RAG-Retrieval/rag_service.py - Query embeddings
RAG-codebase/RAG-Retrieval/embeddings.py - Vector retrieval
RAG-codebase/RAG-Retrieval/retriever.py - Postgres vector store
RAG-codebase/RAG-Retrieval/vector_store.py - Result reranking
RAG-codebase/RAG-Retrieval/reranker.py - Prompt construction
RAG-codebase/RAG-Retrieval/prompt.py - Answer generation
RAG-codebase/RAG-Retrieval/llm.py
AWS Platform
- Amazon Bedrock
- Amazon S3
- RDS PostgreSQL pgvector
- AWS network and ECS
Terraform - Database bootstrap
ansible/sql/schema.sql
Other components
- API client
Connections 31
- API client → FastAPI app: sends requests
README.md - FastAPI app → Cognito auth middleware: applies middleware
RAG-codebase/api/main.py - FastAPI app → Request logging: applies middleware
RAG-codebase/api/main.py - FastAPI app → Query route: registers route
RAG-codebase/api/main.py - FastAPI app → Ingest route: registers route
RAG-codebase/api/main.py - FastAPI app → RAG orchestration: initializes at startup
RAG-codebase/api/main.py - Query route → RAG orchestration: calls answer
RAG-codebase/api/routes/query.py - Query route → Request and response models: uses schemas
RAG-codebase/api/routes/query.py - Ingest route → Request and response models: uses schemas
RAG-codebase/api/routes/ingest.py - Ingest route → Ingestion entry point: dispatches ingestion
RAG-codebase/api/routes/ingest.py - Ingestion entry point → Ingestion orchestration: creates and runs
RAG-codebase/RAG-Ingestion/run_ingestion.py - Ingestion orchestration → S3 document access: lists and downloads
RAG-codebase/RAG-Ingestion/ingestion/ingestion.py - S3 document access → Amazon S3: reads PDFs
RAG-codebase/RAG-Ingestion/s3_client.py - Ingestion orchestration → PDF page extraction: extracts pages
RAG-codebase/RAG-Ingestion/ingestion/ingestion.py - Ingestion orchestration → Text chunking: creates chunks
RAG-codebase/RAG-Ingestion/ingestion/ingestion.py - Ingestion orchestration → Titan embeddings: embeds chunks
RAG-codebase/RAG-Ingestion/ingestion/ingestion.py - Ingestion orchestration → Chunk vector storage: stores chunks
RAG-codebase/RAG-Ingestion/ingestion/ingestion.py - Titan embeddings → Amazon Bedrock: invokes model
RAG-codebase/RAG-Ingestion/embedding/embedding.py - Chunk vector storage → RDS PostgreSQL pgvector: writes vectors
README.md - RAG orchestration → Vector retrieval: retrieves documents
RAG-codebase/RAG-Retrieval/rag_service.py - Vector retrieval → Query embeddings: embeds question
RAG-codebase/RAG-Retrieval/rag_service.py - Vector retrieval → Postgres vector store: searches vectors
RAG-codebase/RAG-Retrieval/rag_service.py - Postgres vector store → RDS PostgreSQL pgvector: searches chunks
README.md - RAG orchestration → Result reranking: reranks results
RAG-codebase/RAG-Retrieval/rag_service.py - RAG orchestration → Prompt construction: builds prompt
RAG-codebase/RAG-Retrieval/rag_service.py - RAG orchestration → Answer generation: generates answer
RAG-codebase/RAG-Retrieval/rag_service.py - Query embeddings → Amazon Bedrock: invokes embeddings
RAG-codebase/RAG-Retrieval/embeddings.py - Answer generation → Amazon Bedrock: requests answer
README.md - AWS network and ECS → FastAPI app: hosts privately
README.md - AWS network and ECS → RDS PostgreSQL pgvector: provisions database
README.md - Database bootstrap → RDS PostgreSQL pgvector: creates schema
README.md