crates.io is the official Rust package registry: a Rust backend on Axum, Diesel and PostgreSQL with a custom background worker, crate files in object storage behind a CDN, and a SvelteKit frontend in TypeScript.
- Language
- Rust
- Database
- PostgreSQL
- Hosting
- AWS
- License
- Apache-2.0
- Running for
- 11 years
- Team
- 1M+ MAU
Why this architecture
crates.io runs one pinned-dependency Rust binary as migrate, web and worker processes, splits domains into small internal crates, and generates its TypeScript client from OpenAPI types so the SvelteKit frontend and Axum API share one contract.
Tech stack by layer
14 technologies · audited Oct 2, 2026- SvelteKitThe crates.io web app in svelte/, built with Vite and the static adapter, with Shiki highlighting and Chart.js download graphs.
- TypeScriptFrontend language; an OpenAPI-generated API client (openapi-fetch, openapi-typescript) lives in packages/crates-io-api-client.
- MSWMock Service Worker data layer in packages/crates-io-msw for frontend development and tests without a backend.
- RustBackend language for the crates-io binary and all crates/ members (edition 2024), with every dependency pinned with =.
- AxumHTTP framework for the API (axum 0.8 with macros and matched-path, axum-extra for typed headers and middleware).
- utoipaGenerates the OpenAPI description of the API types that the TypeScript client is generated from.
- Background workerCustom job system in crates/crates_io_worker, run as a separate background_worker process.
- PostgreSQLPrimary database, with migrations dating back to 2014 and full-text search through diesel_full_text_search.
- DieselORM with diesel-async and a deadpool connection pool; diesel_migrations runs migrations on release.
- git indexcrates_io_index maintains the package index with git2, alongside crate files in object storage.
- HerokuProcfile defines release (migrate), web (server) and background_worker processes; .buildpacks and Aptfile configure the build.
- AWSobject_store with the aws feature for crate files, plus CloudFront and SQS SDK clients.
- FastlyCDN API client in crates/crates_io_fastly; the README credits Fastly for CDN services.
- SentryError tracking with tower and axum integrations.
- OpenTelemetryMetrics exported over OTLP.
- PlaywrightEnd-to-end tests in e2e/ with axe accessibility checks and Percy visual snapshots.
- AGENTS.mdStructured development documentation for coding agents, referenced from the README; docs/AI-TOOLS.md covers AI tool use.
crates.io architecture diagram
Open SVGDiagram as text
- cargo CLI (publish · download) → CDN (Fastly · CloudFront): download
- cargo CLI (publish · download) → crates-io server (Rust · Axum): publish
- crates.io website (SvelteKit) → crates-io server (Rust · Axum): OpenAPI client
- CDN (Fastly · CloudFront) → Crate files (S3 object storage)
- crates-io server (Rust · Axum) → Database (PostgreSQL · Diesel): Diesel
- crates-io server (Rust · Axum) → Background worker (crates_io_worker): enqueue jobs
- Background worker (crates_io_worker) → Crate files (S3 object storage): upload
- Background worker (crates_io_worker) → Package index (git2): sync
- crates-io server (Rust · Axum) → GitHub (OAuth · GitHub App): login
Key architectural decisions
5 decisions- 01
One Rust binary with three process roles
The Procfile runs the same crates-io binary as release (migrate), web (server) and background_worker, so migrations, HTTP serving and background jobs share code and deploy together while scaling independently on Heroku.
- 02
Many small internal crates under crates/
The workspace (members = ["crates/*"]) splits concerns into crates such as crates_io_database, crates_io_index, crates_io_worker, crates_io_tarball, crates_io_trustpub, crates_io_cdn_logs, crates_io_fastly and crates_io_github_app, each with its own dependency list and tests.
- 03
Every dependency pinned to an exact version
Cargo.toml and every crate manifest pin dependencies with = (for example axum = "=0.8.9", diesel = "=2.3.13"), and .github/renovate.json5 configures Renovate, so upgrades arrive as explicit pull requests instead of drifting through semver ranges.
- 04
Typed API contract from Rust to TypeScript
crates_io_api_types derives OpenAPI schemas with utoipa, and packages/crates-io-api-client regenerates a typed client with openapi-typescript and openapi-fetch, which the SvelteKit app and the MSW mock layer both consume.
- 05
Frontend developed against mocks
packages/crates-io-msw provides an MSW data layer, and svelte/package.json has dev:msw, dev:local and dev:staging scripts plus Storybook with Chromatic, so UI work and Playwright e2e tests run without a full backend.
How crates.io is built
How crates.io is structured
The repository holds both halves of crates.io (opens in a new tab):
| Path | Role |
|---|---|
src/ |
The crates_io backend crate and crates-io binary (server, migrate, background-worker subcommands) |
crates/ |
Internal crates: crates_io_database, crates_io_index, crates_io_worker, crates_io_tarball, crates_io_crate_zip, crates_io_trustpub, crates_io_cdn_logs, crates_io_fastly, crates_io_github, crates_io_github_app, crates_io_session, crates_io_markdown, crates_io_linecount, crates_io_docs_rs and more |
migrations/ |
Diesel migrations going back to 2014 |
svelte/ |
The SvelteKit frontend |
packages/ |
Shared frontend packages: generated API client, MSW mocks, favicon and file-tree icons, a test-selector stripper |
e2e/ |
Playwright acceptance tests |
docs/ |
ARCHITECTURE.md, API-DESIGN.md, LOGGING.md, MIRROR.md, PR-REVIEW.md, AI-TOOLS.md |
Frontend
The website is a SvelteKit app in svelte/, built with Vite and @sveltejs/adapter-static. It uses Shiki for syntax highlighting, Chart.js for download graphs, Mermaid and micromark for README rendering, @pierre/trees and @pierre/diffs for file trees and diffs, and UnoCSS with Iconify icon sets for styling. Storybook with Chromatic covers components.
The API client in packages/crates-io-api-client is generated from the backend's OpenAPI schema with openapi-typescript and called with openapi-fetch. packages/crates-io-msw provides a Mock Service Worker data layer, so dev:msw runs the frontend with no backend. dev:local and dev:staging point it at a local or staging API.
Backend & APIs
The backend is Rust on Axum 0.8, with axum-extra for typed headers, query parsing and middleware. Notable pinned dependencies in Cargo.toml:
oauth2for GitHub login, andcrates_io_github_appwithjsonwebtokenfor GitHub App authentication.crates_io_trustpubhandles trusted publishing.lettrefor email,minijinjafor templates, andrssfor Atom feeds.sentrywith tower and axum integrations for errors, andopentelemetry-otlpfor metrics.utoipaincrates_io_api_typesto describe the API as OpenAPI.
Data & persistence
PostgreSQL is accessed with Diesel 2, diesel-async with a deadpool pool, diesel_migrations and diesel_full_text_search for crate search (crates/crates_io_database). diesel.toml and diesel-guard.toml configure schema generation and migration checks.
Crate files are written to object storage through object_store with its AWS backend. aws-sdk-cloudfront and aws-sdk-sqs handle CDN invalidation and CDN log queues, and crates_io_cdn_logs parses those logs to count downloads. The package index is maintained with git2 in crates_io_index, and crates_io_database_dump produces public database dumps.
Build, test & deploy
- The
Procfiledefinesrelease: crates-io migrate,web: crates-io serverandbackground_worker: crates-io background-worker..buildpacks,Aptfileandcrates_io_herokutarget a Heroku-style platform. - Workflows:
ci.yml,smoke-test.yml(backed bycrates_io_smoke_test), andupdate-cdn-ip-ranges.yml, which refreshes the CDN IP ranges used bycrates_io_real_ip. - Tests use
instasnapshots,googletest,mockitoand a throwaway Postgres fromcrates_io_test_db..config/nextest.tomlconfigures nextest. The dev profile compiles crypto crates with optimizations to speed up database setup in tests. e2e/runs Playwright with@axe-core/playwrightaccessibility checks and Percy visual snapshots..devcontainer/provides a container with the PostgreSQL 16 client and mise-managed tools.Justfilecollects common commands.
What to copy (and what not to)
Copy:
- One binary, several process roles (migrate, web, worker): shared code, independent scaling, one deploy artifact.
- An OpenAPI-generated client plus an MSW mock layer, so frontend and backend can evolve in parallel without drifting apart.
- Exact-pinned dependencies with Renovate. Every upgrade becomes a reviewable pull request.
- Architecture and API design docs (
docs/ARCHITECTURE.md,docs/API-DESIGN.md) and anAGENTS.mdnext to the code.
Don't copy blindly:
- A git-based package index and CDN log processing are specific to a package registry.
- Pinning every dependency exactly only works with automated update tooling. Without Renovate it turns into stale dependencies.
Compare with other Axum backends in the directory, such as OpenObserve and Atuin, or start from the Rust + Axum + PostgreSQL rules.
Sources & repo audit
- Audited
- Oct 2, 2026
- Commit
- 204522d
- License
- Apache-2.0
- Root Cargo.toml (workspace, pinned dependencies)
- Procfile (release, web, background_worker)
- svelte/package.json (SvelteKit frontend)
- crates/crates_io_database/Cargo.toml
- README (axum, diesel, SvelteKit, hosting credits)
Independent analysis of repository at github.com/rust-lang/crates.io. Spotted an inaccuracy? Use the claim form to request a correction.
Maintainer? Add the architecture badge to your README
[](https://stackitfast.com/project/crates-io) Scaffold it with your agent
Paste this prompt into Claude Code, Cursor, Windsurf or AGY to start a project with crates.io's architecture.
- 1Copy the promptThe full markdown spec, with every layer and decision.
- 2Open your AI toolClaude Code, Cursor, Windsurf or Copilot, in a new repo.
- 3Paste and scaffoldUse it as the first instruction; review before you ship.
# MISSION: Scaffold "crates.io" Production Architecture
You are an expert Senior Staff Software Architect and Full-Stack Engineer. Your mission is to scaffold and implement a production-grade, highly reliable, and modular codebase following the proven architecture of **crates.io**.
---
## 1. PROJECT SPECIFICATIONS & BENCHMARK
- **Reference Architecture**: crates.io
- **What It Does**: crates.io is the official Rust package registry: a Rust backend on Axum, Diesel and PostgreSQL with a custom background worker, crate files in object storage behind a CDN, and a SvelteKit frontend in TypeScript.
- **Domain & Category**: Package Registry
- **Production Scale**: 1M+ MAU
- **Development Mode**: CLASSIC
- **Architectural Rationale**: crates.io runs one pinned-dependency Rust binary as migrate, web and worker processes, splits domains into small internal crates, and generates its TypeScript client from OpenAPI types so the SvelteKit frontend and Axum API share one contract.
- **Live Website Reference**: https://crates.io
- **Source Repository**: https://github.com/rust-lang/crates.io
---
## 2. PRODUCTION TECH STACK
- **Full Stack Array**: Rust, Axum, Diesel, PostgreSQL, Tokio, SvelteKit, Svelte, TypeScript, Vite, AWS, Sentry, OpenTelemetry, Playwright, Storybook
- **Primary Language(s)**: Rust, TypeScript, Svelte, PLpgSQL
- **License of the reference repo**: Apache-2.0
- **Frontend**: SvelteKit — The crates.io web app in svelte/, built with Vite and the static adapter, with Shiki highlighting and Chart.js download graphs.; TypeScript — Frontend language; an OpenAPI-generated API client (openapi-fetch, openapi-typescript) lives in packages/crates-io-api-client.; MSW — Mock Service Worker data layer in packages/crates-io-msw for frontend development and tests without a backend.
- **Backend & APIs**: Rust — Backend language for the crates-io binary and all crates/ members (edition 2024), with every dependency pinned with =.; Axum — HTTP framework for the API (axum 0.8 with macros and matched-path, axum-extra for typed headers and middleware).; utoipa — Generates the OpenAPI description of the API types that the TypeScript client is generated from.; Background worker — Custom job system in crates/crates_io_worker, run as a separate background_worker process.
- **Data & persistence**: PostgreSQL — Primary database, with migrations dating back to 2014 and full-text search through diesel_full_text_search.; Diesel — ORM with diesel-async and a deadpool connection pool; diesel_migrations runs migrations on release.; git index — crates_io_index maintains the package index with git2, alongside crate files in object storage.
- **Infrastructure & deploy**: Heroku — Procfile defines release (migrate), web (server) and background_worker processes; .buildpacks and Aptfile configure the build.; AWS — object_store with the aws feature for crate files, plus CloudFront and SQS SDK clients.; Fastly — CDN API client in crates/crates_io_fastly; the README credits Fastly for CDN services.; Sentry — Error tracking with tower and axum integrations.; OpenTelemetry — Metrics exported over OTLP.; Playwright — End-to-end tests in e2e/ with axe accessibility checks and Percy visual snapshots.
- **Tooling, testing & ops**: AGENTS.md — Structured development documentation for coding agents, referenced from the README; docs/AI-TOOLS.md covers AI tool use.
---
## 3. KEY ARCHITECTURAL DECISIONS (audited from https://github.com/rust-lang/crates.io @ 204522d)
1. **One Rust binary with three process roles**: The Procfile runs the same crates-io binary as release (migrate), web (server) and background_worker, so migrations, HTTP serving and background jobs share code and deploy together while scaling independently on Heroku.
2. **Many small internal crates under crates/**: The workspace (members = ["crates/*"]) splits concerns into crates such as crates_io_database, crates_io_index, crates_io_worker, crates_io_tarball, crates_io_trustpub, crates_io_cdn_logs, crates_io_fastly and crates_io_github_app, each with its own dependency list and tests.
3. **Every dependency pinned to an exact version**: Cargo.toml and every crate manifest pin dependencies with = (for example axum = "=0.8.9", diesel = "=2.3.13"), and .github/renovate.json5 configures Renovate, so upgrades arrive as explicit pull requests instead of drifting through semver ranges.
4. **Typed API contract from Rust to TypeScript**: crates_io_api_types derives OpenAPI schemas with utoipa, and packages/crates-io-api-client regenerates a typed client with openapi-typescript and openapi-fetch, which the SvelteKit app and the MSW mock layer both consume.
5. **Frontend developed against mocks**: packages/crates-io-msw provides an MSW data layer, and svelte/package.json has dev:msw, dev:local and dev:staging scripts plus Storybook with Chromatic, so UI work and Playwright e2e tests run without a full backend.
---
## 4. NON-NEGOTIABLE ARCHITECTURAL GUARDRAILS
1. **Monorepo & Modular Separation**:
- Structure as a Turborepo monorepo with strict package boundaries:
- `apps/web`: Application UI, routing, layouts, and server endpoints.
- `packages/ui`: Shared design tokens, CSS variables, and Radix UI primitive components.
- `packages/db`: Database schemas, client singleton, declarative migrations, and seed scripts.
- `packages/config`: Shared TypeScript, ESLint, and build configurations.
2. **Strict Type Safety & Zero `any` Policy**:
- Enable `strict: true`, `noImplicitAny: true`, and `strictNullChecks: true`.
- Validate ALL external inputs, API request bodies, and query parameters with **Zod** schemas before execution.
3. **Frontend & Rendering Guidelines**:
- Utilize Vite 6 with TanStack Router for fully type-safe routing. Manage server state and caching via TanStack Query v5 with optimistic UI updates.
4. **Design System & Aesthetics**:
- Keep every color, radius, shadow and font in a single token file (CSS variables) and consume tokens everywhere; never hardcode hex values in components.
- Prefer crisp 1px borders and one subtle shadow scale over blurry default shadows. Pair one sans-serif for body/headings with one monospace for tags, badges, metrics, and code.
5. **Data Layer & Reliability**:
- Write declarative schema definitions with foreign keys, composite indexes on queried filters, and automated timestamp triggers.
- Use connection pooling and prepared statements for serverless database execution.
---
## 5. STEP-BY-STEP SCAFFOLDING ROADMAP
- **Phase 1: Workspace & Root Config**: Initialize package manager, monorepo configuration (`turbo.json`, `tsconfig.base.json`, `package.json`).
- **Phase 2: Database Schema & Client**: Set up the data layer (PostgreSQL, Diesel, git index): client, connection pool, models, and migration scripts.
- **Phase 3: Design Tokens & UI Primitives**: Build accessible `Button`, `Input`, `Card`, `Badge`, and layout wrappers inside `packages/ui`.
- **Phase 4: Core Application Routes & Handlers**: Implement primary authentication, user session handling, and application routes.
- **Phase 5: Quality Assurance & Build Verification**: Run `tsc --noEmit`, ESLint, Prettier, and smoke test suites to ensure zero compilation or runtime errors.
---
## 6. EXECUTION INSTRUCTIONS
1. Review all specifications, architectural guardrails, and stack choices above.
2. Present the full monorepo directory tree structure.
3. Systematically generate the complete, production-ready codebase according to the 5-phase roadmap above — starting with the root workspace setup, followed by the database schema, UI design system package, and full-stack application routes until the repository is fully scaffolded and ready to run.Frequently asked about crates.io
What is crates.io built with?
The crates.io backend is Rust with the Axum web framework, Diesel and diesel-async for PostgreSQL, and a custom background worker system. The frontend is a SvelteKit application in TypeScript, using an API client generated from the backend's OpenAPI types.
Is crates.io still an Ember.js app?
No. The audited repository contains a SvelteKit frontend in svelte/, built with Vite and the static adapter, and the README describes the frontend as a SvelteKit application written in TypeScript.
Where does crates.io store crate files?
Crate files go to object storage through the object_store crate with its AWS backend, and downloads are served through a CDN; the README credits AWS for file hosting and Fastly for CDN services. The package index is maintained with git2 in crates_io_index.
Does crates.io use Axum or Actix?
Axum. The root Cargo.toml pins axum 0.8 with macros and matched-path, plus axum-extra for typed headers and middleware, and Sentry is integrated through its tower and axum features.
How is crates.io deployed?
The Procfile runs one binary in three roles: release runs migrations, web runs the API server and background_worker processes jobs. .buildpacks and Aptfile configure a Heroku-style build.
One email a month: new deep dives and stack trends
New source-audited architectures, head-to-head comparisons and the monthly stack report. No spam, unsubscribe anytime.
Similar architectures
- AxumClassicRust Web Framework · 1M+ MAUShares Rust · Axum · Tokio
- DioxusClassicCross-Platform Rust App Framework · 6-20 peopleShares Rust · Axum · Tokio
- LeptosClassicFull-Stack Rust Web Framework · 6-20 peopleShares Rust · Axum · Tokio
- LocoClassicRails-Style Rust Web Framework · 2-5 peopleShares Rust · Axum · PostgreSQL
- AtuinClassicShell History Sync · 2-5 peopleShares Rust · Axum · PostgreSQL
- LemmyClassicFederated Link Aggregator & Forum · 20+ peopleShares Rust · Diesel · PostgreSQL