Architecture overview
KV Cache Store is made of three components: thekvcdn CLI, the portal, and the Worker.
Components
kvcdn CLI
An open-source Rust command-line tool for x86-64 Linux that customers run locally. It supports:
login— open the dashboard in the default browser.api-key—set,verify, orclearthe API key used for API requests.verify— verify a local.kvartifact against a context file.quant— quantize a.kvartifact to a lower-precision dtype.benchmark— measure throughput or memory of a.kvartifact.plot— generate visualizations from benchmark output.upload— send a.kvartifact to the hosted service via a presigned URL.list— query the hosted API for artifacts in the active project.
KVCDN_API_KEY. It talks to the portal at KVCDN_API_URL (default https://api.kvcachestore.com).
Portal
The Rust web service atapi.kvcachestore.com (also kvcachestore.com) that handles:
- OIDC sign-in via Pocket-ID (
/auth/*). - Customer, organization, and project management.
- API key creation and verification (
/api/v1/api-keys). - Artifact metadata, presigned upload URLs, and visibility (
/api/v1/artifacts). - Billing and Stripe webhooks (
/api/v1/billing). - Static frontend assets served from
frontend/dist/(the frontend seam).
Worker
A Cloudflare Worker that runs at the edge and serves artifacts from R2 object storage. It exposes:GET /v1/artifacts/:id— downloads a public artifact.POST /v1/artifacts/:id/visibility— updates object metadata visibility.POST /v1/artifacts/upload-url— alternative upload-url path (not used by the current CLI).
403 Forbidden.
Upload flow
- The CLI infers artifact metadata from the
.kvfilename and the user-supplied--name. - The CLI calls
POST /api/v1/artifacts/upload-urlon the portal with the metadata, size, and SHA-256 checksum. - The portal checks the organization’s artifact quota, creates a
pendingartifact record, and returns a presigned URL. - The CLI PUTs the file bytes directly to the presigned URL.
- The CLI calls
POST /api/v1/artifacts/{id}/confirm-uploadto finalize the upload.
Download flow
- A customer requests an artifact through the dashboard or the portal’s
GET /api/v1/artifacts/{id}endpoint. - The portal verifies the customer has access, then returns a presigned download URL.
- For public artifacts, the Worker can also serve the object directly from R2 using the artifact ID.
Frontend seam
The portal serves the frontend website fromfrontend/dist/. The frontend consumes only the portal’s /api/v1/* JSON API. This boundary keeps the website separate from the Rust service while both run on the same public URL.
Environment boundaries
- CLI ↔ Portal:
KVCDN_API_URL+KVCDN_API_KEY. - Portal ↔ Postgres:
DATABASE_URL. - Portal ↔ R2:
R2_ACCOUNT_ID,R2_ACCESS_KEY_ID,R2_SECRET_ACCESS_KEY,R2_BUCKET_NAME. - Portal ↔ Worker: The Worker calls the portal’s
/api/v1/api-keys/verifyendpoint to authenticate requests. - Portal ↔ Stripe:
STRIPE_SECRET_KEY,STRIPE_WEBHOOK_SECRET.