The Index Schema

Learn about how we define the structure of a book in the Sefaria Library.

Index Schemas

The structure of a book is defined in the Index schema. These schemas are trees made up of nodes.
In the Python code , these nodes are instances of the class sefaria.model.schema.SchemaNode and its children. The trees are stored in the database and transmitted through the API in a serialized form.

Node Types for an Index Schema Tree

Index schemas are structured as trees. In most cases, the internal nodes of these trees are of type SchemaNode, while the leaves of the tree are of typeJaggedArrayNode. For further information on this, take a look at the next section) of our documentation.

Below is a diagram of the class hierarchy that defines the various Index schema nodes.

Inheritance Hierarchy of Index Schema Nodes at Sefaria

The Inheritance Hierarchy of Index Schema Nodes in the Sefaria Library

Please note: Since not all of this information is immediately relevant to most engineers working on projects that use Sefaria's data, we only elaborate on SchemaNode and JaggedArrayNode in these docs. For a deeper dive, you can explore a more detailed description of the schema on GitHub.