Skip to content
prashant edited this page May 11, 2026 · 1 revision

Journal Lens — Wiki

AI-powered research discovery platform.

Live: https://journal-lens.vercel.app/


Local setup (minimal)

Backend

cd backend
npm install
npm start

Backend entry: backend/index.js

Frontend

cd frontend
npm install
npm run dev

Environment variables

backend/.env

Required by backend code:

PORT=8080

# OpenAlex
OPENALEX_BASE_URL=https://api.openalex.org
OPENALEX_API_KEY=your_openalex_api_key

# CORS (used in backend/configs/corsOptions.js)
FRONTEND_URL=http://localhost:5173

# Groq (used in backend/routes/chat.js)
GROQ_API_KEY=your_groq_api_key

# Clerk (used by @clerk/express middleware)
CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
CLERK_SECRET_KEY=your_clerk_secret_key

frontend/.env

(Referenced in repository README)

VITE_BACKEND_BASE_URL=http://localhost:8080/api
VITE_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key
VITE_LOGO_DEV_PUBLIC_KEY=your_logo_dev_public_key

Authentication (important)

Backend uses Clerk:

  • Global middleware: clerkMiddleware() in backend/index.js
  • All API routers also enforce auth: router.use(requireAuth)
  • requireAuth checks getAuth(req).userId and returns 401 if missing.

So, these endpoints require a valid Clerk-authenticated request.


Backend API

Base server mounts (from backend/index.js):

  • /api/chat
  • /api/researchpapers
  • /api/author
  • /api/providers

Chat (backend/routes/chat.js)

  • POST /api/chat/ingest-text
    • body: { "journalId": "...", "text": "..." }
    • stores chunks in an in-memory pdfStore object (not persistent)
  • POST /api/chat/ask
    • body: { "journalId": "...", "question": "...", "chatHistory": [] }
    • returns: { "answer": "..." }
    • if not ingested: 404 "PDF not ingested yet."

Research papers (backend/routes/researchpapers.js)

  • GET /api/researchpapers?field=...&pageNum=...&authorId=...
    • field and pageNum are required (else 400)
    • uses OpenAlex /works with filter: type:article,open_access.is_oa:true
    • if authorId provided: adds author.id:${authorId}

Author (backend/routes/author.js)

  • GET /api/author/id?author=...
    • author required (else 400)
    • queries OpenAlex /authors
    • returns first match’s display_name + ids

Providers (backend/routes/provider.js)

  • GET /api/providers?page=1&per_page=25
    • lists publishers (OpenAlex /publishers)
  • GET /api/providers/sources/:providerId
    • lists sources/journals for provider (OpenAlex /sources)
  • GET /api/providers/:providerId
    • single publisher detail (OpenAlex /publishers/{providerId})

Backend dependencies (from backend/package.json)

  • express
  • cors
  • dotenv
  • @clerk/express
  • axios
  • groq-sdk
  • pdf-parse
  • node-fetch
  • mongoose (installed; not used in the shown backend entry/routes)