Full‑stack RAG playground with a FastAPI backend and a React (Vite) frontend. Backend uploads documents to S3 and proxies chat requests to a Modal endpoint.
- Frontend: React 19 + Vite
- Backend: FastAPI (served via
uvicorn) - Storage: AWS S3
- Conda (Miniconda or Anaconda)
- Node.js 18+ and npm
- AWS credentials with access to the target S3 bucket
git clone <your-repo-url>
cd RagApp
# Python deps via Conda
conda env create -f environment.yml
conda activate rag_app
# Frontend deps
npm installCreate a .env file in the project root with:
AWS_S3_BUCKET_NAME=your-bucket
AWS_S3_REGION=your-region
AWS_ACCESS_KEY_ID=your-access-key-id
AWS_SECRET_ACCESS_KEY=your-secret-access-key
MODAL_UPLOAD_URL=https://your-modal-upload-endpoint
MODAL_CHAT_URL=https://your-modal-chat-endpoint
MODAL_API_TOKEN=your-modal-api-tokenNotes:
- CORS is currently allowed for
http://localhost:5174andhttp://127.0.0.1:5174in the backend. Run Vite on port 5174 to avoid CORS errors.
- Backend (FastAPI via
uvicorn):
npm startThis runs uvicorn main:app (default at http://127.0.0.1:8000).
- Frontend (Vite on port 5174):
npm run dev -- --port 5174Vite dev server will be available at http://localhost:5174.
-
POST /api/upload- Form‑data:
file(document to upload) - Action: uploads file to S3 and calls
MODAL_UPLOAD_URL - Returns:
{ session_id, filename }
- Form‑data:
-
POST /api/chat- JSON body:
{ "session_id": string, "message": string } - Action: forwards to
MODAL_CHAT_URLwith{ session_id, questions: [message] } - Returns: Modal response JSON
- JSON body:
{
"start": "uvicorn main:app",
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
}RagApp/
├─ main.py # FastAPI app (S3 upload, chat proxy)
├─ environment.yml # Conda environment (python + deps)
├─ package.json # Frontend scripts and deps
├─ src/ # React app source
├─ public/ # Static assets
├─ vite.config.js # Vite config
└─ README.md
- If you see CORS errors, ensure the frontend runs on
5174or update allowed origins inmain.py. - Ensure your AWS creds and bucket/region are correct;
main.pyconstructs public S3 URLs ashttps://{bucket}.s3.{region}.amazonaws.com/{key}. - Modal endpoints must accept the shapes documented above and the
Authorization: Bearer <MODAL_API_TOKEN>header.
MIT (or your preferred license)