# Entities Layer — Innermost, Zero Dependencies ## Rules - NEVER import from application/, infrastructure/, interface-adapters/, or di/ - NEVER import external libraries except Zod (for schema validation) - Everything here is pure — no side effects, no I/O, no async - Models are Zod schemas with inferred TypeScript types - Errors are custom Error subclasses with domain-specific semantics ## Adding a New Model 1. Create `src/entities/models/{name}.ts` 2. Define Zod schema and export inferred type: ```typescript import { z } from "zod"; export const {name}Schema = z.object({ ... }); export type {Name} = z.infer; ``` 3. Export from `src/entities/models/index.ts` ## Adding a New Error 1. Create or edit `src/entities/errors/{domain}.ts` 2. Extend Error with constructor accepting message + options: ```typescript export class {Name}Error extends Error { constructor(message: string, options?: ErrorOptions) { super(message, options); } } ``` 3. Export from `src/entities/errors/index.ts`