# Deploying to Hugging Face This repo deploys [SimpleDocReview](https://github.com/eputnam77/SimpleDocReview) to a Hugging Face **Static** Space as a browser-only demo. It holds no application logic of its own — only the build tooling, the Space card, a vendored copy of upstream in `app/`, the browser-side API in `overlay/`, and the generated site at the repository root. ## Why static Per Hugging Face's own docs, [Static Spaces][static-docs] are free for everyone — "served directly without running on compute, so unlike Gradio and Docker Spaces, creating them never requires a paid plan." Upstream is a good fit in one respect and a poor fit in another, and both matter: - **Good fit:** the front end is plain HTML, CSS, and JavaScript with no build step, no framework, and no bundler. It is served byte-for-byte as upstream wrote it. - **Poor fit:** upstream is a *server*. `app.py` owns the review logic and the storage. A Static Space cannot run it, so the API is reimplemented in the browser and the storage becomes IndexedDB. That second point is the whole design constraint of this repository, and it is why the Space is a demo. See [What the demo cannot be](#what-the-demo-cannot-be). [static-docs]: https://huggingface.co/docs/hub/spaces-sdks-static ## The everyday workflow After you change something in `C:\dev\SimpleDocReview` and commit it there: ```powershell cd C:\dev\sdr-streamlit .\scripts\deploy.ps1 ``` That syncs `app/`, builds the site into the repository root, commits with the upstream commit in the message, and pushes to `hf`. Because a Static Space serves files directly, the update is live as soon as the push lands. To see what would change without committing: ```powershell .\scripts\deploy.ps1 -DryRun ``` Individual steps, when you want them: ```powershell .\scripts\sync-upstream.ps1 # refresh app/ from the local upstream checkout .\scripts\build-static.ps1 # build the site into the repository root node tests\parity\run-parity.mjs # diff the browser API against the real app.py node tests\browser\run-browser-check.mjs # drive the built site in headless Chromium python -m http.server 8000 # preview at http://localhost:8000 ``` ### Useful flags | Flag | Effect | | --- | --- | | `-Message "feat: ..."` | Custom commit message | | `-AlsoPushOrigin` | Also push to the GitHub mirror of this repo | | `-UpstreamPath D:\other\checkout` | Sync from a different checkout | | `-AllowDirty` | Deploy from an uncommitted upstream working tree | | `-SkipSync` | Build and deploy `app/` as it stands, no re-mirror | | `-SkipBuild` | Commit and push the existing site, no rebuild | | `-SkipTests` | Skip the parity and browser checks (they run by default) | | `-DryRun` | Show the plan, change nothing | By default a dirty upstream working tree is an **error**, because `UPSTREAM.json` would otherwise record a commit that does not describe what actually shipped. Commit upstream first, or opt in with `-AllowDirty`. ## First-time setup 1. Create the Space at https://huggingface.co/new-space — choose the **Static** SDK and the **Blank** template. Name it `SimpleDocReview`. 2. Add it as a remote: ```powershell git remote add hf https://huggingface.co/spaces/Hoctar77/SimpleDocReview ``` 3. Authenticate. Use a Hugging Face access token with **write** scope from https://huggingface.co/settings/tokens as the password when git prompts, or store it once: ```powershell git config credential.helper manager ``` 4. Build and push: ```powershell .\scripts\deploy.ps1 -AlsoPushOrigin ``` A blank Space starts with its own initial commit, so the first push may be rejected as non-fast-forward. Reconcile once: ```powershell git pull --rebase hf main git push hf main ``` ## How the build works ``` app/ clean upstream mirror (generated by sync-upstream.ps1) overlay/ the browser-side API (hand-maintained) | v copy + insert two