Spaces:
Sleeping
Sleeping
Worklog
2026-01-17 – Work Package C
Summary
- Productionised the backend for deployment on Hugging Face Spaces (Docker) and added a minimal Streamlit frontend suitable for Streamlit Community Cloud.
- Introduced optional API key protection, rate limiting, and in-memory caching.
- Added in-memory metrics with a
/metricsendpoint and an asyncio-based benchmark script.
Key Files Changed
- Backend runtime and deployment:
backend/Dockerfilebackend/app/core/runtime.py
- Security, CORS, rate limiting, and caching:
backend/app/core/security.pybackend/app/core/rate_limit.pybackend/app/core/cache.py
- Metrics:
backend/app/core/metrics.pybackend/app/routers/metrics.py
- Routers and configuration:
backend/app/main.pybackend/app/routers/chat.pybackend/app/routers/search.pybackend/app/routers/ingest.pybackend/app/core/config.py
- Dependencies and environment:
backend/requirements.txtbackend/.env.example
- Tooling and frontend:
scripts/bench_local.pyfrontend/app.pyrequirements.txt(root)
- Documentation:
backend/README.mddocs/CONTEXT.md
- Backend runtime and deployment:
Major Decisions
- Use port
7860by default in the Docker image, while respecting thePORTenvironment variable for platforms like Hugging Face Spaces. - Keep API key protection opt-in via
API_KEYwith clear logging when disabled. - Enable rate limiting and caching by default, with simple boolean toggles (
RATE_LIMIT_ENABLED,CACHE_ENABLED) for easy operational control. - Implement metrics as in-memory only (no external storage) and expose them via a JSON
/metricsendpoint tailored for demos and lightweight monitoring.
- Use port
2026-01-17 – Security + UI + Ingestion Hardening
Summary
- Hardened the backend for public deployment by enforcing API key protection for all non-health endpoints and (initially) for the OpenAPI/Swagger documentation, then relaxed docs to be publicly viewable while keeping all functional endpoints protected.
- Upgraded the Streamlit frontend to a conversational chat UI using Streamlit's chat primitives.
- Improved local document ingestion workflows with Docling-aware scripts for single files and batch folder ingestion.
- Added a UI-based document upload dialog in the Streamlit app that ingests files via
/documents/upload-text.
Key Files Changed
- Backend authentication and wiring:
backend/app/core/auth.pybackend/app/core/security.pybackend/app/main.py
- Frontend chatbot UI and upload:
frontend/app.pyfrontend/services/file_convert.pyfrontend/services/backend_client.py
- Local ingestion scripts:
scripts/docling_convert_and_upload.pyscripts/batch_ingest_local_folder.py
- Documentation:
backend/README.mddocs/CONTEXT.mddocs/WORKLOG.md(this file)
- Backend authentication and wiring:
Major Decisions
- In production-like environments (
ENV=productionor on Hugging Face Spaces), requireAPI_KEYand fail fast at startup when it is missing; Swagger/OpenAPI remain publicly accessible but all non-health API endpoints still enforceX-API-Key. - Use a single
require_api_keydependency (based onAPIKeyHeader) to protect all routers except/health. - Treat Streamlit as a first-class chat client, using
st.chat_message/st.chat_inputwith session-based history and optional streaming from/chat/stream. - Keep Docling as an optional dependency used in:
- Local ingestion scripts that upload text to
/documents/upload-text. - The frontend upload dialog for converting PDFs/Office/HTML when available, while falling back to raw
.md/.txtand showing clear errors otherwise.
- Local ingestion scripts that upload text to
- In production-like environments (