--- title: WhereToWatch Gateway emoji: 🎬 colorFrom: indigo colorTo: gray sdk: docker app_port: 7860 pinned: false --- # WhereToWatch Gateway (Rust + axum) The API the WhereToWatch client talks to — the only backend clients reach (NFR-1.3). This directory is a self-contained cargo workspace **and** a Hugging Face **Docker Space** (the frontmatter above configures the Space). ## Crates | Crate | Role | |---|---| | `domain` | Entities + the idempotent ingestion diff (pure) | | `upstream` | `AvailabilityProvider` seam (JustWatch impl is a stub) | | `store` | `Store` trait + `InMemoryStore` (dev) and `PgStore` (Postgres/sqlx) | | `gateway` | axum HTTP service (this Space's binary) | | `ingestion` | worker: upstream `/changes` → diff → store → notify | ## Run ```bash cargo run -p gateway # in-memory store, :8080 PORT=7860 cargo run -p gateway # honor a PaaS port DATABASE_URL=postgres://… cargo run -p gateway # persist to Postgres ``` ## Container ```bash docker build -t wtw-gateway -f Dockerfile . docker run -p 7860:7860 -e DATABASE_URL=postgres://… wtw-gateway ``` On boot the gateway runs migrations (if `DATABASE_URL` is set), seeds the catalog into the store, and serves on `$PORT` (default 7860). Set `DATABASE_URL` as a Space **secret** to persist; without it the store is in-memory (resets on restart). CORS is permissive for the web client. See `../docs/DEPLOY-HF.md`.