Skip to content
Stephan.

03Academic

Document.ai

Smart Knowledge Assistant (RAG MVP)

Firebase-authenticated document Q&A: upload PDFs/DOCX, async chunking and embedding into Pinecone, then grounded answers with cited source chunks in a Next.js chat UI.

Company
Capstone / product-style MVP
Role
Full-Stack + LLM integration
Duration
Multi-month build
Category
Full-Stack
012400×1000

/images/work/document-ai/cover.webp

Full-bleed project cover. Wide editorial crop of the interface or its subject matter.

01Impact

By the numbers.

RAG

Retrieval + LLM

Δ

Per-user vectors

Async

Ingest states

UI

Sources panel

02Overview

The brief.

Split repo: document.ai-backend (FastAPI, SQLAlchemy, PostgreSQL, Firebase Admin) and document.ai-frontend (Next.js 19, Tailwind 4, Firebase client). Users obtain an ID token and call the API with Bearer auth; ingestion runs in the background with status tracked per document.

Problem

Teams need answers from their own files without hallucinated references — retrieval-grounded responses with visible citations.

Solution

Ingest pipeline extracts text, chunks content, embeds with OpenAI, upserts to Pinecone with user-scoped metadata, then RAG: embed question, filtered vector search, assemble context, generate answer plus AskResponse sources.

03Features

What it does.

01

Secure auth flow

Firebase register/login on the client; backend verifies ID tokens on protected routes.

  • Firebase Auth
  • Bearer tokens
02

Upload & ingest

POST /upload-doc persists metadata and kicks off background extraction, chunking, and Pinecone upsert.

  • FastAPI
  • Background tasks
  • OpenAI embeddings
03

Grounded Q&A

POST /ask-question runs scoped vector search and returns answers with retrieved chunk citations.

  • Pinecone
  • OpenAI chat
04

Operator visibility

Document list, processing status, and optional themes in the Next.js app; query logging in PostgreSQL.

  • Next.js
  • QueryLog
  • DocumentMetadata

04Architecture

How it's built.

frontend

  • Next.js (app/)
  • React 19
  • Tailwind 4
  • Firebase client
  • Themes

backend

  • FastAPI
  • SQLAlchemy
  • PostgreSQL
  • Firebase Admin SDK

retrieval

  • OpenAI embeddings
  • Pinecone
  • User/document metadata filters

ops / dev

  • .env.example parity
  • CORS for early dev
  • Health check endpoint

05Challenges

What was hard.

01

Tenant-safe retrieval

Namespace chunks with user_id (and optional document filter) so Pinecone queries never cross tenants.

02

Transparent answers

Return source chunks alongside the model reply so the UI can show citations and rebuild trust.

06Gallery

A closer look.

021600×1200

/images/work/document-ai/01.webp

Interface detail. Crop tight on one screen or one interaction — not a full-page screenshot shrunk down.

031600×1200

/images/work/document-ai/02.webp

Interface detail. Crop tight on one screen or one interaction — not a full-page screenshot shrunk down.

041600×1200

/images/work/document-ai/03.webp

Interface detail. Crop tight on one screen or one interaction — not a full-page screenshot shrunk down.

051600×1200

/images/work/document-ai/04.webp

Interface detail. Crop tight on one screen or one interaction — not a full-page screenshot shrunk down.

07Stack

Built with.

  • Next.js
  • React
  • Tailwind CSS
  • FastAPI
  • PostgreSQL
  • Firebase
  • Pinecone
  • OpenAI

Outcomes

  • End-to-end MVP from sign-in to cited answers over private documents
  • Observable ingest lifecycle (uploaded → processing → indexed / failed)
  • Clear split between chat UX and API/AI pipeline for iteration