Aphex

Introduction

Aphex CMS — a database-agnostic, Sanity-inspired content management system built with SvelteKit.

Aphex is a headless CMS built with SvelteKit and Svelte 5. It takes inspiration from Sanity's schema-driven approach while being fully database-agnostic through a ports and adapters architecture.

The fastest way to try it is with the create-aphex scaffolder:

pnpm create aphex
# or: npm create aphex@latest

Head to Getting Started for the full walkthrough.

Key Features

  • Schema-driven — define your content model with TypeScript. Get a full admin UI, REST API, GraphQL API, and database schema automatically.
  • Database-agnostic — ships with PostgreSQL via Drizzle ORM. Bring your own adapter for any database.
  • SvelteKit-native — runs as part of your SvelteKit app. No separate server to manage.
  • Draft / published workflow — auto-save every couple of seconds, hash-based change detection, one-click publish.
  • Version history — every draft save and publish is captured. Editors can preview and restore any prior version.
  • Singletons — mark a schema as singleton: true to model global content (site nav, footer, settings) as a single auto-resolving row.
  • Multi-tenancy — organizations with PostgreSQL row-level security and a parent / child hierarchy.
  • Capability-based access control — edit built-in roles, define custom roles per organization, and gate schemas / fields by role or policy function.
  • Authentication — Better Auth integration with email + password, API keys, and email-verified sign-up.
  • S3-compatible storage — AWS S3, Cloudflare R2, MinIO, or local filesystem.
  • Hono-powered HTTP layer — register custom routes and middleware via the api(app) config hook.
  • Email — Resend or any SMTP provider via the Nodemailer adapter; Mailpit by default in dev.

Architecture

Aphex follows a hexagonal (ports & adapters) architecture. The core engine (@aphexcms/cms-core) defines interfaces for database, storage, authentication, email, and cache. Separate packages provide implementations:

PackagePurpose
@aphexcms/cms-coreCore engine, admin UI, Hono HTTP routes, built-in GraphQL, types
@aphexcms/postgresql-adapterPostgreSQL + Drizzle ORM adapter
@aphexcms/storage-s3S3-compatible storage (R2, AWS S3, MinIO)
@aphexcms/resend-adapterEmail via Resend
@aphexcms/nodemailer-adapterEmail via Nodemailer / SMTP (includes a Mailpit shorthand)
@aphexcms/uiShared shadcn-svelte component library

Next Steps

Edit on GitHub

Last updated on