--- title: Internal Portal API emoji: 🏢 colorFrom: indigo colorTo: blue sdk: docker app_port: 7860 pinned: false --- # Internal Portal API (backend) FastAPI backend for the internal portal chat app. Provides domain/project management, a chat endpoint backed by **DeepSeek**, and an HR assistant grounded in uploaded documents. ## Deploy on Hugging Face Spaces 1. Create a new Space → **Docker** SDK. 2. Push the contents of this `backend/` folder to the Space repo (this README's YAML header configures the Space; `app_port: 7860` matches the Dockerfile). 3. In **Settings → Variables and secrets**, add: - `DEEPSEEK_API_KEY` (secret) — your DeepSeek key - `DEEPSEEK_MODEL` — your exact model id (e.g. the "v4 flash" model string) - `DEEPSEEK_BASE_URL` — optional, defaults to `https://api.deepseek.com` - `ALLOWED_ORIGINS` — your Vercel URL, e.g. `https://your-app.vercel.app` (defaults to `*` for easy first testing) 4. The Space builds and serves at `https://-.hf.space`. Check it's up: `GET https:///api/health` → `{"ok": true, "llm_configured": true, "model": "..."}`. ## Run locally ```bash cd webapp/backend python -m venv .venv && source .venv/bin/activate pip install -r requirements.txt export DEEPSEEK_API_KEY=sk-... # your key export DEEPSEEK_MODEL=deepseek-chat # or your "v4 flash" model id uvicorn app.main:app --reload --port 7860 ``` Then open http://localhost:7860 — the backend also serves the static frontend from `../frontend` for convenience, so you can test the whole app from one process locally. ## Storage note Data is persisted to a JSON file under `DATA_DIR` (`/data` in Docker). **A free HF Space's disk is ephemeral** — it resets on rebuild/restart. That's fine for development and demos. When durable storage is needed, the `store.py` layer is swappable for a real database without changing the rest of the app.