Overview
Key characteristics:- React-based SPA - Modern component architecture
- Real-time collaboration - Multiple users can edit simultaneously
- Schema-driven - Content structure defined in JavaScript/TypeScript
- Highly extensible - Plugin system for customization
- GROQ-powered - Graph-Oriented Query Language for data access
Repository structure
Sanity Studio is developed as a monorepo containing multiple packages:Package dependency graph
The packages have a layered dependency structure:Key packages
| Package | Description |
|---|---|
sanity | Main studio package containing UI, form builder, structure tool, and core functionality |
@sanity/cli | Command-line interface for project management, builds, and deployments |
@sanity/types | TypeScript type definitions for documents, schemas, and common data structures |
@sanity/schema | Schema compilation, validation, and type inference |
@sanity/mutator | Document mutation logic for real-time collaboration |
@sanity/diff | Generates diffs between documents for change tracking |
@sanity/vision | GROQ query playground tool (Studio plugin) |
Studio and workspace architecture
The Studio is configured usingdefineConfig() which creates one or more workspaces. Each workspace represents an independent content environment with its own:
- Project ID and Dataset - Connection to Content Lake
- Schema - Document and field type definitions
- Plugins - Extended functionality
- Tools - Top-level navigation views
Data flow architecture
Query flow
- Component requests data via hooks (
useDocumentStore,useClient) - Document Store manages subscriptions and caching
- Client sends GROQ queries to Content Lake
- Real-time listeners push updates back
Mutation flow
- User edits trigger form changes
- Form builder generates patches
- Mutator applies patches optimistically
- Mutations sent to Content Lake
- Confirmation/conflict resolution
Module organization
The mainsanity package is organized into modules:
Entry points
Thesanity package exposes multiple entry points:
| Import | Description |
|---|---|
sanity | Main exports (defineConfig, components, hooks) |
sanity/structure | Structure tool and builder |
sanity/router | Routing utilities |
sanity/presentation | Presentation tool |
Key technologies
| Technology | Purpose |
|---|---|
| React | UI component framework |
| TypeScript | Type safety and developer experience |
| RxJS | Reactive data streams and state management |
| Vite | Development server and build tool |
| GROQ | Query language for Content Lake |
| Portable Text | Rich text data structure |
| @sanity/ui | Design system components |
For more details on the monorepo structure and development workflow, see the ARCHITECTURE.md file in the repository.