A production-ready Retrieval Augmented Generation system built with Next.js, FastAPI, and AWS.
- 📝 Document processing and chunking
- 🔍 Semantic search with pgvector
- 💬 Streaming chat interface
- 🚀 High-performance vector search
- 🔒 Built-in authentication
- 📊 Advanced monitoring
- FastAPI
- PostgreSQL + pgvector
- AWS Bedrock
- Docker + ECS
- Next.js 14 (App Router)
- shadcn/ui components
- Tailwind CSS
- TypeScript
- AWS (ECS, RDS, S3, Lambda)
- Terraform
- Python 3.11+
- Node.js 18+
- Docker
- AWS CLI configured
- Terraform
- Clone the repository
git clone https://github.com/yourusername/rag-system.git
cd rag-system- Backend Setup
cd backend
python -m venv venv
source venv/bin/activate # or `venv\Scripts\activate` on Windows
pip install -r requirements.txt- Frontend Setup
cd frontend
npm install- Environment Setup
Create .env files:
backend/.env:
DATABASE_URL=postgresql://user:pass@localhost:5432/rag
AWS_REGION=us-west-2
BEDROCK_MODEL_ID=anthropic.claude-v2
S3_BUCKET=your-rag-documents-bucket
frontend/.env.local:
NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_UPLOAD_BUCKET=your-rag-documents-bucket
- Run Development Servers
Backend:
cd backend
uvicorn api.main:app --reloadFrontend:
cd frontend
npm run dev- Infrastructure Setup
cd infrastructure
terraform init
terraform apply- Backend Deployment
docker build -f docker/backend.Dockerfile -t rag-backend .
docker push <ECR_REPO>/rag-backend:latest- Frontend Deployment
cd frontend
npm run build
vercel deploy # or your preferred hosting├── Document Upload
│ └── S3 Storage
├── Processing Pipeline
│ ├── Lambda Trigger
│ ├── Unstructured-IO
│ └── Embedding Generation
├── Vector Storage
│ └── PostgreSQL + pgvector
└── Query Pipeline
├── Semantic Search
├── Context Retrieval
└── LLM Response
rag-system/
├── backend/
│ ├── api/
│ ├── indexer/
│ └── retriever/
├── frontend/
│ ├── app/
│ ├── components/
│ └── lib/
└── infrastructure/
└── modules/
Key configurations in backend/config.py:
- Database settings
- AWS credentials
- Model parameters
- Processing pipeline
Key configurations in frontend/config.ts:
- API endpoints
- Authentication
- UI theming
- Feature flags
- Fork the repository
- Create your feature branch
- Commit your changes
- Push to the branch
- Create a new Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.