<aside> 👉🏻
Executive Summary
This project focuses on designing a Retrieval-Augmented Generation (RAG) system that serves as the knowledge backbone for my personal AI assistant. Rather than assuming retrieval is correct by default, the system treats retrieved context as a fallible hypothesis that must be evaluated, constrained, and sometimes retried. It covers the full RAG lifecycle—from ingestion and embedding to retrieval, context assembly, and citation—prioritizing quality, traceability, and determinism over raw recall. Auto-RAG mechanisms such as weak-retrieval detection, query rewriting, and fallback strategies are used to reduce confidently incorrect answers. The project reframes RAG as a system design and safety problem, ensuring that only reliable, explainable context reaches downstream generation.
</aside>
Type: 🧭 Personal Learning & Demo (Non-Commercial)
Context: A core knowledge subsystem powering my personal AI Chat Assistant on jackhpark.com
Focus: How knowledge is ingested, structured, retrieved, and validated before it reaches an LLM
As large language models become more capable, a recurring failure mode becomes more visible:
answers that sound confident, fluent, and wrong.
This project focuses on the part of the system that most directly influences that outcome—the Retrieval-Augmented Generation (RAG) layer.
Rather than optimizing prompts or chat experiences, I intentionally stepped one layer earlier in the stack to explore:
The goal of this project is not to retrieve more information, but to retrieve better, safer context for downstream generation.
This system is structured around two decoupled architectural paths: a triggered-pull ingestion path that refreshes the knowledge base on a daily schedule and after a portfolio page is published, and a self-correcting retrieval path that decides what evidence is strong enough to send downstream to generation. On the ingestion side, content from Notion pages and external URLs is normalized, checked for meaningful change, and refreshed without duplicating or mixing old and new chunks. On the retrieval side, the system treats first-pass search as a hypothesis rather than a fact, using bounded recovery mechanisms when initial results look weak instead of assuming semantic search is always trustworthy. The chat runtime adds a separate reliability boundary around that retrieval flow, isolating lightweight request handling from heavier retrieval and model-execution work so the system behaves more predictably in a serverless environment. LangChain is used selectively where it provides architectural structure — especially around retrieval orchestration, provider abstraction, and vector-store integration — while guardrails, caching, and most operational logic remain outside that layer. The result is not just a search component in front of an LLM, but a context-quality pipeline designed for grounding, traceability, and controlled failure handling.
The ingestion pipeline follows a deliberate triggered-pull model: an admin action or CLI run can fetch Notion content, a daily scheduled run refreshes the corpus, and a targeted refresh fetches the edited page immediately after a portfolio publish. External URLs use their own fetch adapter before entering the shared change-detection and embedding path. Unchanged content is skipped, metadata-only changes avoid re-embedding, and changed content is chunked and refreshed together. This trades immediate visibility for bounded freshness, lower embedding cost, and updates that are easier to reason about.
flowchart TD
subgraph T["Notion refresh triggers"]
A["Admin UI / CLI"]
D["Daily scheduled run"]
P["Publish-coupled page refresh"]
end
subgraph S["Sources"]
N["Notion pages"]
U["External URLs"]
end
A --> N
D --> N
P --> N
X["Explicit URL ingestion"] --> U
subgraph E["Fetch and normalize"]
NX["Notion to plain text"]
UX["URL to article text"]
Z["Normalize text"]
end
N --> NX --> Z
U --> UX --> Z
Z --> H["Compare content hash and metadata"]
H --> Q{"What changed?"}
Q -->|"Nothing"| R1["Record ingestion run"]
Q -->|"Metadata only"| R2["Update document metadata"]
Q -->|"Content"| K["Chunk with overlap"]
K --> ES["Choose embedding space"] --> EM["Embed and replace changed chunks"]
EM --> R3["Supabase: pgvector chunks"]
EM --> R2
R2 --> R1
R3 --> R1