A Retrieval Augmented Generation (RAG) system for semantic document search and Q&A over PDF files, powered by a LangGraph ReAct agent.
Live Demo: http://rag-alb-1726979633.us-east-1.elb.amazonaws.com/
- Document Upload: Upload and index PDF files directly from the browser
- Semantic Search: FAISS vector store with OpenAI
text-embedding-3-small - ReAct Agent: LangGraph ReAct agent for intelligent multi-step Q&A
- Web Search Fallback: Tavily search when answers aren't found in documents
- Source Citations: Every answer includes page-level source references
- Cloud-Native: S3 for PDFs, Secrets Manager for API keys, ECS Fargate for hosting
- Backend: FastAPI + Python 3.12
- AI: LangGraph ReAct agent, OpenAI embeddings, FAISS vector store
- APIs: OpenAI, Tavily
- Frontend: Vanilla JavaScript, HTML, CSS
- Cloud: AWS ECR + ECS Fargate + ALB + S3 + Secrets Manager
- CI/CD: GitHub Actions
- Python 3.12+
- API Keys:
- OpenAI API key
- Tavily API key
- Clone the repository:
git clone https://github.com/francis-rf/RAG-document-qa.git
cd RAG-document-qa- Install dependencies:
pip install -r requirements.txt- Create
.envfile:
cp .env.example .env
# Edit .env with your API keys- Run the application:
uvicorn app:app --reload --port 8000- Open browser:
http://localhost:8000
docker build -t rag-document-search .
docker run -p 8000:8000 --env-file .env rag-document-search| Service | Purpose |
|---|---|
| ECR | Container image registry |
| ECS Fargate | Serverless container hosting |
| Application Load Balancer | HTTP traffic routing |
S3 (rag-documents-qa) |
PDF document storage |
Secrets Manager (rag_document) |
API key storage |
| CloudWatch | Logs and monitoring |
| IAM | Task roles and permissions |
- Store API keys in AWS Secrets Manager under secret name
rag_document - Upload PDFs to S3 bucket
rag-documents-qa - Push Docker image to ECR
- Deploy via ECS Fargate with an ALB pointing to port 8000
The app is deployed and accessible at:
http://rag-alb-1726979633.us-east-1.elb.amazonaws.com/
Automated deployment is configured via .github/workflows/deploy.yml.
On every push to main, the pipeline:
- Checks out the code
- Configures AWS credentials
- Logs in to Amazon ECR
- Builds & pushes the Docker image to ECR (tagged with commit SHA and
latest) - Triggers a force new deployment on ECS
Add the following secrets to your GitHub repository (Settings > Secrets > Actions):
| Secret | Description |
|---|---|
AWS_ACCESS_KEY_ID |
IAM user access key |
AWS_SECRET_ACCESS_KEY |
IAM user secret key |
RAG-document-qa/
├── app.py # FastAPI application
├── src/
│ ├── config/ # Settings — AWS Secrets Manager + .env fallback
│ ├── document_ingestion/ # PDF loading and chunking
│ ├── vectorstore/ # FAISS vector store management
│ ├── nodes/ # LangGraph retriever + ReAct agent nodes
│ ├── graph_builder/ # LangGraph workflow builder
│ ├── state/ # State schema (TypedDict)
│ └── utils/ # Logging
├── static/ # Frontend
│ ├── index.html
│ ├── script.js
│ └── style.css
├── data/ # PDF documents (local only — S3 on AWS)
├── vectorstore/ # FAISS index (local only)
├── .github/workflows/ # CI/CD
│ └── deploy.yml
├── Dockerfile
├── .dockerignore
└── requirements.txt
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Serves frontend |
| GET | /api |
Health check |
| GET | /api/files |
List PDFs (S3 or local) |
| POST | /api/upload |
Upload a PDF file |
| POST | /api/load |
Index documents into vector store |
| POST | /api/query |
Query documents with a question |
MIT License
