Skip to content

06. Infra and Local Ops

Local development

Command Purpose
pnpm dev Vite dev server
pnpm build tsc -b && vite build
pnpm preview Preview production build
pnpm lint ESLint
pnpm typecheck tsc --noEmit
pnpm format Prettier on TS/TSX

Package manager: pnpm (pnpm-workspace.yaml present; single app package).

Topology

graph TD
  classDef default fill:#1e293b,stroke:#38bdf8,stroke-width:2px,color:#f8fafc
  classDef highlight fill:#065f46,stroke:#34d399,stroke-width:2px,color:#f0fdf4
  classDef warning fill:#78350f,stroke:#fbbf24,stroke-width:2px,color:#fffbeb

  Dev["Developer machine<br/>pnpm dev"]:::highlight
  Vite["Vite + COOP/COEP headers"]
  CI["GitHub Actions<br/>deploy.yml"]
  Pages["gh-pages branch<br/>static /browser-rag/"]
  Browser["User browser"]
  CDN["Model weight CDNs"]:::warning

  Dev --> Vite --> Browser
  CI --> Pages --> Browser
  Browser -.-> CDN

  linkStyle default stroke:#64748b,stroke-width:2px

No Docker Compose, no Kubernetes, no application server.

Environment and config

  • No .env.example — configuration is in-app (projects, preferences)
  • Vite base: '/browser-rag/' for project Pages URL
  • Dev/preview headers (vite.config.ts):
  • Cross-Origin-Opener-Policy: same-origin
  • Cross-Origin-Embedder-Policy: require-corp

These enable SharedArrayBuffer / WASM multi-threading when the browser supports it. Settings UI probes wasmMultiThreading.

Networking and ports

  • Dev: default Vite port (typically 5173)
  • Runtime network: model downloads only (library-driven)
  • No backend ports

Startup / shutdown / migrations

  1. initDb() creates/opens PGlite and runs pending migrations
  2. SystemInitProvider polls until DB ready, resolves/creates active project
  3. User explicitly loads embedding/LLM models
  4. Import path closes DB, deletes IDB, reloads data dir, migrates, reloads page

Secrets

No server secrets. No API keys in repo for the RAG path. Model access is public CDN downloads.

Observability

  • Browser console logs for DB failures
  • In-app diagnostics: capability checks, table row counts, schema version
  • Retrieval debug timings in chat UI
  • No APM, metrics, or remote logging

CI / deploy

.github/workflows/deploy.yml:

  • Triggers: push to main (path-filtered) or workflow_dispatch
  • Node 22 + pnpm 10
  • pnpm install --no-frozen-lockfilepnpm run build
  • Deploy dist to gh-pages via JamesIves/github-pages-deploy-action

Infra interview questions

Q: How do you deploy?
A: Static Vite build to GitHub Pages with base path /browser-rag/.

Q: Why COOP/COEP?
A: Cross-origin isolation for high-performance WASM/WebGPU ML paths that need SharedArrayBuffer.

Q: What’s missing for production hardening?
A: Confirmed headers only on Vite server/preview — Pages header configuration is not in this repo; also no automated tests in CI.