> ## Documentation Index
> Fetch the complete documentation index at: https://docs.earthcare.network/llms.txt
> Use this file to discover all available pages before exploring further.

# CRM

> Organization (the tenant), Membership, and the Attio-style CRM core: Contact, Account, Deal, Task.

The CRM is the workspace. **Organization** is the tenant boundary for credits,
membership, and all workspace data.

## Organization

| Field                                          | Type     | Notes                        |
| ---------------------------------------------- | -------- | ---------------------------- |
| `id`                                           | UUID     | Primary key                  |
| `slug`                                         | string   | Unique                       |
| `kind`                                         | enum     | `BUSINESS · AGENCY · CLIENT` |
| `parent_agency`                                | FK(self) | Agency → client sub-accounts |
| `monthly_credit_cap`, `max_credits_per_action` | number   | Budget guards                |
| `ai_paused`                                    | bool     | Blocks managed AI            |

## Core CRM objects

| Model                      | Purpose                                                            | Key relationships                                      |
| -------------------------- | ------------------------------------------------------------------ | ------------------------------------------------------ |
| `Membership`               | User ↔ Org with role (`OWNER · ADMIN · MEMBER · SCOUT · VERIFIER`) | FK Organization, User                                  |
| `Contact`                  | A lead/person                                                      | FK Organization, optional `linked_business`, `account` |
| `CrmAccount`               | A company record                                                   | FK Organization, optional `linked_business`            |
| `Deal`                     | Pipeline opportunity (`LEAD · QUALIFIED · PROPOSAL · WON · LOST`)  | FK Organization, Contact, Business                     |
| `Task`                     | Work item (`OPEN · IN_PROGRESS · DONE · CANCELLED`)                | FK Organization, assignee                              |
| `Interaction`              | Logged touchpoint (audit trail)                                    | FK Organization, Contact                               |
| `Conversation` / `Message` | Email threads (drafts gate outbound)                               | FK Organization, Contact                               |
| `Form` / `FormSubmission`  | Lead-capture forms → CRM records                                   | FK Organization                                        |
| `CrmFieldDefinition`       | Custom fields (Attio-style)                                        | FK Organization                                        |
| `CrmSavedView`             | Saved filtered list views                                          | FK Organization                                        |
| `Notification`             | Workspace activity feed                                            | FK Organization, User                                  |

## Custom fields

`CrmFieldDefinition` + a `custom_data` JSON blob on Contact/Account/Deal give
flexible, per-org schema without migrations.

<Note>Generated from the `crm` app models; field lists re-sync each iteration.</Note>
