$ show fedify-dev/fedify
Fedify is a comprehensive, modular TypeScript framework for building ActivityPub-powered federated servers (the Fediverse). It provides a rich set of abstractions: a central `Federation` class that orchestrates actor dispatchers, inbox/outbox listeners, WebFinger, HTTP signatures, and background tasks. The repository is a monorepo containing ~35+ packages under the `@fedify/*` scope, including integration adapters for popular web frameworks (Express, Hono, Fastify, Koa, Next.js, Nuxt, SvelteKit, SolidStart, Astro, Fresh, NestJS, Elysia, H3), storage backends (PostgreSQL, SQLite, MySQL, Redis, Deno KV, Cloudflare Workers KV, PGlite), message queues (AMQP, Redis, SQLite, MySQL, in-process, Cloudflare Workers Queues, Netlify Async Workloads), and developer tooling (CLI, project scaffolding, linting rules, debug dashboard, benchmarking). The architecture is highly modular with clean interface contracts (e.g., `KvStore`, `MessageQueue`) that multiple backends implement consistently, enabling users to swap infrastructure without changing application code. The core focuses on ActivityPub protocol compliance, including JSON-LD handling, HTTP Message Signatures (RFC 9421, Cavage), Linked Data Signatures, and Object Integrity Proofs. The codebase is well-tested with unit tests, integration tests, smoke tests against real Mastodon/Sharkey instances, and a dedicated benchmark suite.
The LLM identified 6 files worth highlighting for reuse:
Defines the `KvStore` interface and an in-memory implementation (`MemoryKvStore`). This is a fundamental abstraction that decouples federation logic from storage backend. The interface supports key-value operations with CAS (compare-and-swap), listing by prefix, and TTL expiration. Multiple backend packages (`@fedify/postgres`, `@fedify/sqlite`, `@fedify/redis`, etc.) implement this interface, making it a reusable contract for any ActivityPub application. The pattern is clean, minimal, and easily imitable in other projects.
Defines the `MessageQueue` interface and provides an in-process implementation (`InProcessMessageQueue`). The interface supports `enqueue`, `listen`, and `getDepth` with optional ordering keys, native retrial, and deduplication flags. A `ParallelMessageQueue` decorator wraps any queue to add concurrent processing while preserving ordering key serialization. This is an exceptionally clean and reusable abstraction that can be extracted to any project needing a pluggable message queue.
Implements the Multibase encoding/decoding specification with support for 23 base variants (base58btc, base64url, etc.). The implementation is self-contained, well-tested, and includes constants, RFC 4648 base encodings, and utility functions. It can be extracted as a standalone library for any project requiring cryptographic key serialization in ActivityPub or IPFS contexts.
Full implementation of RFC 6570 URI Template routing with a trie-based router for matching and building paths. Supports Level 4 operators, variable constraints, and priority-based route selection. The module is self-contained, extensively tested (benchmarks and conformance tests), and can be reused as a standalone URI template router. It represents a non-obvious implementation of a complex specification.
Provides a reusable `testKvStore` function that validates any `KvStore` implementation against a comprehensive set of conformance tests (CAS, TTL, listing, atomic operations). This is a textbook example of an interface conformance test suite that can be extracted and applied to any KV store implementation with minimal adaptation. It ensures backend consistency across the ecosystem.
Implements HTTP Message Signature acceptance and verification (RFC 9421 / draft-cavage). Parses `Signature-Input`, `Signature` headers, validates against the `Accept-Signature` negotiation, and verifies Ed25519/RSA keys. This is a self-contained, well-tested module that demonstrates non-obvious cryptographic and protocol handling. It can be reused in any HTTP-based project requiring signed request verification.