Skip to content

Latest commit

 

History

39 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alphex — AI Research Acceleration Platform

Import papers, ask anything, publish faster.


Features

Library

Multi-source import — Upload PDFs directly, paste arXiv IDs, drop in DOIs, or bulk-import an entire Zotero / Mendeley library by uploading a .bib export. Every paper is chunked, embedded, and indexed automatically. Abstracts are embedded immediately on BibTeX import (no re-indexing needed) so papers are searchable in chat from the moment they land.

arXiv search — Find papers by keyword directly inside the Library. Results show title, authors, abstract excerpt, and a one-click Add button. No tab-switching required.

Library views — Toggle between grid view and folder view (papers grouped by first tag). Filter by status (unread / reading / read / queued) or by any tag. Full-text search across title, authors, and tags.

Tags — Auto-tagged by Claude on import. Add or remove tags inline on every paper card. Tag filter chips at the top of the Library let you jump to any topic.

Reading progress — Sidebar shows a gradient progress bar, read count, and in-progress count so you always know where your queue stands.


Assistant

Streaming chat — Token-by-token streaming via SSE. Thinking dots animate while the model searches your library; a blinking cursor appears as the answer streams in. Every answer cites the exact chunk it came from ([S1], [S2], …). Scope the assistant to a single paper or let it search your entire library.


Research Tools

Research question generator (/research) — Select any subset of papers and optionally specify a focus topic. Claude analyses the literature and outputs: research questions, knowledge gaps, testable hypotheses, and a step-by-step proposed procedure — all grounded in the selected papers.

Side-by-side comparison (/compare) — Pick two papers from dropdowns and Claude produces a structured comparison table across: Research Question, Methodology, Dataset/Evaluation, Key Results, Limitations, and Overall Contribution. Each row includes a synthesis insight noting the key difference or commonality.

Literature review generator (/lit-review) — Select 2–20 papers, add an optional focus or scope, and Claude writes a full academic literature review: thematic groupings, synthesised findings (not per-paper summaries), inline [S1]-style citations, and a Research Gaps section. Interactive citation chips in the output show the paper title on hover. Export to .tex (citations flow directly into the BibTeX pipeline), copy to clipboard, or save to Forge for further editing.

Citation network crawler — Every paper detail page has a Fetch References button that queries Semantic Scholar for the paper's reference list. Each reference shows title, authors, year, and a one-click import button (via arXiv ID or DOI) to pull that paper straight into your library.


Annotations

AI-annotated reader — View any paper with hover definitions for technical terms, acronyms, and jargon generated by Claude. Glossary sidebar lists every identified term.

Highlight → note — Select any text passage in the annotated reader and a floating popover appears. Click Save note to persist the selection as a note linked to that paper — no copy-paste required.


Notes

Linked notes attached to individual papers or freeform. Full create / edit / delete. Notes feed into LaTeX export and are visible in the paper detail sidebar.


Forge

AI draft generation — Paste raw notes and data, optionally ground it in library papers. Claude generates a structured research draft with heading, text, and chart sections. Edit sections inline, add per-section comments, export as .md or .tex, or share with a public link.

Draft scoring — Click the Score button on any draft and Claude evaluates it on five metrics (Clarity, Evidence, Structure, Depth, Originality), each scored 1–10. The score panel opens alongside the draft showing: an overall score ring colour-coded red/amber/green, a progress bar per metric, and one specific, actionable improvement suggestion per metric. The header button shows the live overall score (e.g. 7.4/10) so it's always visible. Re-score any time after edits.


Graphs & Charts

Similarity graph — Force-directed graph showing cosine similarity edges between your papers. Explore how topics relate across your library.

Paper chart extraction — Generate matplotlib charts from quantitative data found in any paper. Claude identifies 2–3 distinct findings and writes the chart code; a sandboxed subprocess renders them to PNG.

Prompt-based charts — Describe a chart in natural language and get a rendered matplotlib figure back.


LaTeX Export

Any paper, note, Forge draft, or literature review can be exported as a complete .tex file with a companion references.bib. Markdown headings become \section{}/\subsection{}, bold/italic are converted to \textbf{}/\textit{}, and [Sn] citation tags are substituted with \cite{key} using BibTeX keys generated from paper metadata.


Stack

Layer Tech
Frontend Next.js 14 (app router), TypeScript, Tailwind CSS
Backend FastAPI (Python 3.11), Uvicorn
Auth Supabase Auth (Google OAuth + email/password) + JWT verification in FastAPI
Database Supabase Postgres + pgvector (1536-d, ivfflat cosine index)
File storage Supabase Storage (private papers bucket)
PDF parsing PyMuPDF
Embeddings OpenAI text-embedding-3-small
LLM Anthropic Claude (claude-sonnet-4-20250514)
Charts Claude → Python (matplotlib) → PNG, sandboxed subprocess

APIs used

API Used for
Anthropic Messages API Summaries, streaming RAG chat, chart code, annotations, tagging, forge drafts, research questions, paper comparison, literature reviews, draft scoring
OpenAI Embeddings API text-embedding-3-small — chunk and query embeddings
Supabase Auth, Postgres + pgvector RPC, Storage signed URLs
arXiv Atom API Metadata + PDF for arXiv ingest; keyword search
Crossref REST API DOI metadata
Semantic Scholar Graph API Citation network / reference lists

Repository layout

supabase/schema.sql          — tables, RLS policies, RPC functions, storage bucket
backend/
  app/
    main.py                  — app factory, CORS, router wiring
    auth.py                  — Supabase JWT verification dependency
    db.py                    — service-role Supabase client
    routers/
      chat.py                — RAG chat + SSE streaming
      forge.py               — draft generation, scoring, sharing
      graph.py               — similarity graph + chart execution
      ingest.py              — PDF upload, arXiv, DOI, BibTeX bulk import
      latex.py               — LaTeX / BibTeX export
      notes.py               — notes CRUD
      papers.py              — library, annotations, compare, research questions, literature review, references
      search.py              — semantic search
    services/
      claude.py              — all LLM functions (summarise, chat, annotate, tag, forge, score, lit review, compare, research questions)
      chunking.py            — sliding-window text chunking
      embeddings.py          — OpenAI embedding batching
      doi.py                 — Crossref metadata fetch
      arxiv.py               — arXiv metadata + PDF download
      pdf.py                 — PyMuPDF parsing
frontend/
  src/
    app/
      library/               — paper grid, arXiv search, BibTeX import
      chat/                  — streaming assistant
      research/              — research question generator
      compare/               — side-by-side paper comparison
      lit-review/            — literature review generator
      graph/                 — similarity graph + chart studio
      forge/                 — draft list + editor with scoring
      search/                — semantic search
      notes/                 — notes list
      papers/[id]/           — paper detail, PDF viewer, references panel
      papers/[id]/annotate/  — annotated reader with highlight-to-note
      login/                 — auth (Google, email, demo account)
    components/
      Shell.tsx              — layout wrapper
      Sidebar.tsx            — nav + reading progress
      AuthGate.tsx           — session guard
      IngestBar.tsx          — PDF / arXiv / DOI / BibTeX import widget
      PaperCard.tsx          — library card with status, tags, .tex export
    lib/
      api.ts                 — typed API client
      supabase.ts            — browser Supabase client

Endpoint reference

Method Path Description
POST /ingest/upload Multipart PDF upload
POST /ingest/arxiv { "arxiv": "2310.06825" }
POST /ingest/doi { "doi": "10.1038/..." }
POST /ingest/bibtex .bib file upload — bulk metadata import
POST /search { "query": "...", "k": 8 } — semantic search
POST /chat RAG, returns { answer, citations }
POST /chat/stream SSE streaming RAG — data: {"type":"token","text":"..."}
GET /papers List user's papers with tags
GET/PATCH/DELETE /papers/{id} Paper detail, update status/title, delete
POST /papers/{id}/rechunk Re-index a paper's text
GET /papers/{id}/annotate AI term definitions + paper chunks
GET /papers/{id}/related Cosine-similar papers
GET /papers/{id}/references Citation list via Semantic Scholar
POST/DELETE /papers/{id}/tags Add / remove tags
GET /papers/graph Similarity graph nodes + edges
GET /papers/arxiv-search ?q=... — arXiv keyword search
POST /papers/research-questions Generate questions, gaps, hypotheses, procedure
POST /papers/compare Side-by-side comparison of two papers
POST /papers/literature-review Generate grounded literature review
POST /graph Prompt → matplotlib PNG
POST /graph/paper/{id} Extract charts from a paper
POST /forge/draft Generate draft from notes + paper context
GET /forge/drafts List user's drafts
GET/PATCH/DELETE /forge/drafts/{id} Get, update, delete draft
POST /forge/drafts/{id}/share Generate public share token
POST /forge/drafts/{id}/score AI scoring on 5 metrics with suggestions
GET /forge/shared/{token} Public draft view (no auth)
GET/POST/PATCH/DELETE /notes Notes CRUD
POST /latex Export body + paper metadata as .tex + .bib

All endpoints except GET /forge/shared/{token} require Authorization: Bearer <supabase-jwt>.


Local setup

Prerequisites

  • Python 3.11+, Node 18+
  • Supabase project (free tier is sufficient)
  • Anthropic API key, OpenAI API key

1. Database

Run supabase/schema.sql in the Supabase SQL editor. This creates all tables, indexes, RLS policies, and the related_papers vector search RPC.

In Supabase → Authentication → Providers, enable Google and add http://localhost:3000/auth/callback to the allowed redirect URLs.

2. Backend

cd backend
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env   # fill in keys
uvicorn app.main:app --reload --port 8000

Required env vars:

SUPABASE_URL=
SUPABASE_SERVICE_ROLE_KEY=
SUPABASE_ANON_KEY=
SUPABASE_JWT_SECRET=
ANTHROPIC_API_KEY=
OPENAI_API_KEY=
CLAUDE_MODEL=claude-sonnet-4-20250514
EMBED_MODEL=text-embedding-3-small
CORS_ORIGINS=http://localhost:3000
PORT=8000

3. Frontend

cd frontend
npm install
cp .env.local.example .env.local   # fill in Supabase public keys
npm run dev

Required env vars:

NEXT_PUBLIC_SUPABASE_URL=
NEXT_PUBLIC_SUPABASE_ANON_KEY=
NEXT_PUBLIC_API_URL=http://localhost:8000

Open http://localhost:3000. A demo account (demo@alphex.ai / demo1234) can be enabled by creating that user in Supabase Auth.


Hallucination safeguards

Every LLM call in Alphex is designed to prevent the model from inventing information not present in the provided context.

Feature Safeguard
Chat (RAG) System prompt explicitly prohibits answering from training knowledge. Every claim must be cited inline as [S1], [S2], etc. When no relevant chunks are found in the library, the response is forced to: "I could not find relevant information in your library for this question." Temperature locked to 0.1. Applies to both the standard and streaming chat endpoints.
Paper charts Charts are only generated when REAL numbers are explicitly stated in the paper text. If fewer than 2 concrete data points exist for a chart, it is skipped entirely. Fabricating or estimating values is explicitly prohibited in the system prompt.
Paper summaries System prompt instructs: "Do not invent details that are not in the text." Input is the raw paper text, not the model's prior knowledge.
Annotations / Glossary Only terms that literally appear in the provided chunks are returned. The first 2 chunks (author/affiliation headers) are skipped to prevent proper nouns being misidentified as technical terms.
Literature review Model is instructed not to invent findings or statistics not present in the provided source summaries. If a source lacks detail, the model is instructed to say so rather than extrapolate.
Paper comparison Model is explicitly told not to invent claims, statistics, or findings not stated in the provided summaries.
Research questions / Forge Both system prompts instruct the model to ground output in provided notes and paper excerpts only — not to invent results.
Auto-tagging Only topics, methods, and domains drawn from the title, abstract, and body excerpts. Proper nouns (author names, institutions, journals) are excluded by system prompt rule.

Security notes

  • Sandboxed chart execution. Generated Python is regex-filtered for dangerous imports, runs in a 20-second subprocess.run with a minimal clean environment, and only writes to a randomly-named temp file.
  • RLS on every table. Even if the frontend bypassed the API, Supabase row-level security restricts every user to their own rows. The backend uses the service role key but manually filters every query by the verified user_id from the JWT.
  • No secrets in code. Backend reads from .env via pydantic-settings; frontend exposes only the anon key and Supabase URL via NEXT_PUBLIC_* env vars.

License

MIT

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages