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

# Enterprise Patterns

> Scale Peanuts across teams with governance and best practices

<Info>
  **Time:** 20 minutes | **Level:** Expert\
  **Prerequisites:** [Sharing & Collaboration](/tutorials/intermediate/sharing-and-collaboration), [Knowledge Base Fundamentals](/tutorials/advanced/knowledge-base-fundamentals)\
  **Requires:** Team plan
</Info>

## What You'll Learn

* Design helper architectures for teams
* Implement governance and access control
* Standardize templates across departments
* Build approval workflows and audit trails

***

## Team Architecture

### Single Source of Truth

Design your helper ecosystem with clear ownership:

```mermaid theme={null}
flowchart TD
    A[Organization] --> B[Finance Team]
    A --> C[Sales Team]
    A --> D[Operations]
    
    B --> B1[Expense Tracker - Owner: CFO]
    B --> B2[Invoice Log - Owner: Controller]
    
    C --> C1[Lead Tracker - Owner: Sales Director]
    C --> C2[Meeting Notes - Owner: Sales Ops]
    
    D --> D1[Inventory - Owner: Ops Manager]
    D --> D2[Maintenance Log - Owner: Facilities]
```

### Helper Naming Convention

Establish clear naming patterns:

| Pattern                | Example            | Use Case           |
| ---------------------- | ------------------ | ------------------ |
| `[Team] - [Purpose]`   | Finance - Expenses | Team-owned helpers |
| `[Project] - [Type]`   | Alpha - Tasks      | Project-specific   |
| `[Client] - [Service]` | Acme - Support     | Client-facing      |
| `Personal - [Name]`    | Personal - Notes   | Individual use     |

***

## Access Control Matrix

### Permission Levels

<Tabs>
  <Tab title="Delegation">
    **Use case:** Staff logs on behalf of manager

    * Staff member creates entries
    * Entries attributed to owner
    * Owner sees all data
    * Staff sees only their contributions

    **Example:** Executive assistant logging CEO's meetings
  </Tab>

  <Tab title="Collaboration">
    **Use case:** Team works together on shared data

    * All members can add entries
    * Visibility based on role (Viewer/Contributor/Editor)
    * Owner manages permissions
    * Entries show who created them

    **Example:** Sales team sharing lead updates
  </Tab>

  <Tab title="Template">
    **Use case:** Standardize structure without sharing data

    * Recipient gets helper structure only
    * No data transferred
    * They become owner of their copy
    * Updates don't sync

    **Example:** Distributing expense tracker template to all managers
  </Tab>
</Tabs>

### Role Permissions Matrix

| Permission     | Viewer | Contributor | Editor | Owner |
| -------------- | ------ | ----------- | ------ | ----- |
| View entries   | ✅      | ✅           | ✅      | ✅     |
| Add entries    | ❌      | ✅           | ✅      | ✅     |
| Edit entries   | ❌      | ❌           | ✅      | ✅     |
| Delete entries | ❌      | ❌           | ✅      | ✅     |
| View insights  | ✅      | ✅           | ✅      | ✅     |
| Manage sharing | ❌      | ❌           | ❌      | ✅     |
| Edit helper    | ❌      | ❌           | ❌      | ✅     |

***

## Template Governance

### Master Template Library

Create a central library of approved templates:

<Steps>
  <Step title="Design Master Templates">
    Create helpers with standardized fields, widgets, and settings.

    **Example - Standard Expense Tracker:**

    * Amount (required, number)
    * Category (select: Travel, Meals, Office, Software)
    * Vendor (text)
    * Receipt (image)
    * Approval Status (select: Pending, Approved, Rejected)
  </Step>

  <Step title="Document Standards">
    Create internal documentation for each template:

    * Required fields and validation rules
    * Expected usage patterns
    * Reporting requirements
  </Step>

  <Step title="Distribute via Template Sharing">
    Share templates with "Template" mode to team leads.
    Each team lead gets a copy to customize for their team.
  </Step>

  <Step title="Version Control">
    Name templates with versions: `Expense Tracker v2.1`
    Document changes when updating master templates.
  </Step>
</Steps>

### Template Categories

| Category   | Examples                       | Owner        |
| ---------- | ------------------------------ | ------------ |
| Finance    | Expenses, Invoices, Budgets    | Finance Team |
| HR         | Time-off, Reviews, Onboarding  | HR Team      |
| Sales      | Leads, Meetings, Pipeline      | Sales Ops    |
| Operations | Inventory, Maintenance, Assets | Ops Team     |
| IT         | Tickets, Assets, Deployments   | IT Team      |

***

## Approval Workflows

### Building Review Processes

Use helper fields to create approval workflows:

**Expense Approval Helper Design:**

```
Fields:
├── Amount (number, required)
├── Category (select)
├── Description (text)
├── Receipt (image)
├── Status (select: Draft, Submitted, Under Review, Approved, Rejected)
├── Submitted By (text, auto-filled)
├── Reviewed By (text)
├── Review Notes (text, multiline)
└── Approved Date (date)
```

**Workflow with Webhooks:**

```typescript theme={null}
async function handleExpenseEntry(event: WebhookEvent) {
  const { status, amount, submitted_by } = event.entry.data;
  
  if (status === 'Submitted') {
    // Route to appropriate approver
    const approver = amount > 500 ? 'director@company.com' : 'manager@company.com';
    
    await sendEmail({
      to: approver,
      subject: `Expense Approval Required: $${amount}`,
      body: `${submitted_by} submitted an expense for review.`
    });
  }
  
  if (status === 'Approved' || status === 'Rejected') {
    // Notify submitter
    await sendEmail({
      to: submitted_by,
      subject: `Expense ${status}: $${amount}`,
      body: `Your expense has been ${status.toLowerCase()}.`
    });
  }
}
```

***

## Audit & Compliance

### Entry Attribution

Every entry includes metadata:

```json theme={null}
{
  "entry": {
    "id": "entry_abc123",
    "created_at": "2026-01-15T10:30:00Z",
    "created_by": "user_789",
    "data": { ... }
  }
}
```

### Building Audit Reports

Use scheduled reports for compliance:

<Steps>
  <Step title="Create Audit Helper">
    Design a helper specifically for audit trail:

    * Action (select: Created, Updated, Deleted, Approved)
    * Target Helper (text)
    * Entry ID (text)
    * User (text)
    * Timestamp (datetime)
    * Details (text, multiline)
  </Step>

  <Step title="Log via Webhooks">
    Forward all helper webhooks to your audit helper or external system.
  </Step>

  <Step title="Schedule Reports">
    Create weekly/monthly audit reports sent to compliance team.
  </Step>
</Steps>

### Retention Policies

Document and communicate data retention:

| Data Type         | Retention                 | Action               |
| ----------------- | ------------------------- | -------------------- |
| Financial records | 7 years                   | Archive after 1 year |
| HR records        | 3 years after termination | Secure delete        |
| Operational logs  | 1 year                    | Rotate monthly       |
| Personal trackers | User discretion           | Self-managed         |

***

## Scaling Patterns

### Department Rollout

<Steps>
  <Step title="Pilot Phase">
    Start with one team (e.g., Finance with expense tracking).
    Document learnings, refine templates.
  </Step>

  <Step title="Expand Horizontally">
    Roll out proven templates to similar teams.
    Train department champions.
  </Step>

  <Step title="Cross-Functional">
    Connect helpers across departments via webhooks.
    Build unified dashboards.
  </Step>

  <Step title="Organization-Wide">
    Establish governance committee.
    Regular template reviews and updates.
  </Step>
</Steps>

### Training Program

| Audience    | Content                                | Duration |
| ----------- | -------------------------------------- | -------- |
| End Users   | Basic logging, voice input, mobile use | 30 min   |
| Power Users | Widgets, sharing, Ask Peanuts          | 1 hour   |
| Team Leads  | Template management, permissions       | 1 hour   |
| Admins      | Webhooks, integrations, compliance     | 2 hours  |

***

## Security Best Practices

<CardGroup cols={2}>
  <Card title="Principle of Least Privilege" icon="lock">
    Grant minimum permissions needed. Start with Viewer, upgrade as needed.
  </Card>

  <Card title="Regular Access Reviews" icon="clipboard-check">
    Quarterly review of who has access to what. Remove stale permissions.
  </Card>

  <Card title="Secure Webhooks" icon="shield">
    Always verify signatures. Use HTTPS. Rotate secrets periodically.
  </Card>

  <Card title="Data Classification" icon="tags">
    Label helpers by sensitivity: Public, Internal, Confidential, Restricted.
  </Card>
</CardGroup>

***

## Exercise

<Card title="Practice: Design Team Rollout" icon="dumbbell">
  Create a rollout plan for a 3-team deployment:

  1. **Define templates** for each team (minimum 2 per team)
  2. **Map permissions** - who gets Viewer/Contributor/Editor access
  3. **Document naming convention** your organization will use
  4. **Plan webhook integrations** - what external systems need data
  5. **Create training outline** for each user tier

  Deliverable: One-page rollout document
</Card>

***

## Key Takeaways

<Tip>
  **Remember:** Successful enterprise deployment requires clear ownership, standardized templates, appropriate permissions, and documented governance. Start small, prove value, then scale.
</Tip>

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Building Client Tools" href="/tutorials/expert/building-client-tools" icon="users">
    Create self-service tools for external clients
  </Card>

  <Card title="Webhooks Reference" href="/features/webhooks" icon="bolt">
    Detailed webhook documentation
  </Card>
</CardGroup>
