← Back to main spec FUTURE SCOPE

Organization Context Enrichment

This feature is out of scope for the current Workerline Enhancements sprint. It is documented here as a standalone specification for future implementation.

Overview

Allow organizations to upload documents (PDFs, text files, policy manuals) that are automatically processed and injected as context into AI conversations for that organization's sessions. This enriches the AI's responses with org-specific knowledge — company policies, vessel procedures, benefit details, etc.

How It Works

Org Instructions (Existing)

The survey_instructions table already exists in the schema. Enhancement: improved dashboard UI with template suggestions and preview of how instructions affect AI behavior.

Org-Specific Documents (New)

Upload PDFs/text files → extract text → store → concatenate into the AI system prompt for that org's sessions (simple text injection, not semantic retrieval).

sequenceDiagram participant Admin as 🖥️ Admin participant API as ⚡ scb-api participant DB as 💾 SQLite Admin->>API: Upload PDF API->>API: Extract + chunk text API->>DB: Store org_document Note over API,DB: During conversations... participant W as 🚢 Worker participant OAI as 🤖 OpenAI W->>API: Chat message API->>DB: Load org_documents API->>API: Build prompt + doc excerpts API->>OAI: Chat completion (with context) OAI-->>W: Streaming response

Data Model

erDiagram orgs ||--o{ org_documents : has org_documents { text id PK text org_id FK text name text file_type text extracted_text text created_at }

API Routes

MethodRouteAuthDescription
POST/org/:id/documentsAdminUpload org document (PDF/text)
GET/org/:id/documentsAdminList org documents
DELETE/org/:id/documents/:docIdAdminDelete org document

Implementation Notes

Future enhancement: If document volume grows, consider vector embeddings + similarity search (RAG) for more precise context injection. For now, simple text concatenation is sufficient.

Foundation Analysis — What Already Exists

This feature has a small footprint because it builds almost entirely on existing infrastructure:

Key insight: This is primarily a data-pipeline + dashboard-UI task. No new external services, no new infrastructure patterns. The heaviest lift is the text extraction and the dashboard upload interface.

Estimated Cost

Organization Context Enrichment

$2,200

2–3 days · agentic coding workflow · builds entirely on existing infrastructure

Pricing note: This estimate assumes the same AI-driven development workflow used in the base sprint ($13,200 for 7 features / 2–3 weeks). Context Enrichment is a small, well-bounded task — 3 API routes, 1 table, PDF text extraction, and a basic dashboard upload UI. No new external services or infrastructure patterns.

What's Included

DeliverableDetails
Document upload APIPOST/GET/DELETE routes with org-scoped access. PDF + plain text support.
Text extraction pipelineAutomatic text extraction on upload via pdf-parse. Chunking to stay within prompt limits (~8K chars per org).
AI context injectionOrg documents concatenated into the GPT-4 system prompt during worker conversations. Full text injected up to the ~8K character limit per org — no topic-based filtering in MVP (simple concatenation, not semantic search).
Dashboard UIUpload widget, document list with preview of extracted text, delete confirmation. Integrated into existing org settings page.
Improved instructions UIBetter editing experience for existing survey_instructions with template suggestions.

Ongoing Costs