Privacy-first document assistant with zero-retention architecture. Documents are processed but never stored on servers. All persistent data lives in the user's browser (EntityDB). Backend is stateless.
Key points:
- No Redis — server stores nothing
- No raw IndexedDB — we use EntityDB instead
- EntityDB — IndexedDB under the hood + Transformers.js for embeddings and semantic search
Use this guide to get set up locally and ready to contribute.
Quick start (copy & paste):
git clone https://github.com/Resilient-Labs/multilingual-ai-document-assistant.git
cd multilingual-ai-document-assistant
npm install
npm run devThen open http://localhost:3000. No Redis or server storage required.
- Node.js 18.x or 20.x (nodejs.org)
- npm 9+ (comes with Node.js)
- Git (for cloning)
git clone https://github.com/Resilient-Labs/multilingual-ai-document-assistant.git
cd multilingual-ai-document-assistantnpm installWhat this installs:
| Package | What it does | Install notes |
|---|---|---|
next, react, react-dom |
Next.js app framework | Standard install |
@babycommando/entity-db |
In-browser vector DB (IndexedDB + Transformers.js under the hood) | May take 1–2 min; pulls WASM deps |
uuid |
Document ID generation | Standard install |
Step-by-step:
- Open a terminal in the project folder.
- Run
npm install. - Wait for it to finish (entity-db can take longer on first install).
- Confirm: you should see
added X packagesand no errors. - If it fails, try
npm cifor a clean install.
Installing a single package later:
npm install <package-name>If npm install fails:
- Run
npm cache clean --force, thennpm installagain. - Ensure Node.js 18+ is installed:
node -v. - On Windows, you may need to run the terminal as Administrator for native modules.
Optional. Copy .env.local.example to .env.local when you add OCR, LLM, or other API keys:
cp .env.local.example .env.localNo Redis or server storage is required. Add keys only when integrating external services.
npm run devOpen http://localhost:3000 in your browser.
- The app should load without errors.
- API routes are stateless — they process and return; no server storage.
Before you start contributing, confirm:
- Node.js 18+ installed (
node -v) - Repo cloned and
npm installcompleted -
npm run devruns and localhost:3000 loads - You know your team's area (see Team ownership below)
| Command | Description |
|---|---|
npm run dev |
Start development server (hot reload) |
npm run build |
Build for production |
npm run start |
Start production server |
npm run lint |
Run ESLint |
npm run format |
Check formatting with Prettier |
npm run typecheck |
Run TypeScript type checking |
This project uses ESLint, Prettier, and TypeScript. These checks run in CI.
npm run lint
npm run format
npx prettier --write . # Fix formatting
npm run typecheck| Issue | Solution |
|---|---|
| Port 3000 in use | Run npm run dev -- -p 3001 to use a different port |
| Build fails | Run npm ci for a clean install, then npm run build |
| EntityDB / Transformers.js errors | Check next.config.js has webpack aliases for onnxruntime-node and sharp |
npm install uuid
npm install github:babycommando/entity-db| Package | Purpose | Install source |
|---|---|---|
@babycommando/entity-db |
In-browser vector DB for chunks, embeddings, semantic search | GitHub |
uuid |
Document ID generation (doc_${uuidv4()}) |
npm |
EntityDB stores all data in the browser. Use lib/entitydb.ts:
import { insertChunk, queryChunks } from "@/lib/entitydb";
await insertChunk("Document text here", { docId: "doc_123", chunkId: "c1" });
const results = await queryChunks("search query", { limit: 5 });User Browser
│
├── EntityDB (IndexedDB + Transformers.js)
│ Entities: Document, OCRBlock, Chunk, Embedding, Summary, ChatSession, ChatMessage, RiskFlag, Language
│
└── API requests
│
▼
Stateless Backend (OCR, LLM, embeddings, translation, risk classification)
Server never stores documents. Everything persistent lives in EntityDB in the browser.
Document (root)
├── OCRBlock → FieldCandidate
├── Chunk → Embedding
├── Summary
├── RiskFlag
├── Language
└── ChatSession → ChatMessage
See types/index.ts for full definitions.
| Team | Area | Files / endpoints | What to build |
|---|---|---|---|
| Team 1 | Upload & OCR | app/api/documents/upload, app/api/documents/extract |
File upload, OCR pipeline. Return JSON. Client stores in EntityDB. |
| Team 2 | Summarization | app/api/summarize |
Receive fullText, return summary via LLM. Stateless. |
| Team 3 | RAG & embeddings | app/api/ask, lib/entitydb.ts |
Chunking, embeddings in EntityDB, RAG. Client sends context; backend returns answer. |
| Team 4 | Multilingual | (to be added) | Speech-to-text, translation, multilingual responses. |
| Team 5 | Safety detection | app/api/safety |
Receive text/blocks, return risk flags. Stateless. |
Shared resources:
types/— Entity definitions (Document, OCRBlock, Chunk, etc.)lib/entitydb.ts— EntityDB client for chunks and semantic searchlib/constants.ts— File limits, allowed MIME typeslib/documentId.ts— Document ID generation
app/
api/
documents/upload # Stateless: OCR, return JSON
documents/extract # Stateless: OCR, return JSON
ask # Stateless: RAG (client sends context)
summarize # Stateless: summary (client sends fullText)
safety # Stateless: risk flags (client sends text)
components/ # Shared React components
lib/ # entitydb, constants, documentId
types/ # Entity definitions
All endpoints are stateless. Client sends data; backend processes and returns. No server storage.
| Endpoint | Method | Body | Description |
|---|---|---|---|
/api/documents/upload |
POST | FormData (file) |
OCR, return docId + OCR JSON |
/api/documents/extract |
POST | FormData (file) |
OCR, return OCR JSON |
/api/ask |
POST | { question, context? } or { question, chunks? } |
RAG answer |
/api/summarize |
POST | { fullText } |
Summary |
/api/safety |
POST | { fullText?, blocks? } |
Risk flags |
- PDF / Images: ≤ 4.5 MB (client upload limit)
Documents are processed but never stored on servers. All data stays in the user's browser.