← Back to Projects
FileQuery

FileQuery

A document question-answering tool using production-ready RAG to give accurate, hallucination-free answers grounded strictly in your uploaded files.

A full-stack document search and Q&A platform that lets users upload documents into project folders and ask questions answered strictly from their files using Retrieval-Augmented Generation (RAG). It extracts text, breaks documents into smart sections, uses hybrid keyword and semantic search, and produces accurate AI answers with source citations.

Next.jsTypeScriptTailwind CSSFastAPIPython 3.14SQLAlchemy 2.0PostgreSQLpgvectorLangChainAWS S3AWS SQSAWS LambdaAmazon Titan Text Embeddings V2Amazon Nova MicroGoogle Cloud Run

Core Problem Solved

General AI models like ChatGPT often make up answers or cannot read private business files. FileQuery solves this by letting users upload private documents, indexing them with vector search, and forcing the AI to answer solely based on the uploaded content.

Why I Built This

Engineered to demonstrate a real-world, cloud-native RAG pipeline that handles asynchronous file ingestion, vector search in PostgreSQL, and dependable AI answer generation.

Features

  • •Project Knowledge Bases: Group documents into distinct project workspaces so queries only search the relevant files.
  • •Multi-Format Ingestion: Upload and extract content from PDF, DOC, DOCX, CSV, Markdown, and TXT files.
  • •Smart Document Chunking: Uses LangChain to split text naturally while keeping headings and tables intact.
  • •Hybrid Semantic & Keyword Search: Combines keyword search with pgvector embeddings to find the most relevant document sections.
  • •Query Rewriting: Automatically turns follow-up questions (such as 'What about the second option?') into clear search queries.
  • •Grounded AI Answers: Powered by Amazon Nova Micro, trained to only answer using retrieved text and avoid hallucinations.
  • •Background File Processing: Uploaded files are processed asynchronously using AWS SQS and Lambda so the web app never freezes.
  • •Source Citations: Each answer highlights the exact document snippets used, allowing users to verify facts quickly.

Architecture

Frontend: • Next.js with TypeScript and Tailwind CSS for a fast, modern user experience. • Server Actions and secure HTTP-only cookies for authenticated API communication. Backend & Vector Search: • Python 3.14 with FastAPI providing fast, documented RESTful endpoints. • PostgreSQL database with the pgvector extension for high-speed semantic similarity searches. • SQLAlchemy 2.0 ORM for robust database querying. Cloud & Async Pipeline: • Files are uploaded securely to Amazon S3. • An Amazon SQS queue triggers an AWS Lambda worker to extract text, create chunks via LangChain, and generate vector embeddings with Amazon Titan Text Embeddings V2. • When a user asks a question, FastAPI rewrites the prompt, retrieves the best matching chunks with pgvector, and calls Amazon Nova Micro to generate the answer. Hosted on Google Cloud Run.

Database Modelling

Schema for FileQuery

Challenges

  • •Finding the Optimal Chunking Strategy: Splitting text into pieces that are too small loses context, while chunks that are too large dilute search accuracy. Evaluated different chunk sizes and overlaps using LangChain's recursive markdown splitter to preserve document headers and table structures.
  • •Tuning RAG Retrieval Quality: Basic vector search sometimes missed specific terms or returned weak matches. Improved accuracy by adding conversational query rewriting, hybrid search (combining exact keyword matching with vector similarity), and similarity score filtering across diverse test question sets.

Tradeoffs and Decisions

Chose Amazon Titan Embeddings and Amazon Nova Micro over OpenAI to keep running costs minimal while remaining inside the AWS ecosystem alongside S3 and SQS. Used fully managed AWS SQS and Lambda for background processing instead of running a self-hosted Celery/Redis cluster; this added minor cold-start latency but removed all server maintenance and operational overhead.

Impact

Successfully delivers fast, accurate document Q&A across multi-page technical manuals and reports with zero hallucinations. I regularly uses it as a personal tool to search complex developer documentation.