What is the Architecture of Sanity and its Data Model?

5 replies
Last updated: Aug 4, 2022
Hello 👋 . Complete newbie to Sanity. This is a great find 🎉 and I am totally loving it ❤️ . Is there any documentation on how the app and the underlying data model is architected. Thanks !!
AI Update

Welcome to Sanity! 🎉 So glad you're loving it! Let me break down the architecture and data model for you.

Platform Architecture

Sanity is built as a "Content Operating System" with three main pillars:

  1. Content Lake - Your unified, real-time content database
  2. Live CDN - Global content delivery network
  3. Compute + AI - Serverless functions, webhooks, and AI capabilities

The Content Lake (Your Data Foundation)

The Content Lake is Sanity's content-optimized database that stores everything as structured JSON documents. Think of it as a specialized database designed specifically for content operations with built-in features like:

  • Real-time capabilities - Multiple editors can work simultaneously
  • Revision history - Track every change to your content
  • Referential integrity - Maintain relationships between content
  • Atomic mutations - Ensure data consistency
  • Global distribution - Fast access worldwide via CDN

Document Structure

Every piece of content in Sanity is a document with a specific structure. Documents have system fields that Sanity manages automatically:

  • _id - Unique identifier for the document
  • _type - The schema type (like "post", "author", "product")
  • _rev - Revision identifier
  • _createdAt - Creation timestamp
  • _updatedAt - Last update timestamp

Datasets and Drafts

Content is organized into datasets (think of them as separate content repositories within your project). Sanity has a built-in drafts system - when you edit a published document, it creates a draft version with the ID pattern drafts.{documentId}, keeping your published content safe until you're ready to publish changes.

Querying with GROQ

You query your content using GROQ (Graph-Relational Object Queries), Sanity's powerful query language. It lets you fetch exactly the content you need with relationships and transformations. GraphQL is also supported if you prefer that approach.

Sanity Studio

The editing interface is Sanity Studio - a headless, customizable TypeScript/React CMS that connects to your Content Lake. You define your content model using schemas, and Studio automatically generates the editing interface.

Modern Features

Recent additions to the platform include:

  • Sanity Functions - Serverless compute for event handlers
  • Agent Actions - Built-in AI that can read/write content
  • Content Releases - Stack changes and publish atomically
  • Live Content API - Real-time content delivery without websockets

The beauty of this architecture is that your content lives in the Content Lake as structured data, while you can use Studio (or build custom apps with the App SDK) to edit it, and query it from any frontend framework you choose. It's truly composable!

Is an entry a single document or uses tables like in mysql ? I am trying to decide if Sanity would be right for a client project.
Welcome
user R
, nice to have you here 👋So Sanity is based on Structured Data, which is different than a table based system.

https://www.sanity.io/structured-content This means, that a content strategy is key using Sanity (or structured content) in its full potential.

Our very own
user J
is an expert on these topics, and in addition to her book , talks and many videos you can find online, she is also helping people out in content-strategy and content-modeling.
Hope that helps
🙂 and let me know, if you need any more help or pointers.Btw: you can always ask for pointers in
help ☺️
Ah and to your first question: we have extensive and READABLE docs, guides etc. on how Sanity, Studio and Content Lake works (also check out GROQ)
Plus: as we are open Source (for most parts at least) you can also check out our Github!
would love to hear from
user J
. The sanity backend seems to be built on json documents kinda nosql system, referencing other documents to create a page ? 🤔 . That might be better for editorial experiences, but probably not for a data rich app ?
Well yes and no to the JSON… it’s based on JS Object syntax.But we have a lot of very complex multi-domain systems built on Sanity.
Regarding Carrie, You will have to be either more specific and pose your question in one of the channels I mentioned before, or read/watch our/her content about the possibilities of structured content
🙂
My recommendation
https://www.youtube.com/playlist?list=PLRzQpWc3zNPkrIwaz1qfTMx0IGSfCFPKX

Sanity – Build the way you think, not the way your CMS thinks

Sanity is the developer-first content operating system that gives you complete control. Schema-as-code, GROQ queries, and real-time APIs mean no more workarounds or waiting for deployments. Free to start, scale as you grow.

Was this answer helpful?