The Archive is a RAG-powered (Retrieval-Augmented Generation) document analysis platform. Upload PDFs, DOCX, or TXT files and chat with them using AI. The system extracts and chunks your documents, generates embeddings, and answers questions by citing only what's in your files — no hallucination.
- Upload PDF, DOCX, and TXT files via drag-and-drop
- AI-powered Q&A chat grounded in your uploaded documents
- Auto-generates a TL;DR (executive summary) on upload
- Citation tracking — every AI answer references its source document
- Document library with search and filtering
- In-browser PDF preview modal
- Brutalist UI design with dark mode support
| Layer | Technology |
|---|---|
| Framework | Next.js 15 (App Router) + React 19 + TypeScript |
| Styling | Tailwind CSS + Radix UI (headless) + shadcn/ui |
| AI Models | OpenAI gpt-4o-mini (chat) + text-embedding-3-small (embeddings) |
| AI SDK | Vercel AI SDK v6 (generateText, embed) |
| AI Flows | Google Genkit 1.16 |
| File Parsing | pdf-parse for PDF text extraction |
| Forms | React Hook Form + Zod |
| File Upload | React Dropzone |
| Deployment | Firebase App Hosting |
the-archive-ai/
├── src/
│ ├── app/
│ │ ├── page.tsx # Landing page
│ │ ├── layout.tsx # Root layout & metadata
│ │ ├── globals.css # Global styles & CSS variables
│ │ ├── dashboard/
│ │ │ ├── layout.tsx # Dashboard shell with sidebar
│ │ │ ├── page.tsx # Overview / stats
│ │ │ ├── chat/page.tsx # Chat interface
│ │ │ ├── documents/page.tsx # Document library & upload
│ │ │ └── settings/page.tsx # Settings
│ │ └── api/
│ │ └── extract-text/route.ts # PDF/text extraction API route
│ ├── ai/
│ │ ├── genkit.ts # OpenAI client config
│ │ ├── dev.ts # Genkit dev server entry
│ │ └── flows/
│ │ ├── rag-query-response-generation.ts # RAG chat flow
│ │ └── document-embedding-processing.ts # Chunking & embedding flow
│ ├── components/
│ │ ├── chat/chat-window.tsx # Main chat UI
│ │ ├── documents/
│ │ │ ├── upload-zone.tsx # Drag-and-drop uploader
│ │ │ └── document-list.tsx # Document library list
│ │ ├── layout/ # Header & footer
│ │ └── ui/ # Radix-based UI primitives (37 components)
│ ├── hooks/ # use-mobile, use-toast
│ └── lib/
│ ├── types.ts # Shared TypeScript interfaces
│ └── utils.ts # cn() and other helpers
├── .env # Environment variables (see below)
├── next.config.ts
├── tailwind.config.ts
├── apphosting.yaml # Firebase App Hosting config
└── package.json
- Upload — file is sent to
/api/extract-text, which usespdf-parseto extract raw text - Chunk —
document-embedding-processing.tssplits text into ~1000-char segments at paragraph/sentence boundaries - Embed — each chunk is embedded with
text-embedding-3-small - Query — user message is embedded and matched against stored chunk embeddings (cosine similarity)
- Generate — top matching chunks are passed as context to
gpt-4o-minivia the RAG flow, which is instructed to answer only from the provided documents
- Node.js 18+
- An OpenAI API key
git clone <repo-url>
cd the-archive-ai
npm installCreate a .env file in the project root:
OPENAI_API_KEY=your_openai_api_key_herenpm run devThe app runs at http://localhost:9002
npm run genkit:devThis starts the Genkit developer UI for inspecting and testing AI flows locally.
| Script | Description |
|---|---|
npm run dev |
Start Next.js dev server on port 9002 (Turbopack) |
npm run build |
Production build |
npm start |
Start production server |
npm run lint |
Run ESLint |
npm run typecheck |
TypeScript type check (no emit) |
npm run genkit:dev |
Start Genkit AI dev UI |
npm run genkit:watch |
Genkit dev UI in watch mode |
| Variable | Required | Description |
|---|---|---|
OPENAI_API_KEY |
Yes | OpenAI API key used for GPT-4o-mini and text embeddings |
The project is configured for Firebase App Hosting via apphosting.yaml.
npm run build
# then deploy via Firebase CLI or push to connected repoMIT License
Copyright (c) 2026 Saw Simon Linn
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.