AI Document Chat
A chat interface that answers questions about your own documents. Upload a file and it's indexed automatically; the system retrieves the relevant passages and answers using only what's actually in your documents, citing the source alongside each answer.
Architecture
Problem
Documentation is easy to write and hard to search. Files sit in a folder or a bucket, and finding the answer to a specific question means opening several of them and skimming — assuming you remember which one it's in.
Solution
Upload a document and it's automatically indexed: Amazon Bedrock Knowledge Bases chunks it, generates embeddings with Titan Embed Text v2, and writes them into a Postgres vector store. Ask a question in the chat UI and Bedrock retrieves the most relevant chunks and answers with Claude Haiku 4.5 — grounded in what's actually in the documents, with the source file cited alongside the answer.
Automatic re-indexing
Uploading or deleting a file fires an EventBridge rule that triggers re-indexing automatically, so the index stays in sync with the documents without a manual step.
Choosing the vector store
Bedrock Knowledge Bases can use several vector stores. The default most tutorials reach for, OpenSearch Serverless, has a billing floor of roughly $700/month regardless of use. This project uses Aurora Serverless v2 with the pgvector extension instead, which scales down and auto-pauses when idle — the same workload runs for roughly $5–15/month.
Infrastructure
The data store, knowledge base, ingestion pipeline, query API and web front end are each defined as code with AWS CDK, so the whole system deploys reproducibly with a single command rather than being assembled by hand in the console.
Grounded answers, not guesses
The chat answers only from what's in the uploaded documents rather than the model's general knowledge, and every answer comes back with a citation pointing at the source file it was drawn from.