# aws-samples/aws-ai-appflow-veeva-integration architecture

> Architecture diagram of the GitHub repository aws-samples/aws-ai-appflow-veeva-integration, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-10). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aws-samples/aws-ai-appflow-veeva-integration
- Repository: https://github.com/aws-samples/aws-ai-appflow-veeva-integration

## Overview

This repository implements a Veeva Vault asset-analysis integration using Amazon AppFlow and AWS AI services. The principal workflow transfers Veeva documents and metadata to S3, uses AppFlow completion events to enqueue supported assets, processes them asynchronously, and stores extracted tags. Separate consumers publish results to OpenSearch and write high-confidence tags back to Veeva. The README documents the product flow; sampled handlers show the processing and integration logic. Event-source wiring for the DynamoDB consumers is not shown, so those links are marked unverified.

Main entry points: [`code/source/AVAIQueuePoller.py`](https://github.com/aws-samples/aws-ai-appflow-veeva-integration/blob/main/code/source/AVAIQueuePoller.py) (Queue poller), [`code/source/AVAIAppFlowListener.py`](https://github.com/aws-samples/aws-ai-appflow-veeva-integration/blob/main/code/source/AVAIAppFlowListener.py) (Flow listener), [`code/source/AVAIPopulateES.py`](https://github.com/aws-samples/aws-ai-appflow-veeva-integration/blob/main/code/source/AVAIPopulateES.py) (OpenSearch sync), [`code/source/AVAICustomFieldPopulator.py`](https://github.com/aws-samples/aws-ai-appflow-veeva-integration/blob/main/code/source/AVAICustomFieldPopulator.py) (Custom field writer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Asset ingestion"]
  node_appflow["Amazon AppFlow"]
  node_eventbridge["Amazon EventBridge"]
  node_listener["Flow listener"]
  node_s3[("Asset S3 bucket")]
  node_queue["Asset queue"]
end

subgraph group_process["AI processing"]
  node_poller["Queue poller<br/>[AVAIQueuePoller.py]"]
  node_comprehend["Comprehend Medical"]
  node_rekognition["Rekognition"]
  node_textract["Textract"]
  node_transcribe["Transcribe"]
end

subgraph group_results["Results and search"]
  node_dynamodb[("Tag table")]
  node_es_sync["OpenSearch sync<br/>[AVAIPopulateES.py]"]
  node_dashboard["OpenSearch dashboard"]
end

subgraph group_writeback["Vault writeback"]
  node_field_writer["Custom field writer"]
end

node_vault["Veeva Vault"]

node_vault -->|"supplies assets"| node_appflow
node_appflow -->|"transfers assets"| node_s3
node_appflow -->|"publishes run events"| node_eventbridge
node_eventbridge -->|"triggers"| node_listener
node_listener -->|"reads metadata"| node_s3
node_listener -->|"enqueues assets"| node_queue
node_queue -->|"provides messages"| node_poller
node_poller -->|"reads assets"| node_s3
node_poller -->|"extracts entities"| node_comprehend
node_poller -->|"analyzes images"| node_rekognition
node_poller -->|"extracts PDF text"| node_textract
node_poller -->|"transcribes audio"| node_transcribe
node_poller -->|"writes tags"| node_dynamodb
node_dynamodb -.->|"feeds change records"| node_es_sync
node_es_sync -->|"indexes for viewing"| node_dashboard
node_dynamodb -.->|"feeds tag records"| node_field_writer
node_field_writer -->|"updates custom fields"| node_vault

click node_listener "https://github.com/aws-samples/aws-ai-appflow-veeva-integration/blob/main/code/source/AVAIAppFlowListener.py"
click node_poller "https://github.com/aws-samples/aws-ai-appflow-veeva-integration/blob/main/code/source/AVAIQueuePoller.py"
click node_es_sync "https://github.com/aws-samples/aws-ai-appflow-veeva-integration/blob/main/code/source/AVAIPopulateES.py"
click node_dashboard "https://github.com/aws-samples/aws-ai-appflow-veeva-integration/blob/main/code/ESConfig/AVAI_ES_Entity_Dashboard.ndjson"
click node_field_writer "https://github.com/aws-samples/aws-ai-appflow-veeva-integration/blob/main/code/source/AVAICustomFieldPopulator.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_appflow,node_eventbridge,node_listener,node_s3,node_queue toneBlue
class node_poller,node_comprehend,node_rekognition,node_textract,node_transcribe toneAmber
class node_dynamodb,node_es_sync,node_dashboard toneMint
class node_field_writer toneRose
class node_vault toneIndigo
```

## Components

### Asset ingestion

- **Amazon AppFlow**
- **Amazon EventBridge**
- [Flow listener](https://github.com/aws-samples/aws-ai-appflow-veeva-integration/blob/main/code/source/AVAIAppFlowListener.py): `code/source/AVAIAppFlowListener.py`
- **Asset S3 bucket**
- **Asset queue**

### AI processing

- [Queue poller](https://github.com/aws-samples/aws-ai-appflow-veeva-integration/blob/main/code/source/AVAIQueuePoller.py): `code/source/AVAIQueuePoller.py`
- **Comprehend Medical**
- **Rekognition**
- **Textract**
- **Transcribe**

### Results and search

- **Tag table**
- [OpenSearch sync](https://github.com/aws-samples/aws-ai-appflow-veeva-integration/blob/main/code/source/AVAIPopulateES.py): `code/source/AVAIPopulateES.py`
- [OpenSearch dashboard](https://github.com/aws-samples/aws-ai-appflow-veeva-integration/blob/main/code/ESConfig/AVAI_ES_Entity_Dashboard.ndjson): `code/ESConfig/AVAI_ES_Entity_Dashboard.ndjson`

### Vault writeback

- [Custom field writer](https://github.com/aws-samples/aws-ai-appflow-veeva-integration/blob/main/code/source/AVAICustomFieldPopulator.py): `code/source/AVAICustomFieldPopulator.py`

### Other components

- **Veeva Vault**

## Connections

- Veeva Vault → Amazon AppFlow: supplies assets (evidence: `README.md`)
- Amazon AppFlow → Asset S3 bucket: transfers assets (evidence: `README.md`)
- Amazon AppFlow → Amazon EventBridge: publishes run events (evidence: `README.md`)
- Amazon EventBridge → Flow listener: triggers (evidence: `README.md`)
- Flow listener → Asset S3 bucket: reads metadata (evidence: `code/source/AVAIAppFlowListener.py`)
- Flow listener → Asset queue: enqueues assets (evidence: `code/source/AVAIAppFlowListener.py`)
- Asset queue → Queue poller: provides messages (evidence: `README.md`)
- Queue poller → Asset S3 bucket: reads assets (evidence: `code/source/AVAIQueuePoller.py`)
- Queue poller → Comprehend Medical: extracts entities (evidence: `code/source/AVAIQueuePoller.py`)
- Queue poller → Rekognition: analyzes images (evidence: `code/source/AVAIQueuePoller.py`)
- Queue poller → Textract: extracts PDF text (evidence: `README.md`)
- Queue poller → Transcribe: transcribes audio (evidence: `code/source/AVAIQueuePoller.py`)
- Queue poller → Tag table: writes tags (evidence: `code/source/AVAIQueuePoller.py`)
- Tag table → OpenSearch sync: feeds change records
- OpenSearch sync → OpenSearch dashboard: indexes for viewing (evidence: `README.md`)
- Tag table → Custom field writer: feeds tag records
- Custom field writer → Veeva Vault: updates custom fields (evidence: `code/source/AVAICustomFieldPopulator.py`)
