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

# Welcome to Forge

> Program design studio for building benefit programs with AI assistance

# Welcome to Forge

> Forge is where benefit programs are born. Upload documents, ask questions about similar programs, build eligibility templates, and generate all the messaging you need—in every language.

Program managers spend months designing new benefit programs. They research similar programs, define eligibility criteria, create documentation requirements, design workflows, and write communications for every scenario. Forge compresses this work from months to days.

***

## What Forge Does

Forge is a **program design studio** with four integrated capabilities:

<CardGroup cols={2}>
  <Card title="Document Library" icon="folder-open">
    Upload RFPs, guidelines, existing program materials, and reference documents. Build a knowledge base for your programs.
  </Card>

  <Card title="Program Q&A" icon="comments">
    Ask questions about similar programs. "What income limits do rental assistance programs typically use?" Get answers grounded in your documents and existing programs.
  </Card>

  <Card title="Template Builder" icon="table-cells">
    Build program templates with guided workflows. Define eligibility criteria, required documents, application fields, and review workflows.
  </Card>

  <Card title="Messaging Generator" icon="envelope">
    Generate all program communications—approval letters, denial notices, reminder emails, social media posts, flyers—and auto-translate to 20+ languages.
  </Card>
</CardGroup>

***

## Who Uses Forge

**Primary User: Program Manager**

The program manager is not technical. She needs:

* A polished, intuitive UI (no scripts or code)
* Ability to upload documents and ask questions
* Guided workflows for building program templates
* One-click export to Terra
* All messaging variants generated and translated

**Secondary Users:**

* **Executive Director**: Review program designs before launch
* **Communications Team**: Access generated messaging for campaigns
* **Case Managers**: Reference program requirements during intake

***

## Core Workflows

### 1. Program Research

```mermaid theme={null}
flowchart LR
    Upload[Upload Docs] --> Library[Document Library]
    Library --> Ask[Ask Questions]
    Ask --> Answers[AI-Grounded Answers]
    Answers --> Insights[Program Insights]
```

**Example questions:**

* "What income limits do similar rental assistance programs use?"
* "What documents are typically required for childcare subsidies?"
* "How do other programs handle self-employed applicants?"
* "What fraud controls do housing programs implement?"

### 2. Template Building

```mermaid theme={null}
flowchart LR
    Start[Start Template] --> Elig[Define Eligibility]
    Elig --> Docs[Required Documents]
    Docs --> Fields[Application Fields]
    Fields --> Workflow[Review Workflow]
    Workflow --> Export[Export to Terra]
```

**Template components:**

* **Eligibility Rules**: Income limits, household requirements, residency, citizenship
* **Required Documents**: Paystubs, ID, proof of address, bank statements
* **Application Fields**: Questions mapped to eligibility criteria
* **Review Workflow**: Approval steps, fraud checks, notification triggers

### 3. Messaging Generation

```mermaid theme={null}
flowchart LR
    Program[Select Program] --> Generate[Generate Messaging]
    Generate --> Variants[All Variants]
    Variants --> Translate[Auto-Translate]
    Translate --> Export[Export for Use]
```

**Or upload a flyer:**

```mermaid theme={null}
flowchart LR
    Flyer[Upload Flyer] --> Extract[Extract Content]
    Extract --> Generate[Generate All Messaging]
    Generate --> Translate[Translate 20+ Languages]
```

***

## Messaging Variants

For any program, Forge generates:

| Category          | Variants                                                                             |
| ----------------- | ------------------------------------------------------------------------------------ |
| **Outreach**      | Social media posts (Twitter, Facebook, Instagram), community flyers, partner toolkit |
| **Notifications** | Application received, documents needed, under review, decision pending               |
| **Approvals**     | Approval letter, payment details, next steps, renewal timeline                       |
| **Denials**       | Denial notice, appeal rights, alternative programs, reapplication info               |
| **Reminders**     | Document deadline, renewal due, payment scheduled, follow-up needed                  |
| **Banners**       | Website banners, email headers, form announcements                                   |

All variants are generated in:

* Plain language (8th grade reading level)
* Legally compliant format
* Culturally appropriate for target communities
* Auto-translated to 20+ languages

***

## Integration with Terra

Forge exports program templates directly to Terra:

```mermaid theme={null}
flowchart LR
    subgraph Forge
        Template[Program Template]
        Messaging[Messaging Variants]
    end

    subgraph Terra
        Form[Draft Form]
        Notifications[Notification Templates]
        Branding[Program Branding]
    end

    Template -->|"Export"| Form
    Messaging -->|"Export"| Notifications
    Messaging -->|"Export"| Branding
```

**What gets exported:**

* Form schema (fields, logic, validation)
* Eligibility rules (conditional logic)
* Notification templates (email/SMS)
* Branding assets (if generated)

***

## Technical Architecture

### Document Processing

1. **Upload**: PDF, Word, images accepted
2. **Extract**: OCR + AI extraction via `@unify/extraction`
3. **Chunk**: Split into semantic chunks for retrieval
4. **Embed**: Generate embeddings via `@unify/ai`
5. **Store**: Vector store for similarity search

### Q\&A Pipeline

```typescript theme={null}
// User asks a question
const question = "What income limits do rental assistance programs use?";

// Retrieve relevant documents
const relevantDocs = await vectorSearch(question, {
  sources: ['uploaded_docs', 'existing_programs', 'public_benefits'],
  limit: 10,
});

// Generate grounded answer
const answer = await rag({
  query: question,
  documents: relevantDocs,
  options: { citeSources: true },
});

// Returns answer with citations
{
  answer: "Most rental assistance programs set income limits at 80% of Area Median Income (AMI)...",
  citations: [
    { source: "HUD Guidelines 2024.pdf", page: 12 },
    { source: "Seattle ERAP Program", section: "Eligibility" },
  ]
}
```

### Template Schema

```typescript theme={null}
interface ProgramTemplate {
  id: string;
  name: string;
  description: string;

  eligibility: {
    incomeLimit: {
      type: 'ami_percentage' | 'fpl_percentage' | 'fixed_amount';
      value: number;
      householdAdjustment: boolean;
    };
    residency: {
      required: boolean;
      jurisdictions: string[];
    };
    citizenship: {
      requirements: ('citizen' | 'permanent_resident' | 'work_authorized' | 'any')[];
    };
    customRules: EligibilityRule[];
  };

  requiredDocuments: {
    type: DocumentType;
    required: boolean;
    alternatives: DocumentType[];
    description: string;
  }[];

  applicationFields: FormField[];

  workflow: {
    steps: WorkflowStep[];
    fraudChecks: FraudCheck[];
    notificationTriggers: NotificationTrigger[];
  };

  messaging: {
    outreach: MessagingVariant[];
    notifications: MessagingVariant[];
    approvals: MessagingVariant[];
    denials: MessagingVariant[];
    reminders: MessagingVariant[];
  };
}
```

***

## Data Model

### Core Tables

```sql theme={null}
-- Program templates created in Forge
CREATE TABLE forge_templates (
  id UUID PRIMARY KEY,
  name TEXT NOT NULL,
  description TEXT,
  status TEXT DEFAULT 'draft', -- draft, review, published
  template_data JSONB NOT NULL,
  created_by UUID REFERENCES users,
  created_at TIMESTAMPTZ DEFAULT NOW(),
  updated_at TIMESTAMPTZ DEFAULT NOW()
);

-- Documents uploaded for research
CREATE TABLE forge_documents (
  id UUID PRIMARY KEY,
  template_id UUID REFERENCES forge_templates,
  filename TEXT NOT NULL,
  file_path TEXT NOT NULL,
  extracted_text TEXT,
  chunk_count INTEGER,
  created_at TIMESTAMPTZ DEFAULT NOW()
);

-- Document chunks for vector search
CREATE TABLE forge_chunks (
  id UUID PRIMARY KEY,
  document_id UUID REFERENCES forge_documents,
  chunk_index INTEGER,
  content TEXT NOT NULL,
  embedding VECTOR(1536),
  metadata JSONB
);

-- Generated messaging variants
CREATE TABLE forge_messaging (
  id UUID PRIMARY KEY,
  template_id UUID REFERENCES forge_templates,
  category TEXT NOT NULL, -- outreach, notification, approval, denial, reminder
  variant_type TEXT NOT NULL, -- social_twitter, email_reminder, etc.
  content JSONB NOT NULL, -- I18nString with all translations
  created_at TIMESTAMPTZ DEFAULT NOW()
);

-- Q&A history for context
CREATE TABLE forge_conversations (
  id UUID PRIMARY KEY,
  template_id UUID REFERENCES forge_templates,
  messages JSONB NOT NULL, -- Array of {role, content, citations}
  created_at TIMESTAMPTZ DEFAULT NOW()
);
```

***

## UI Wireframe

### Main Layout

```
┌─────────────────────────────────────────────────────────────────┐
│  Forge                                    [User] [Settings]     │
├──────────────┬──────────────────────────────────────────────────┤
│              │                                                  │
│  Programs    │  Emergency Rental Assistance                     │
│  ──────────  │  ═══════════════════════════                    │
│              │                                                  │
│  > ERA 2025  │  [Documents] [Q&A] [Template] [Messaging]       │
│    SNAP Exp  │  ─────────────────────────────────────          │
│    Childcare │                                                  │
│              │  ┌─────────────────────────────────────────┐    │
│  ──────────  │  │                                         │    │
│  + New       │  │   Ask a question about this program     │    │
│              │  │   or similar programs...                │    │
│              │  │                                         │    │
│              │  └─────────────────────────────────────────┘    │
│              │                                                  │
│              │  Recent Questions                                │
│              │  ────────────────                               │
│              │  • What income limits do similar programs use?  │
│              │  • What documents are typically required?       │
│              │  • How do other programs handle appeals?        │
│              │                                                  │
└──────────────┴──────────────────────────────────────────────────┘
```

### Template Builder

```
┌─────────────────────────────────────────────────────────────────┐
│  Template Builder                          [Save] [Export]      │
├─────────────────────────────────────────────────────────────────┤
│                                                                 │
│  Progress: ████████░░░░░░░░ 50%                                │
│                                                                 │
│  [✓] Eligibility  [✓] Documents  [ ] Fields  [ ] Workflow      │
│  ─────────────────────────────────────────────────────────────  │
│                                                                 │
│  Required Documents                                             │
│  ═══════════════════                                           │
│                                                                 │
│  ┌─────────────────────────────────────────────────────────┐   │
│  │  [✓] Proof of Income                                    │   │
│  │      Paystubs (last 30 days) OR Tax return OR           │   │
│  │      Self-employment documentation                       │   │
│  ├─────────────────────────────────────────────────────────┤   │
│  │  [✓] Proof of Identity                                  │   │
│  │      Government-issued ID                                │   │
│  ├─────────────────────────────────────────────────────────┤   │
│  │  [✓] Proof of Address                                   │   │
│  │      Utility bill OR Lease agreement                    │   │
│  ├─────────────────────────────────────────────────────────┤   │
│  │  [ ] Proof of Crisis (optional)                         │   │
│  │      Eviction notice, job loss letter, etc.             │   │
│  └─────────────────────────────────────────────────────────┘   │
│                                                                 │
│  [+ Add Document Requirement]                                   │
│                                                                 │
│                              [← Back]  [Next: Application Fields →]
└─────────────────────────────────────────────────────────────────┘
```

***

## Implementation Phases

### Phase 1: Document Library + Q\&A

* Document upload and storage
* Text extraction and chunking
* Vector embeddings and search
* Basic Q\&A interface

### Phase 2: Template Builder

* Eligibility rule builder
* Document requirements UI
* Application field generator
* Terra export

### Phase 3: Messaging Generator

* Messaging variant generation
* Flyer upload and extraction
* Auto-translation
* Export for all channels

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Core Concepts" icon="brain" href="/forge/foundation/core-concepts">
    Mental models for program design
  </Card>

  <Card title="Document Processing" icon="file-lines" href="/forge/core-systems/document-processing">
    How documents are extracted and indexed
  </Card>

  <Card title="Template Schema" icon="table-cells" href="/forge/core-systems/template-schema">
    Program template data model
  </Card>

  <Card title="Messaging Engine" icon="envelope" href="/forge/core-systems/messaging-engine">
    How messaging variants are generated
  </Card>
</CardGroup>
