> For the complete documentation index, see [llms.txt](https://docs.soapjs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.soapjs.com/components/model.md).

# Model

## Model

A **model** (document / DTO) is the **persistence shape** of your data — how a record looks in the database. It's kept separate from the domain Entity so storage concerns never leak into your business model; a Mapper converts between them. Write it by hand in the feature's `data/` folder:

```typescript
// data/character.dto.ts — the MongoDB document shape
export interface CharacterDocument {
  _id: string;
  name: string;
  universe: string;
  alignment: string;
  createdAt: Date;
  updatedAt: Date;
}
```

### Entity vs Model

|               | Entity                    | Model (document/DTO) |
| ------------- | ------------------------- | -------------------- |
| Layer         | `domain/`                 | `data/`              |
| Purpose       | business rules + behavior | storage shape        |
| Knows the DB? | no                        | yes (e.g. `_id`)     |
| Defined as    | class                     | interface / type     |
