| # Plexi API | |
| FastAPI RAG backend deployed on HuggingFace Spaces. | |
| ## What It Does | |
| - Loads the pre-built LlamaIndex vector store from the `plexi-materials` GitHub repo at startup | |
| - Exposes three endpoints consumed by the Cloudflare Worker middleman | |
| ## Endpoints | |
| | Method | Path | Purpose | | |
| |---|---|---| | |
| | `GET` | `/health` | Liveness probe — used by keep-alive GitHub Actions | | |
| | `GET` | `/manifest` | Proxies + caches `manifest.json` from the materials repo | | |
| | `POST` | `/retrieve` | Embeds query, searches index, returns scoped top-k chunks | | |
| ## Local Development | |
| ```bash | |
| pip install -r requirements.txt | |
| uvicorn main:app --reload --port 7860 | |
| ``` | |
| Visit `http://localhost:7860/docs` for the interactive API docs. | |
| ## Environment Variables | |
| | Variable | Default | Purpose | | |
| |---|---|---| | |
| | `MATERIALS_REPO` | `KunalGupta25/plexi-materials` | GitHub repo with study materials | | |
| | `MANIFEST_BRANCH` | `main` | Branch that holds `manifest.json` and `index/` | | |
| | `ALLOWED_ORIGINS` | (Cloudflare Pages URL) | CORS allowed origins | | |
| ## Deploy to HuggingFace Spaces | |
| 1. Create a new Space with **Docker** SDK | |
| 2. Push this folder as the Space repo | |
| 3. Set environment variables in the Space settings | |
| 4. HF will build and run the Dockerfile automatically | |