Istifsar AI
A history exploration platform powered by custom-built GraphRAG where every AI answer is grounded in verified scholarly sources.
The home and landing page of Istifsar AI, displaying the platform's core value proposition of history-grounded answers.
Project Overview
Istifsar AI is a history exploration platform powered by GraphRAG that grounds every AI response in verified scholarly sources. Built on the strict design constraint 'No Document, No History,' the system prevents AI hallucinations by gating similarity scores, traversing document relationship graphs directly in PostgreSQL, and logging unresolved historical inquiries to a public registry.
Role
Full-Stack Developer
- Full-Stack Developer
Tech Stack
Backend & Architecture
- Custom GraphRAG pipeline using PostgreSQL Recursive CTEs in Supabase, eliminating external graph DB dependencies.
- Hybrid search engine combining semantic cosine similarity (pgvector) and Full-Text Search (FTS) ranked via Reciprocal Rank Fusion (RRF).
- Ingestion pipeline with semantic document chunking, Gemini embedding generation, entity-relationship extraction, and contention checking.
- Robust Row-Level Security (RLS) policies enforcing role-based permissions (Reader, Verified Historian, Admin) via JWT claims.
- Serverless rate limiting and request caching powered by Upstash Redis to prevent API abuse.
Frontend & UX
- Split-pane viewer showing live streaming chat side-by-side with original source PDF/scan document view and auto-scroll alignment.
- Interactive React Flow (XYFlow) node mapping to visualize conflicting scholarly arguments and claims.
- Immersive 3D node-network hero animation powered by Three.js and React Three Fiber to visualize the archival knowledge graph.
- Public Archive Gaps dashboard allowing users to log, view, and upvote historical queries that the AI has no source material to answer.
App Architecture Diagram

Custom-built RAG Architecture Diagram

Challenges & Technical Solutions
Designing a nested, hierarchical URL routing model (/documents/[tagSlug]/[id]) for documents belonging to multiple categories, risking duplicate canonical paths.
Established a deterministic routing architecture using a primary_tag flag in database metadata for canonical URL construction, while using a many-to-many join table for secondary category queries.
Decoupling AI-generated RAG citations from routing frameworks to prevent broken links during directory structure refactors (e.g., flat to hierarchical paths).
Shifted URL construction entirely to the client-side UI by prompting the LLM to output abstract source tokens and injecting document metadata dynamically in the chat stream.
Strictly preventing the LLM from hallucinating answers based on general training data instead of the uploaded historical archives.
Enforced 'The Agoncillo Constraint' via a hard 0.65 similarity threshold on retrieved chunks; queries falling below this are blocked from generation, logged as gaps, and returned as a standard denial.
Querying multi-hop document relationships in a custom GraphRAG pipeline without the infrastructure overhead of a dedicated graph database.
Built the graph structure directly within PostgreSQL (Supabase) and utilized recursive Common Table Expressions (CTEs) to perform low-latency relational traversals during retrieval.
Managing and presenting contradictory assertions between historical scholarly sources without introducing AI bias.
Created an ingestion-time contradiction classifier using Gemini Flash to flag conflicts and render them as custom interactive nodes in a React Flow contention graph.