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

# Dynamodb supabase streaming deployment

# DynamoDB to Supabase Streaming - Deployment Guide

## Overview

This system streams data from AWS DynamoDB ConsultationsTable to Supabase scenarios table in real-time using DynamoDB Streams and Lambda functions.

## Prerequisites

* AWS CLI configured with appropriate permissions
* CDK installed (`npm install -g aws-cdk`)
* Supabase project with scenarios table created
* Environment variables configured

## Environment Setup

1. **Create .env file in aws/ai/ directory:**

```bash theme={null}
ANTHROPIC_API_KEY=your_anthropic_key_here
SUPABASE_PASSWORD=your_supabase_password_here
```

2. **Create scenarios table in Supabase:**

```sql theme={null}
CREATE TABLE scenarios (
    id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
    user_id TEXT NOT NULL,
    consultation_id TEXT,
    scenario_data JSONB NOT NULL,
    created_at TIMESTAMPTZ DEFAULT NOW(),
    updated_at TIMESTAMPTZ DEFAULT NOW(),
    dynamo_sequence_number TEXT UNIQUE NOT NULL,
    dynamo_event_name TEXT NOT NULL
);

CREATE INDEX idx_scenarios_user_id ON scenarios (user_id);
CREATE INDEX idx_scenarios_consultation_id ON scenarios (consultation_id);
```

## Deployment Commands

### Dev Environment (Safe - Won't Affect Production)

```bash theme={null}
cd aws
cdk deploy -c env=dev
```

This creates `AgentStack-dev` with all resources prefixed with `dev-`.

### Production Environment (Uses Existing Stack)

```bash theme={null}
cd aws
cdk deploy
```

This uses your existing `AgentStack` without changes.

## Post-Deployment Steps

1. **Get NAT Gateway IP from CDK output**
2. **Add IP to Supabase network restrictions:**
   * Go to Supabase Dashboard → Settings → Database
   * Add the NAT Gateway IP to allowed connections

## Verification

1. **Check Lambda functions are deployed**
2. **Verify DynamoDB streams are enabled**
3. **Test by creating a consultation - data should appear in Supabase scenarios table**
4. **Monitor CloudWatch logs for any errors**

## Architecture

```
DynamoDB → DynamoDB Streams → Lambda → VPC NAT Gateway → Supabase
```

The system provides real-time data synchronization with error handling, retry logic, and complete environment isolation.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.