This repository contains a complete Retrieval-Augmented Generation (RAG) workflow:
- Backend API in
app/ - Frontend client in
front/ - Notebook prototype in
notebooks/
The system accepts only .txt and .pdf, does not persist uploaded files, and supports streamed answers.
The frontend is managed with Yarn 4.17.1 through Corepack and is deployed with Wrangler. The main CI workflow validates the backend with pytest and the frontend with a Yarn 4 immutable install plus a production build.
app/FastAPI backend for RAG queriesfront/React + Vite + TypeScript frontendnotebooks/Jupyter notebook prototype and local document workspacerequirements.txtPython dependencies for backend/notebook
- Python 3.10+
- Node.js 24+
- Corepack-enabled Yarn 4.17.1
- A Hugging Face token
git clone <your-repo-url>
cd doc_rag
pip install -r requirements.txt
cd front
yarn install
cd ..uvicorn app.main:app --reloadBackend docs:
- Swagger UI: http://localhost:8000/docs
cd front
yarn devOpen the URL printed by Vite (typically http://localhost:5173).
To deploy the frontend through Cloudflare from the front/ directory:
yarn deploy- Paste your Hugging Face token in the frontend (stored in browser localStorage)
- Upload a
.txtor.pdf - Enter a question (up to 1,000 characters)
- Toggle stream on/off and submit
Optional backend variables:
CORS_ALLOWED_ORIGINS(comma-separated)EMBEDDING_MODELLLM_MODELCHUNK_SIZECHUNK_OVERLAPNUM_RETRIEVED_DOCSHUGGINGFACE_API_KEY(fallback token if frontend token is not provided)
- Uploaded files are processed in-memory and are not stored by the API.
- Frontend install and build should use Yarn 4.17.1 with Corepack enabled.
- Frontend build check:
cd front
yarn build- Never commit
.envor real API keys. - Use
.env.exampleas template and keep real values only in local env / deployment secret manager. - Frontend sends token using
Authorization: Bearer <token>at request time. - If you suspect a token leak, rotate/revoke it immediately in Hugging Face settings.
If a secret was committed in git history, rewrite history before publishing:
git filter-repo --path .env --invert-paths
git push --force --all
git push --force --tags