Landing Page: Showcases the collaborative research vault features, landing details, and system entry points.
Overview
Research Citadel is a collaborative research platform where teams create shared vaults, upload papers and web articles, write annotations together in real time, and ask AI questions grounded in their uploaded sources. It features a full RAG pipeline for document Q&A, AI-powered summarization and insight extraction, real-time chat with slash-command directives, role-based access control, contribution analytics, and an immutable audit log.
AI Document Intelligence
RAG-based Q&A — documents are chunked, scored via TF-IDF cosine similarity, and top-K chunks become grounded LLM context
AI-powered document summarization with configurable length (short, medium, detailed) and chunked processing for large documents
Structured insight extraction — methodology, key findings, limitations, and future work parsed into structured JSON from uploaded papers
Real-time Collaboration
Socket.IO WebSocket gateway with vault-scoped rooms — source changes, annotation edits, and chat messages broadcast instantly
Annotation presence tracking — see who is currently editing which annotation with live draft content broadcasting
Team chat with reply threading, slash-command directives (/sources, /members, /admin, /clear), and message timestamps
Vault & Access Control
RBAC membership system — Owner, Contributor, and Viewer roles with vault-level permission enforcement
Immutable audit log tracking every action (source added, annotation edited, member role changed) with IP and user agent metadata
Source management with multi-type support (PDF, web article, dataset, video, book) and per-source Q&A readiness tracking
Auth & Security
JWT dual-token auth with access/refresh rotation, OTP email verification, and Google OAuth
Rate limiting per action type (OTP sends, file uploads, source creation) with configurable windows
Annotation and file locking with auto-expiry to prevent concurrent edit conflicts
On the roadmap
Agentic web scraper for external link sources — crawl URLs, extract structured content, and feed it into the RAG pipeline so users can query web articles the same way they query uploaded PDFs
Collaborative research paper editor — a real-time, multi-user writing interface where teams can draft papers directly from their vault findings, annotations, and AI-generated insights
Cross-paper contradiction detection — compare claims across uploaded sources to surface conflicting findings, methodology gaps, and areas where the literature disagrees
The thought process
The hardest design problem was the AI Q&A pipeline. I needed answers grounded strictly in the user's uploaded sources — not general knowledge. I built a RAG pipeline where uploaded PDFs get text-extracted, chunked at sentence boundaries with overlap, and scored against the user's question using TF-IDF cosine similarity. The top-K chunks become the LLM context, and the response cites exactly which sources and chunks were used. The constraint that forced good design: users can scope Q&A to specific sources, so retrieval had to be vault-aware and source-filterable from the start.
Tech stack & why
NestJS
Modular architecture mapped naturally to domain boundaries — modules (Auth, Vault, Source, Annotation, AI, Collaboration, etc.) with dependency injection keeping them decoupled.
Next.js
App Router with route groups and layouts for the dashboard. TanStack Query for server state, Zustand for client state, Framer Motion for transitions.
PostgreSQL
Relational store via Prisma ORM. Normalized schema with UUID primary keys, JSONB for AI-extracted metadata and embedding vectors, and indexed audit logs.
Redis + BullMQ
Background job processing for document text extraction, AI summarization, and embedding generation — keeping API responses fast while heavy AI work runs asynchronously.
Socket.IO
NestJS WebSocket gateway with vault-scoped rooms for real-time source updates, annotation presence tracking, live draft broadcasting, and team chat.
Cloudflare R2
Document and file uploads (PDFs, papers) stored in R2 object storage with S3-compatible API, signed URLs, and content-type validation.
Cloudinary
Image uploads — user avatars and vault media — with on-the-fly transformation and CDN delivery.
Major updates
Jun 2026
AI Q&A engine
Full RAG pipeline — PDF text extraction, overlapping chunk generation, TF-IDF cosine retrieval, source-scoped grounded answers with chunk citations.
May 2026
Real-time collaboration
Socket.IO gateway with vault rooms, annotation presence/editing indicators, live draft broadcasting, and push notifications for vault invitations.
Apr 2026
AI summarization & insights
Document summarization with chunked processing for large papers. Structured insight extraction parsing methodology, findings, and limitations into JSON.
Mar 2026
Source & annotation system
Multi-type source management with R2 file uploads and Cloudinary image handling. Markdown annotations with page/section references, versioning, and edit locking.
Feb 2026
Vault RBAC & audit logs
Vault creation with Owner/Contributor/Viewer roles. Immutable audit log for all vault actions with entity tracking and IP metadata.
Jan 2026
Auth & project setup
JWT dual-token flow with OTP email verification, Google OAuth, bcrypt hashing. NestJS modular architecture with Prisma and Docker Compose.
What I actually learned
RAG quality depends more on chunking strategy than model choice — breaking at sentence boundaries with overlap dramatically improved retrieval accuracy over naive fixed-size splits
WebSocket auth is its own problem. The NestJS gateway needed a custom WsJwtGuard that validates tokens on every event, not just at connection time, because tokens can expire mid-session
Prisma migrations at scale require discipline — the schema grew to 16 models and keeping migrations clean meant never editing a deployed migration, only creating new ones
Background job queues changed the architecture. Moving AI processing to BullMQ workers meant the API could return instantly while heavy inference ran asynchronously — the UX improvement was immediate
What I'd do differently
Vector search
The embedding service generates and stores vectors but Q&A still uses TF-IDF for retrieval. Switching to cosine similarity over stored embeddings would improve recall on semantic queries.
Source relationships
The schema supports source relationships (cites, contradicts, supports, extends) but the UI for mapping these connections is not built yet.
Citation export
The citation module generates formatted references (APA, MLA, IEEE, etc.) but there is no bulk export or clipboard integration in the frontend.
Annotation conflicts
Edit locking prevents concurrent writes but there is no merge strategy. A CRDT-based approach would allow true concurrent collaborative editing.
Key takeaways
01
Build the RAG pipeline before the chat interface. Grounding quality is the product — a beautiful Q&A UI over bad retrieval is worse than useless.
02
Modular backends pay for themselves. Adding the AI module months into the project required zero changes to Auth, Vault, or Source — NestJS dependency injection made it a clean plug-in.
03
Audit logs are not optional. Once you have them, debugging production issues goes from guesswork to replaying the exact sequence of events.