# Support Chat with RAG System

## Quick Reference

| Action | Method |
|--------|--------|
| Access Support Chat | https://predict.agencio.cloud/admin/support-chat |
| Manage Docs | https://predict.agencio.cloud/admin/support-docs |
| Bulk Ingest Support Docs | `POST /api/predict/v1/admin/support-docs/bulk-ingest` |
| Bulk Ingest User Guide | `POST /api/predict/v1/admin/support-docs/bulk-ingest-user-guide` |
| Assign Support Role | `/admin/users` → Edit user → Role: Support |

---

## Overview

The RAG (Retrieval-Augmented Generation) system powers TWO separate chat features:

| Feature | Audience | Document Scope | Access |
|---------|----------|----------------|--------|
| **Support Chat** | super_admin, support roles | Full docs corpus (`scope='support'`) | `/admin/support-chat` |
| **User Ask AI** | All platform users | User guide only (`scope='user-guide'`) | Floating assistant in app |

### Support Chat
Internal knowledge-base chat for support staff and administrators, powered by Claude with RAG on the full documentation corpus.

### User Ask AI
The in-app assistant that helps all users understand the platform. Uses RAG on the `docs/user-guide/` documentation (23 files) to answer questions about features, trading, brokers, etc.

---

## Architecture

```
┌─────────────────────────────────────────────────────────────────────────┐
│                         Support Chat System                              │
│                                                                          │
│  ┌──────────────┐    ┌──────────────┐    ┌──────────────┐              │
│  │   Document   │    │  Embeddings  │    │   pgvector   │              │
│  │   Upload     │───▶│   (Voyage/   │───▶│   Storage    │              │
│  │   (S3)       │    │   OpenAI)    │    │   (1536d)    │              │
│  └──────────────┘    └──────────────┘    └──────────────┘              │
│                                                  │                       │
│  ┌──────────────┐                               │                       │
│  │   User       │                               ▼                       │
│  │   Question   │───▶ Embed Query ───▶ Similarity Search                │
│  └──────────────┘                               │                       │
│                                                  │                       │
│  ┌──────────────┐    ┌──────────────┐          │                       │
│  │   Claude     │◀───│   Context    │◀─────────┘                       │
│  │   Response   │    │   Injection  │                                   │
│  └──────────────┘    └──────────────┘                                   │
│         │                                                                │
│         ▼                                                                │
│  ┌──────────────────────────────────────────────────────┐               │
│  │  Streaming Response with Source Citations            │               │
│  └──────────────────────────────────────────────────────┘               │
└─────────────────────────────────────────────────────────────────────────┘
```

---

## Access Control

| Role | Support Chat | Document Management |
|------|--------------|---------------------|
| `super_admin` | ✅ Full access | ✅ Upload, delete, reprocess |
| `support` | ✅ Full access | ❌ No access |
| Other roles | ❌ No access | ❌ No access |

To assign the `support` role to a user:
1. Go to `/admin/users`
2. Edit the user
3. Select "Support" from the role dropdown
4. Save changes

---

## Database Schema

### Migrations
- `196_support_chat_rag.sql` - Core tables
- `197_support_docs_scope.sql` - Document scope column

#### `predict.support_documents`
Catalog of uploaded documents.

| Column | Type | Description |
|--------|------|-------------|
| `id` | BIGSERIAL | Primary key |
| `filename` | VARCHAR(255) | Original filename |
| `filepath` | VARCHAR(500) | S3 key path (unique) |
| `content_type` | VARCHAR(100) | MIME type (text/markdown, application/pdf) |
| `size_bytes` | BIGINT | File size |
| `checksum_sha256` | VARCHAR(64) | SHA256 hash (deduplication) |
| `status` | VARCHAR(20) | pending, processing, ready, failed |
| `error_message` | TEXT | Error details if failed |
| `chunk_count` | INTEGER | Number of chunks created |
| `uploaded_by` | UUID | User who uploaded |
| `scope` | VARCHAR(30) | Document scope (default: 'support') |
| `created_at` | TIMESTAMPTZ | Upload timestamp |
| `updated_at` | TIMESTAMPTZ | Last update |

**Document Scopes:**
| Scope | Description | Used By |
|-------|-------------|---------|
| `support` | Full documentation corpus | Support Chat (admin/support roles) |
| `user-guide` | User-facing help documentation | User Ask AI (all users) |

#### `predict.support_document_chunks`
Document chunks with vector embeddings.

| Column | Type | Description |
|--------|------|-------------|
| `id` | BIGSERIAL | Primary key |
| `document_id` | BIGINT | FK to support_documents |
| `chunk_index` | INTEGER | Position in document |
| `content` | TEXT | Chunk text |
| `token_count` | INTEGER | Estimated tokens (~4 chars/token) |
| `embedding` | vector(1536) | pgvector embedding |
| `embedding_model` | VARCHAR(60) | voyage-3-lite or text-embedding-3-small |
| `metadata` | JSONB | Start/end offsets |
| `created_at` | TIMESTAMPTZ | Creation timestamp |

**Indexes:**
- `idx_support_chunks_document` - Document lookup
- `idx_support_chunks_embedding` - HNSW vector similarity (cosine)

#### `predict.support_conversations`
Chat conversation threads.

| Column | Type | Description |
|--------|------|-------------|
| `id` | UUID | Primary key |
| `user_id` | UUID | Owner |
| `title` | VARCHAR(255) | Auto-derived from first message |
| `is_saved` | BOOLEAN | Bookmarked (persistent across devices) |
| `created_at` | TIMESTAMPTZ | Creation |
| `updated_at` | TIMESTAMPTZ | Last activity |

#### `predict.support_turns`
Individual messages in conversations.

| Column | Type | Description |
|--------|------|-------------|
| `id` | UUID | Primary key |
| `conversation_id` | UUID | FK to support_conversations |
| `role` | VARCHAR(20) | 'user' or 'assistant' |
| `content` | TEXT | Message text |
| `sources` | JSONB | Array of source citations |
| `model` | VARCHAR(60) | LLM model used |
| `tokens_in` | INTEGER | Input tokens |
| `tokens_out` | INTEGER | Output tokens |
| `latency_ms` | INTEGER | Response time |
| `feedback` | SMALLINT | -1 (down), 0 (none), 1 (up) |
| `created_at` | TIMESTAMPTZ | Timestamp |

---

## API Endpoints

### Chat Endpoints (super_admin, support)

| Method | Path | Description |
|--------|------|-------------|
| POST | `/api/predict/v1/support-chat/stream` | SSE chat stream with RAG |
| GET | `/api/predict/v1/support-chat/conversations` | List user's conversations |
| GET | `/api/predict/v1/support-chat/conversations/[id]` | Get conversation with turns |
| POST | `/api/predict/v1/support-chat/conversations/[id]/save` | Toggle bookmark |
| POST | `/api/predict/v1/support-chat/feedback` | Rate a response (-1/0/1) |

### Document Management (super_admin only)

| Method | Path | Description |
|--------|------|-------------|
| GET | `/api/predict/v1/admin/support-docs` | List all documents + stats |
| POST | `/api/predict/v1/admin/support-docs` | Upload document (multipart) |
| GET | `/api/predict/v1/admin/support-docs/[id]` | Get document details |
| DELETE | `/api/predict/v1/admin/support-docs/[id]` | Delete document + chunks |
| POST | `/api/predict/v1/admin/support-docs/[id]` | Reprocess document |
| POST | `/api/predict/v1/admin/support-docs/bulk-ingest` | Bulk ingest from S3 (scope=support) |
| POST | `/api/predict/v1/admin/support-docs/bulk-ingest-user-guide` | Bulk ingest user-guide docs (scope=user-guide) |

---

## Backend Services

### Location: `packages/be/src/support-chat/`

| File | Purpose |
|------|---------|
| `types.ts` | TypeScript interfaces |
| `repository.ts` | Database CRUD (documents, chunks, conversations, turns) |
| `text-extractor.ts` | Extract text from .md, .txt, .pdf files |
| `chunker.ts` | Split text into overlapping ~512-token chunks |
| `ingestion.ts` | Full pipeline: upload → extract → chunk → embed → store |
| `retrieval.ts` | Vector similarity search on chunks |
| `handler.ts` | SSE streaming chat handler with RAG context injection |
| `index.ts` | Exports |

### Document Processing Pipeline

1. **Upload**: File uploaded via multipart form to `/admin/support-docs`
2. **Validation**: Check file type (.md, .txt, .pdf) and size (max 10MB)
3. **Deduplication**: SHA256 checksum prevents duplicate uploads
4. **Storage**: File stored in S3 bucket `predict-support-docs`
5. **Extraction**: Text extracted (pdf-parse for PDFs)
6. **Chunking**: Text split into ~512-token chunks with 64-token overlap
7. **Embedding**: Chunks embedded via Voyage AI (or OpenAI fallback)
8. **Storage**: Embeddings stored in pgvector column

### RAG Query Flow

1. **Query Embedding**: User question embedded using same model as documents
2. **Similarity Search**: pgvector HNSW index finds top-5 similar chunks
3. **Relevance Filter**: Chunks with similarity < 0.5 filtered out
4. **Context Building**: Relevant chunks formatted with source filenames
5. **LLM Prompt**: Claude receives system prompt + RAG context + user question
6. **Streaming Response**: SSE stream with `meta`, `delta`, `final`, `done` events
7. **Source Citations**: Response includes source document references

---

## Storage

### S3 Bucket: `predict-support-docs`

- **Region**: ap-southeast-1
- **Versioning**: Enabled
- **Public Access**: Blocked (all 4 settings)
- **Max File Size**: 10 MB
- **Supported Types**: .md, .txt, .pdf

### File Path Convention
```
support-docs/{timestamp}-{filename}
```

### AWS Infrastructure

**Existing Resources (manually created):**
- **Bucket**: `predict-support-docs`
- **Region**: `ap-southeast-1`
- **VPC Endpoint**: `vpce-0feebe4aa435d7034` (S3 Gateway endpoint)
- **VPC**: `vpc-0b7bc7e31a9e793e7` (agencio-predict-vpc)

**Security Configuration:**
- **Public Access**: Blocked (all 4 settings enabled)
- **Encryption**: AES-256 server-side encryption with S3-managed keys
- **Versioning**: Enabled (for data protection and recovery)
- **VPC Endpoint**: Gateway endpoint for private S3 access from within VPC

**CloudFormation Integration:**
The `deploy/aws/cloudformation.yml` template includes:
- Optional S3 bucket creation (`CreateSupportDocsBucket` parameter)
- VPC endpoint for S3 (requires `RouteTableId` parameter)
- IAM task role with S3 permissions
- Environment variable `SUPPORT_DOCS_BUCKET` for the bucket name

**S3 Content:**
125 markdown files from `/docs` have been uploaded to the bucket under `support-docs/docs/`.

> **Important**: Files in S3 are NOT automatically searchable. Each document must be **ingested**
> (uploaded via `/admin/support-docs`) to be processed into chunks and embeddings stored in pgvector.
> S3 serves as raw storage; the database holds the searchable vector index.

---

## Embeddings Configuration

The system supports two embedding providers:

| Provider | Model | Dimensions | Priority |
|----------|-------|------------|----------|
| Voyage AI | voyage-3-lite | 1024 | Primary |
| OpenAI | text-embedding-3-small | 1536 | Fallback |

**Environment Variables:**
- `VOYAGE_API_KEY` - Voyage AI API key (recommended)
- `OPENAI_API_KEY` - OpenAI API key (fallback)

If neither is configured, RAG silently degrades to no context (chat still works without document retrieval).

---

## Environment Variables

| Variable | Required | Description |
|----------|----------|-------------|
| `CLAUDE_API_KEY` | Yes | Anthropic API key for chat responses |
| `VOYAGE_API_KEY` | Recommended | Voyage AI API key for embeddings (primary) |
| `OPENAI_API_KEY` | Optional | OpenAI API key for embeddings (fallback) |
| `AWS_ACCESS_KEY_ID` | Yes | AWS credentials for S3 access |
| `AWS_SECRET_ACCESS_KEY` | Yes | AWS credentials for S3 access |
| `AWS_REGION` | Yes | AWS region (default: `ap-southeast-1`) |
| `STORAGE_PROVIDER` | Yes | Set to `s3` for production |
| `DATABASE_URL` | Yes | PostgreSQL connection string |

**Note**: The `support` role requires `CLAUDE_API_KEY` for chat. Document management requires AWS credentials for S3.

---

## UI Pages

### `/admin/support-chat`
- Chat interface with conversation sidebar
- Save/bookmark conversations (synced across devices via database)
- Source citations in responses
- Feedback buttons (thumbs up/down)
- Link to document management

### `/admin/support-docs`
- Document list with status indicators
- Drag-and-drop upload zone
- Stats: total documents, ready count, total chunks, embedding status
- Per-document actions: view details, reprocess (for failed), delete

---

## Rate Limiting

Support chat shares the same rate limit as the main assistant:
- **30 turns per user per hour**
- Redis-backed sliding window
- In-memory fallback for development

---

## Production Deployment Status

**Deployed**: 2026-05-08

| Component | Status | Details |
|-----------|--------|---------|
| UI Pages | ✅ Live | `/admin/support-chat`, `/admin/support-docs` |
| API Routes | ✅ Live | 11 endpoints (chat + docs management + bulk ingest) |
| Database | ✅ Migrated | 4 tables + scope column in `predict` schema |
| pgvector | ✅ Installed | v0.7.4 with HNSW index |
| S3 Bucket | ✅ Created | `predict-support-docs` (ap-southeast-1) |
| VPC Endpoint | ✅ Created | `vpce-0feebe4aa435d7034` |
| Bulk Ingest API | ✅ Ready | `POST /admin/support-docs/bulk-ingest` |
| User Guide Ingest API | ✅ Ready | `POST /admin/support-docs/bulk-ingest-user-guide` |
| Support Docs (S3) | ✅ Done | 99 markdown files in `support-docs/docs/` |
| User Guide (S3) | ✅ Done | 23 markdown files in `support-docs/user-guide/` |
| Documents Ingested | ⚠️ Pending | Run bulk-ingest APIs to process S3 files |

**Production URLs:**
- Chat: `https://predict.agencio.cloud/admin/support-chat`
- Docs: `https://predict.agencio.cloud/admin/support-docs`

---

## Testing the System

### Quick Start (Production)

1. **Login** as `super_admin` at https://predict.agencio.cloud
2. **Navigate** to `/admin/support-docs`
3. **Upload** a markdown file (drag & drop or click browse)
4. **Wait** for status: `pending` → `processing` → `ready`
5. **Navigate** to `/admin/support-chat`
6. **Ask** a question about the uploaded document
7. **Verify** response includes source citations

### Database Verification

```bash
# SSH to EC2 and check tables
ssh -i ~/.ssh/agencio-predict.pem ec2-user@54.255.100.122
docker exec predict-postgres psql -U postgres -d predict_db -c \
  "SELECT table_name FROM information_schema.tables
   WHERE table_schema = 'predict' AND table_name LIKE 'support%';"
```

Expected output:
```
       table_name
-------------------------
 support_conversations
 support_document_chunks
 support_documents
 support_turns
(4 rows)
```

### Verify pgvector Extension

```bash
docker exec predict-postgres psql -U postgres -d predict_db -c \
  "SELECT extversion FROM pg_extension WHERE extname = 'vector';"
```

Expected: `0.7.4`

### Check Document & Chunk Counts

```bash
docker exec predict-postgres psql -U postgres -d predict_db -c \
  "SELECT
     (SELECT COUNT(*) FROM predict.support_documents) as documents,
     (SELECT COUNT(*) FROM predict.support_documents WHERE status = 'ready') as ready,
     (SELECT COUNT(*) FROM predict.support_document_chunks) as chunks;"
```

### Test Chat API (requires auth token)

```bash
curl -X POST https://predict.agencio.cloud/api/predict/v1/support-chat/stream \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer <token>" \
  -d '{"message": "What is Agencio Predict?", "conversationId": null}'
```

---

## Ingesting Documentation

### Manual Upload (Recommended for small batches)

1. Go to `/admin/support-docs`
2. Drag and drop files or click to browse
3. Multiple files can be uploaded at once
4. Each file processes independently

### Document Processing Flow

```
Upload → S3 Storage → Text Extraction → Chunking → Embedding → pgvector Storage
         (instant)      (< 1 sec)       (< 1 sec)   (1-3 sec)     (< 1 sec)
```

Total processing time: ~3-5 seconds per document (depending on size)

### Bulk Ingestion from S3

**API Endpoint**: `POST /api/predict/v1/admin/support-docs/bulk-ingest`

Triggers bulk ingestion of all markdown files from S3 bucket.

```bash
# Trigger bulk ingestion (requires super_admin auth)
curl -X POST https://predict.agencio.cloud/api/predict/v1/admin/support-docs/bulk-ingest \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"prefix": "support-docs/docs/"}'
```

**Request Body (optional):**
```json
{
  "prefix": "support-docs/docs/"  // S3 prefix to scan (default: support-docs/docs/)
}
```

**Response:**
```json
{
  "success": true,
  "total": 125,
  "ingested": 120,
  "skipped": 3,
  "errors": 2,
  "totalChunks": 1547,
  "files": [
    { "filename": "01-getting-started.md", "status": "success", "documentId": 1, "chunkCount": 12 },
    { "filename": "02-platform-features.md", "status": "skipped", "documentId": 2, "chunkCount": 8 },
    { "filename": "bad-file.md", "status": "error", "error": "No text content" }
  ]
}
```

**CLI Script Alternative:**
```bash
# Run bulk ingestion script locally (requires env vars)
npx tsx scripts/bulk-ingest-support-docs.ts
```

The script processes files in batches of 5 with 2-second delays to avoid rate limits.

---

## Troubleshooting

### Document stuck in "processing"
- Check server logs for errors
- Verify embedding provider is configured
- Try reprocessing via the document actions menu

### No sources in responses
- Verify documents are in "ready" status
- Check embedding provider is configured (`VOYAGE_API_KEY` or `OPENAI_API_KEY`)
- Ensure question relates to document content

### Chat returns "LLM_NOT_CONFIGURED"
- Verify `CLAUDE_API_KEY` or `ANTHROPIC_API_KEY` is set

### S3 upload fails
- Verify AWS credentials are configured
- Check bucket `predict-support-docs` exists
- Verify IAM permissions include `s3:PutObject`

---

## User Ask AI Integration

The main user-facing assistant (`/packages/be/src/assistant/handler.ts`) now includes RAG retrieval from `user-guide` scoped documents.

### How It Works

1. When a user asks a question via the in-app assistant
2. The handler queries pgvector for similar chunks with `scope='user-guide'`
3. Relevant context is injected into the system prompt
4. Claude responds with guidance based on user documentation
5. Sources are cited in the response

### Ingesting User Guide Docs

**Option 1: Via API (recommended for production)**
```bash
curl -X POST https://predict.agencio.cloud/api/predict/v1/admin/support-docs/bulk-ingest-user-guide \
  -H "Authorization: Bearer <token>" \
  -H "Content-Type: application/json" \
  -d '{"prefix": "support-docs/user-guide/"}'
```

**Option 2: Via CLI script (development)**
```bash
# First upload docs to S3
aws s3 sync docs/user-guide/ s3://predict-support-docs/support-docs/user-guide/ --exclude "*" --include "*.md"

# Then run ingestion
npx tsx scripts/ingest-user-guide-docs.ts
```

### User Guide Documentation (23 files)

Located in `docs/user-guide/` and S3 `support-docs/user-guide/`:

| File | Title | Description |
|------|-------|-------------|
| `00-index.md` | User Guide Index | Welcome and navigation guide |
| `01-getting-started.md` | Getting Started | Account setup and first steps |
| `02-platform-features.md` | Platform Features | All major features by user type |
| `03-ai-trading.md` | AI Trading Guide | Create, test, and run AI strategies |
| `04-broker-setup.md` | Broker Setup | Connect brokerage accounts |
| `05-pattern-detection.md` | Pattern Detection | AI-powered pattern recognition |
| `06-portfolio-management.md` | Portfolio Management | Long-term portfolios with rebalancing |
| `07-social-sentiment.md` | Social & Sentiment | Social media and news monitoring |
| `08-economic-calendar.md` | Economic Calendar | Track market-moving events |
| `09-stock-hunter.md` | AI Stock Hunter | AI-powered stock research |
| `10-account-settings.md` | Account & Settings | Manage account, security, preferences |
| `11-faq.md` | FAQ | Quick answers to common questions |
| `12-all-seeing-eye.md` | All Seeing Eye | Central AI market monitoring |
| `13-candlestick-patterns.md` | Candlestick Patterns | Complete pattern reference |
| `14-algorithm-reference.md` | Algorithm Reference | Complete DSL for AI strategies |
| `15-trading-wizard.md` | Trading Wizard | Guided strategy setup |
| `16-making-trades.md` | Making Trades | Manual and automated execution |
| `17-broker-setup-detailed.md` | Broker Setup (Detailed) | Step-by-step for each broker |
| `18-ai-trader.md` | AI Trader Guide | End-to-end strategy lifecycle |
| `19-prediction-markets.md` | Prediction Markets | Use prediction data for insights |
| `20-watchlists.md` | Watchlists | Create and manage watchlists |
| `21-glossary.md` | Glossary | Trading and platform terminology |
| `22-troubleshooting.md` | Troubleshooting | Solutions to common issues |

**S3 Location:** `s3://predict-support-docs/support-docs/user-guide/`
**Total Size:** ~200 KB

---

## Support Documentation Corpus (99 files)

Located in `docs/` and S3 `support-docs/docs/`. Used by Support Chat for admin/support roles.

<details>
<summary>Click to expand full list</summary>

**Core Documentation:**
| File | Description |
|------|-------------|
| `01-product-overview.md` | Product overview and vision |
| `02-architecture.md` | System architecture |
| `03-database-schema.md` | Database schema reference |
| `04-api-specification.md` | API specification |
| `05-frontend-components.md` | Frontend component inventory |
| `06-build-phases.md` | Build phases and roadmap |
| `07-monetisation-strategy.md` | Pricing and monetization |
| `08-triggers-and-actions.md` | Triggers and actions system |
| `09-data-feed-pipeline.md` | Data feed pipeline |
| `10-infrastructure-deployment.md` | Infrastructure deployment |
| `11-security-overview.md` | Security design |
| `12-algorithm-builder.md` | AI Algorithm Builder |
| `13-broker-integration.md` | Broker integration layer |
| `14-bond-overlays.md` | Fixed income overlays |
| `15-claim-vs-reality-audit.md` | Feature audit |

**Trading & AI:**
| File | Description |
|------|-------------|
| `24-api-routes.md` | 430+ API endpoints |
| `32-algorithm-enhancements.md` | Algorithm improvements |
| `33-trading-workflow.md` | 6-stage trading workflow |
| `36-ai-trading-system-compliance.md` | AI trading compliance |
| `40-ai-trader-compliance-and-audit.md` | AI trader audit |
| `41-ai-api-keys-feature-matrix.md` | API key feature matrix |
| `42-ai-billing-credits-plan.md` | AI billing credits |
| `43-market-paradox-analysis.md` | Market paradox detection |
| `44-pattern-detection-and-ai-features.md` | Pattern detection |
| `46-ai-trader-management.md` | AI trader management |
| `50-derivatives-and-shorts.md` | Derivatives and shorts |
| `51-trading-wizards-graduation-tracker.md` | Graduation tracker |
| `52-ai-paper-trading-uat.md` | Paper trading UAT |

**Integrations:**
| File | Description |
|------|-------------|
| `26-integration-registry.md` | Integration registry |
| `36-bertha-integration.md` | Bertha auth integration |
| `38-silo-integration.md` | SILO AI security |
| `44-prediction-market-integration-guide.md` | Prediction markets |
| `48-social-follows-and-telegram.md` | Social intelligence |
| `55-pepperstone-broker-integration.md` | Pepperstone broker |
| `56-schwab-broker-integration.md` | Schwab broker |
| `57-economic-calendar-integration.md` | Economic calendar |

**Platform Features:**
| File | Description |
|------|-------------|
| `45-session-management.md` | Multi-session management |
| `47-portfolio-management.md` | Portfolio management |
| `53-user-offboarding.md` | User offboarding |
| `54-pattern-detection-system.md` | Pattern detection v2.0 |
| `58-pattern-hunter.md` | Pattern Hunter |
| `59-pattern-intelligence.md` | Pattern Intelligence |
| `60-support-chat-rag.md` | This document |

**Operations:**
| File | Description |
|------|-------------|
| `23-aws-deployment-tiers.md` | AWS deployment tiers |
| `29-cicd.md` | CI/CD pipeline |
| `35-system-administration.md` | System administration |
| `39-dataset-and-backtest-service.md` | Datasets and backtests |
| `DR-INFRASTRUCTURE.md` | Disaster recovery |
| `AWS_DEPLOYMENT.md` | AWS deployment guide |

**User Guides:**
| File | Description |
|------|-------------|
| `AI-TRADING-USER-GUIDE.md` | AI trading walkthrough |
| `BROKER-SETUP-GUIDE.md` | Broker setup guide |
| `PORTFOLIO-USER-GUIDE.md` | Portfolio user guide |
| `USER-ONBOARDING-GUIDE.md` | User onboarding |
| `FEATURE-GUIDE.md` | Feature guide |

</details>

**S3 Location:** `s3://predict-support-docs/support-docs/docs/`
**Total Files:** 99

---

## Future Enhancements

1. **Document Categories** - Organize docs by topic
2. **Search UI** - Search across all documents
3. ~~**Bulk Upload**~~ - ✅ Completed (bulk-ingest API endpoint)
4. ~~**User Guide RAG**~~ - ✅ Completed (user-guide scope + assistant integration)
5. **Auto-sync** - Automatically ingest docs from a git repo on push
6. **Analytics** - Track most-asked questions and gaps in documentation
7. **UI Bulk Ingest Button** - Add button in `/admin/support-docs` to trigger bulk ingest
8. **Scheduled Re-indexing** - Periodic re-embedding with latest models
