> For the complete documentation index, see [llms.txt](https://book.restfulnode.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.restfulnode.com/part-2/chapter-5/5-domain.md).

# Domain

Our domain layer would mainly consist of 3 items: ***services***, ***models***, and ***repositories***. We went in depth in the last chapter, [Layered/N-Tier Architecture: The Unpopular Proven Way](/part-2/chapter-4/2-layered-n-tier-architecture-the-unpopular-proven-way.md#new-school-mvc-services-and-repositories), so make sure to read up on those concepts if you are not sure about what those 3 items are.

## Services

We talked about services and what they are, services will usually use other services and repositories to perform some sort of business logic operation.

For example, a UserService will have a method called `registerUser`.

UserService would potentially use a UserRepository to insert the user into the database and an EmailService to send an email to the user if they successfully registered.

## Models (Entities)

Models usually represent something in the business and are generally going to be some sort of Object Relational Mapper (ORM). They could be SQL based or NoSQL based. Models can also be just plain old objects. For us, we will be using a MongoDB, and [Mongoose ](https://mongoosejs.com)as our NoSQL database adapter.

Examples of models would be a *User*, a *Car*, a *Book*, a *House*, an *Animal*, and more.

## Repositories

If you can recall, repositories are essentially an abstraction layer of models. In general, repositories will have CRUD operations as their methods wrapped around the native models.

An example would be:

*BookRepository*

* `getAllBooks()`
* `createABook(book)`
* `deleteABook(bookId)`


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.restfulnode.com/part-2/chapter-5/5-domain.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
