# Knowledge RAG — Node.js application

This folder specifies a **complete Node.js RAG (Retrieval-Augmented Generation)** service that answers questions from the existing `html/` knowledge base using **OpenAI GPT-4o-mini** (`gpt-4o-mini`).

The source corpus is **not a generic web scrape**. It is actuarial / simplified-issue (SI) life and mortgage-protection underwriting knowledge:

- Narrative HTML (BMI chart, 12 disease modules, mortgage process, mortgage dataset).
- Structured JSON interview trees, product Decline/PASS stats, BMI tables, products, and companies.

RAG exists so operators can ask natural-language questions (“What typically happens for cancer treated 3 years ago on mortgage SI?”) and receive answers **grounded in this corpus**, with citations, instead of relying on the model’s general knowledge.

**Status of this folder:** design and implementation specification. Application source code lives under `src/` once built (see [project-structure.md](./project-structure.md)).

## Documents

| Doc | Purpose |
|-----|---------|
| [architecture.md](./architecture.md) | System design, components, trust boundaries |
| [learning-model.md](./learning-model.md) | **What learns, what does not, and exact save paths** (`data/lancedb/`, `data/learning/`) |
| [vertical-learning-data.md](./vertical-learning-data.md) | **Separate reusable stores: health, BMI, mortgage** |
| [knowledge-communication-rag.md](./knowledge-communication-rag.md) | Agent playbook vectors in `data/knowledge/` (does not change `data/verticals/`) |
| [project-structure.md](./project-structure.md) | Full Node.js repository layout |
| [data-sources.md](./data-sources.md) | How each `html/` file becomes chunks |
| [rag-pipeline.md](./rag-pipeline.md) | Ingest → embed → retrieve → generate |
| [api.md](./api.md) | HTTP API, env vars, example requests |
| [implementation-plan.md](./implementation-plan.md) | Phased build order |

## Non-goals (v1)

- Binding carrier underwriting or quotes.
- Replacing licensed-agent process.
- Fine-tuning GPT-4o-mini.
- Multi-tenant auth (optional later).

Answers must always include a disclaimer that this is **illustrative industry synthesis**, not a filed carrier ruleset.
