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

# AI Workers

> Node.js workers on EC2 powering AI proposal generation and PDF extraction

## Overview

Grouple runs two Node.js AI workers on a dedicated EC2 instance managed by PM2. Both workers use Amazon Bedrock (Claude 4.6) for AI processing.

## Infrastructure

```
ECS API Containers
        ↓ trigger task
Dedicated EC2 Instance (PM2)
  ├── AI Proposal Worker (Node.js)
  └── PDF Extract Worker (Node.js)
        ↓ both call
Amazon Bedrock (Claude 4.6)
        ↓ save results
Supabase PostgreSQL
```

## AI Proposal Worker

**Purpose:** Generates AI-powered group booking proposals for merchants.

**How it works:**

```
Merchant clicks "Generate with AI" on Send Proposal page
        ↓
Frontend calls generate-proposal Edge Function (or API)
        ↓
Worker receives:
  - Enquiry details (group size, budget tier, occasion type, requirements)
  - Venue details (name, capacity, pricing, amenities, cuisine types)
  - Extracted menu/package data from venue_knowledge
        ↓
Builds a contextual prompt for Bedrock Claude 4.6
        ↓
Claude generates:
  - Proposal title and description
  - Recommended packages and inclusions
  - Pricing suggestions
  - Personalised message to the customer
        ↓
Result returned to merchant for review and editing
        ↓
Merchant sends → proposal saved to Supabase
```

**AI model:** Amazon Bedrock Claude 4.6
**Deployment:** PM2 on EC2, Node.js

***

## PDF Extract Worker

**Purpose:** Extracts structured data from venue menu PDFs and brochures uploaded to Supabase Storage.

**How it works:**

```
Merchant uploads PDF menu to venue-brochures storage
        ↓
venue_knowledge record created with file_path
        ↓
PDF Extract Worker picks up the task
        ↓
Downloads PDF from Supabase Storage
        ↓
Sends PDF content to Amazon Bedrock Claude 4.6 for extraction
        ↓
Claude extracts:
  - Menu items, categories, prices
  - Package names and inclusions
  - Special offerings
        ↓
Structured JSON saved to venue_knowledge.extracted_data
        ↓
Used by AI Proposal Worker when generating proposals
```

**AI model:** Amazon Bedrock Claude 4.6
**Deployment:** PM2 on EC2, Node.js

***

## EC2 Instance Details

Both workers share the same EC2 instance, managed by PM2 for process management and auto-restart on failure.

* **Access:** Via PEM key (SSH)
* **Process manager:** PM2
* **AWS credentials:** Injected via AWS Secrets Manager / IAM role
* **Bedrock region:** AWS us-east-1
