Skip to content

Raghavsk24/Citation-Chain

Repository files navigation

Citation Chain

Interactive Citation Graph that maps existing literature in your research domain, generates in-depth summaries for your papers and deploys an AI Assistant (Claude Sonnet 4.6) that uses retrieval-augmented generation to answer your questions.

Landing search screen Citation graph view
Paper node dialog with in-depth summary AI chat assistant panel

Live App: https://citation-chain-two.vercel.app/

Tech Stack

Frontend

Next.js TypeScript Tailwind CSS shadcn/ui React Flow

Backend

Claude Vercel AI SDK OpenAlex Semantic Scholar Supabase Supermemory

Infrastructure

Vercel Bun

Citation Chain Architecture

1. Research Paper Extraction

The user can submit the research paper either by uploading it as a PDF or searching for its DOI/title using the search bar. For PDFs, the client extracts the title and DOI from the first page using unpdf, then sends a query to the OpenAlex API. We use OpenAlex because it has a higher rate limit (100 requests per second) compared to the Semantic Scholar API which has a rate limit of 100 requests per 5 minutes. However, Semantic Scholar offers a more complete and robust dataset, while OpenAlex usually has some missing metadata for a given research paper.

To compensate this we query OpenAlex to see if it has the research paper with all the standard metadata. If OpenAlex has the research paper but is missing some metadata (e.g. author name, DOI, abstract, key fields), we batch all the missing metadata in one query and send a request to Semantic Scholar. If the research paper cannot be found on OpenAlex or both APIs are missing critical metadata, we return an error to the user informing them we are unable to find their research paper.

Note: Research papers that are published after 2025 usually aren't included in either APIs, so unless the user uploads a PDF as input, a citation graph cannot be generated.

2. Citation Graph Layout

We use React Flow to generate the citation graph. The uploaded research paper is the central node and all the outbound citations branch off from it. The appearance of each node is dependent on three variables.

  1. Number of outbound citation: The size of the node is dependent on the number of outbound citations it has. A node with 100 citations is ~50x larger than a node with only 2 citations.
  2. Color of the node: The color of the node depends on the field the research paper falls under. OpenAlex lists 26 fields and 4 domains. Each field is assigned a unique color which you can view in the table below, and fields in the same domain have a similar color.
  3. Shade of the node: The shade of the node depends on the date it was published. Papers that were published closer to the present are shaded darker, while papers published a long time ago appear visually more tinted.
Domain Hex Color
Life Sciences
Agricultural and Biological Sciences#16A34AGrass Green
Biochemistry, Genetics and Molecular Biology#059669Emerald
Immunology and Microbiology#65A30DOlive Green
Neuroscience#15803DForest Green
Pharmacology, Toxicology and Pharmaceutics#34D399Mint Jade
Health Sciences
Medicine#DC2626Red
Nursing#F87171Coral
Veterinary#BE123CCrimson
Dentistry#FB7185Salmon Pink
Health Professions#E11D48Rose
Physical Sciences
Chemical Engineering#0E7490Dark Teal
Chemistry#0891B2Cyan
Computer Science#2563EBRoyal Blue
Earth and Planetary Sciences#0C4A6EDeep Ocean Blue
Energy#38BDF8Sky Blue
Engineering#1E40AFNavy Blue
Environmental Science#06B6D4Turquoise
Materials Science#6366F1Indigo
Mathematics#7C3AEDViolet
Physics and Astronomy#4F46E5Blue-Violet
Social Sciences
Arts and Humanities#D97706Amber
Business, Management and Accounting#EA580COrange
Decision Sciences#CA8A04Mustard Gold
Economics, Econometrics and Finance#B45309Burnt Bronze
Psychology#F59E0BGolden Yellow
Social Sciences#C2410CTerracotta Rust

Each node is clickable. Once you click on it you have the option to view either a light-level summary or in-depth summary. The light-level summary contains standard metadata: title, author name, DOI, key_fields and abstract about the research paper. The in-depth summary is generated upon request by the user using the claude-sonnet-4.6-api. The in-depth summary provides the user more specific information about each section in the research paper. To avoid excessive api token usage, we cap in-depth summary requests at 3 per user.

3. AI Assistant

The AI assistant helps the user understand the domain and work contributed for the citation graph that they just generated. The user can chat with the AI assistant about topics such as the relationship between two papers, methodologies of a study, contributions to the field from each research paper or existing research gaps to name a few. The AI assistant uses Retrieval-Augmented Generation (RAG) to fetch knowledge and context regarding a users request from Supermemory. A light-level summary of each paper is automatically stored in supermemory once the citation graph is generated. The AI assistant fetches knowledge regarding the research papers in the citation graph from those memories. If the user asks a question that is outside the context of the light-level summary, the chatbot directs the user to generate an in-depth summary for that research paper. All in-depth summaries generated in the session are also stored in Supermemory. once the session is complete and the user exits the application, all memories in Supermemory are dumped.

Getting Started

Prerequisites

  • Bun: JavaScript runtime and package manager. bun.sh
  • Supabase project: Postgres database and Storage bucket named papers (private). supabase.com
  • Supermemory API key: Vector memory for paper grounding. supermemory.ai
  • Anthropic API key: Powers in-depth summaries and the AI chat agent. console.anthropic.com
  1. Clone the repo and install dependencies:
git clone https://github.com/your-username/citation-chain.git
cd citation-chain
bun install
  1. Create .env.local in the project root:
NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_KEY=
SUPABASE_SECRET_KEY=
SUPERMEMORY_API_KEY=
ANTHROPIC_API_KEY=
OPENALEX_MAILTO=
  1. Start the development server:
bun run dev

The app runs at http://localhost:3000.

About

Interactive Citation Graph for your Research Papers + AI Assistant (Claude Sonnet 4.6)

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages