# 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: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
