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 publishing unresolved historical inquiries to an interactive community forum on the Explore page.
Role
Full-Stack Developer
- AI Integration Specialist
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).
- Modular Edge Function ingestion pipeline with recursive character chunking, Gemini embedding generation, and per-chunk knowledge graph entity extraction.
- 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.
- Integrated an asynchronous MLOps Evaluation Hub via Upstash QStash to grade AI responses on faithfulness and relevancy without blocking the Next.js frontend.
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.
- Interactive Explore community board allowing users to post, view, upvote, and discuss historical inquiries that the AI lacks 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 dynamic dual similarity thresholds (0.80 global / 0.75 scoped) and RRF noise filtering. Queries falling below this are blocked from generation and instead converted into active community discussions on the Explore page.
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.