Easily restore your project to a previous version with our new Instant One-click Backup Recovery
Hygraph
Docs

Full process example

#Overview

In this document, we will walk through the full process of building a content model using a simple & practical example. We'll use the example of a bookshop website again, which we used for some of the examples we shared in the previous documents.

This step-by-step example shows you how to approach content modeling, starting with desk research and interviews, working with cross-functional teams, and finally building a content a schema in Hygraph for a basic website that sells books. Following this method will help you make sure that your Hygraph project is structured properly, and is flexible & scalable.

#1. Desk research & interviews

The content modeling process starts with research. For our example, imagine that you work for a chain of bookshops that asked you to build a content model for their website. You'll begin with desk research to understand the domain. That is, how bookshops typically structure their information, from book details to genres, authors, and reviews.

Once you have a basic understanding, it's time to interview key stakeholders:

  • Content creators who will use the CMS to enter book details, manage inventory, and create content.
  • Sales team to understand how customers interact with the site and what information facilitates sales.
  • Developers to learn about their preferred tech stack, and understand how they need content to be structured for scalability and good performance.
  • Marketing team to get information about customer engagement and promotional content.

After your research and interviews, you'll have a list of terms that will be the foundation of your content model. For the sake of this example, we created this list for you:

  • Books
  • Authors
  • Genres
  • Reviews
  • Price
  • ISBN
  • Availability
  • Promotions

#Relationships between terms

You'll need to think about how these concepts relate to each other. We've thought of some examples for you:

  • Each Book is written by one or more Authors.
  • Each Book belongs to one or more Genres.
  • Each Book may have multiple Reviews.
  • Each Book has one ISBN.
  • Each Genre may have several Books and Authors.
  • Each Book has one Price.

After identifying these concepts and their relationships, the next step is to decide which ones will serve as object domains and which will act as attributes. Let's move forward to the next step, where we will build the domain model.

#2. Building the Domain Model

Next, bring in your cross-functional team to build the domain model. This model will represent the entire business (everything from managing inventory to customer engagement). It's fundamental to include members from different departments to make sure that all parts of the business are taken into consideration.

For example, in our bookshop example, the domain model would cover:

  • Inventory: Books, Authors, Genres.
  • Customer Reviews: User feedback on books.
  • Sales and Promotions: Book prices, discounts.
  • User Engagement: Popular books, new arrivals.
  • Business Management: Stock availability, order processing.
  • Store Locations: Physical shop locations, contact details, operating hours.
  • Employee Management: Staff details, roles, scheduling.
  • Suppliers: Supplier contact information, orders, contracts.

Teamwork should result in a high-level domain model for the bookshop that contains a list of object domains and considers how they are related.

Here is a list of possible object domains and some attributes related to them:

Domain objectsAttributes
BooksTitle, ISBN, price, availability, summary, cover image.
AuthorsName, biography, photo.
GenresName, description, authors, books.
ReviewsUser name, rating, review text.
PromotionsDiscount name, description, amount, active period.
Store LocationsShop name, address, contact details, operating hours.
Employee ManagementEmployee name, role, shift schedule, contact information.
SuppliersSupplier name, contact information, order history, contracts.

Here is a list of possible relationships:

Domain objectsRelation
Books and AuthorsA book is written by one or more authors. An author can write multiple books.
Books and GenresA book belongs to one or more genres. A genre can have multiple books associated with it.
Books and ReviewsA book can have multiple reviews from different users. A user can review multiple books.
Reviews and AuthorsAn author can have multiple reviews from different users. A user can review multiple authors.
Books and PromotionsA book can be associated with one or more active promotions (such as discounts or pre-ordering). A promotion can apply to multiple books.
Reviews and UsersA review is submitted by a single user. A user can submit multiple reviews.
Books and PromotionsA sale or discount can be applied to available books.
Books and SuppliersA supplier provides one or more books. A book may be sourced from multiple suppliers.
Store Locations and BooksA store location stocks multiple books. A book may be available in multiple store locations.
Suppliers and Store LocationsA supplier provides stock to one or more store locations. A store location receives stock from multiple suppliers.
Employee Management and BooksEmployees may be responsible for specific books (for instance: curating, doing inventory or stocking).
Promotions and Store LocationsA promotion may be applied to specific store locations. A store location may have multiple promotions.

The goal of the domain model is to provide a full picture of how the business operates. However, when creating your schema for the website, you'll only include object domains directly related to the content that users will interact with, such as Books, Authors, Genres, and Promotions.

#3. Build the schema

Now that we have a domain model, we need to focus on the part of it that's relevant to our website's content. In this case, we'll create a content model for displaying books and their related information on a product page.

In Hygraph, the content model is called the schema, the content types are called models, and the attributes are called fields. We'll use Hygraph vocabulary from now on.

Here is a high level Schema that we created using the Domain Model from the previous section:

  • Book (Content Type/Model).
    • Fields: Title, ISBN, Price, Summary, Availability, Book cover, Genres (Reference), Author (Reference), Reviews (Reference), Promotion (Modular component field).
  • Author (Content Type/Model).
    • Fields: Name, Biography, Photo, Books (Reference), Genres (Reference), Reviews (Reference).
  • Genre (Content Type/Model).
    • Fields: Name, Description.

In Hygraph, you define your project schema by creating models and adding fields to them. We've already defined our models based on the domain model, but only briefly listed the specific fields we want to add to them.

Let's look closely into each of these fields in Hygraph.

#Book Model

This is the primary content type on our bookshop website.

FieldDescription
TitleA Single line text field for the book title.
ISBNA Single line text for each book as a unique identifier.
PriceA Float field to store the book's price.
SummaryA Rich text field for the book description.
AvailabilityA Boolean field indicating if the book is in stock.
Book coverAn Asset picker field to upload the book cover image.
GenresA two-way Reference field linking to the Genre model .
AuthorA two-way Reference field linking to the Author model.
PromotionA Basic component field that allows adding a promotion component previously created in the project.

#Promotion component

This component could contain the following fields:

FieldDescription
NameA Single line text field for promotion name.
DiscountAn Enumeration field that allows selecting a discount from a list.
DescriptionA Rich text field for the promotion description.
ImageAn Asset picker field to include an image related with the promotion.

#Author Model

This model stores information about the book's author.

FieldDescription
NameA Single line text field for the author's name.
BiographyA Rich text field for the author's bio.
PhotoAn Asset picker field to upload the author's image.
BooksA two-way Reference field linking to the Books model.
GenresA two-wayReference field linking to the Genre model.

#Genre Model

This model categorizes books based on their genres.

FieldDescription
NameA Single line text field for the genre name (for instance: Fiction, Non-Fiction).
DescriptionA Rich text field to provide more information about the genre.
AuthorsReverse field of the Genre reference in the Author model.
BooksReverse field of the Genre reference in the Book model.

#Next steps

By now, you've created a schema in Hygraph that reflects the models and fields that we outlined above. This structured, scalable approach can now be used to expand your bookshop website or any future projects where content modeling is key.

This schema allows editors to easily create content while developers can query it efficiently via the API. It also guarantees that users will have a smooth experience where elements are connected in a cohesive way that reflects the real world.

When working on future content modeling projects, apply the gradual bottom-up approach we showed you here. Building complex systems by focusing on individual components first ensures each part is well integrated into the whole. Involving a cross-functional team guarantees that all voices are heard and all perspectives are taken into consideration.

#Resources

Here's a list of additional resources that you can look into:

DocumentDescription
Getting startedOur getting started tutorial project takes you from project planning to schema creation and frontend implementation.
Hygraph recipesOur recipes help you discover what elements you can create in your Hygraph project using different configurations.
Implementation guidesOur implementation guides are perfect for devs who need a little help connecting their Hygraph project to a frontend.
Integration guidesOur list of integrated apps is constantly growing. Check them out to find out how they can enhance your project.