Skip to content
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions kits/research-paper-analyzer/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.env
.env.local
apps/node_modules
apps/.next
apps/.vercel
127 changes: 127 additions & 0 deletions kits/research-paper-analyzer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
# Research Paper Analyzer

An AI-powered kit that takes any academic PDF URL and returns a structured breakdown:

- **Problem Statement** — what the research is trying to solve and why it matters
- **Methodology** — how the study was conducted
- **Key Findings** — the main results and conclusions
- **Limitations** — acknowledged weaknesses or gaps
- **Plain English Summary** — jargon-free explanation for non-specialists
- **Follow-up Questions** — ideas for future research directions

Built on [Lamatic.ai](https://lamatic.ai) with a **FastAPI** backend and a **React + Vite** frontend (JavaScript/JSX).

---

## Architecture

```
React (Vite/JSX) → FastAPI (Python) → Lamatic Flow → LLM
frontend backend orchestration
localhost:5173 localhost:8000
```

Comment on lines +18 to +23

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Mission brief: neutralize markdownlint blockers before merge.

At Line 18 and Line 52, fenced blocks are missing language tags (MD040). Around Line 52, Line 91, and Line 96, add blank lines around fenced blocks (MD031) to satisfy the validator.

Proposed patch
 ## Architecture
 
-```
+```text
 React (Vite/JSX)  →  FastAPI (Python)  →  Lamatic Flow  →  LLM
    frontend              backend            orchestration
  localhost:5173       localhost:8000

@@
.env values to fill in:
- + +env
RESEARCH_PAPER_ANALYZER_FLOW_ID=
LAMATIC_API_URL=
LAMATIC_PROJECT_ID=
LAMATIC_API_KEY=

@@
### `POST /analyze`

**Request:**
+
```json
{ "pdf_url": "https://arxiv.org/pdf/2303.08774.pdf" }

Response:
+

{
  "success": true,

Also applies to: 52-57, 91-93, 96-111

🧰 Tools
🪛 markdownlint-cli2 (0.22.1)

[warning] 18-18: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/research-paper-analyzer/README.md` around lines 18 - 23, Several fenced
code blocks in the README (e.g., the ASCII diagram starting "React (Vite/JSX)  →
FastAPI (Python)  →  Lamatic Flow  →  LLM", the `.env` block beginning with
RESEARCH_PAPER_ANALYZER_FLOW_ID, and the JSON examples used under "POST
/analyze") are missing language tags (MD040) and lack surrounding blank lines
(MD031); update each fenced block to include the appropriate language tag (e.g.,
```text, ```env, ```json) and ensure there is a blank line before and after
every fenced block so the validator passes, targeting the blocks that contain
the ASCII diagram, the `.env` variables, and the request/response JSON examples.

---

## Quick Start

### 1. Deploy the Flow in Lamatic Studio

1. Go to [studio.lamatic.ai](https://studio.lamatic.ai) → New Project → New Flow
2. Add nodes in this order:
- **API Trigger** — input schema: `{ pdf_url: string }`
- **Extract From File** — file URL: `{{trigger.pdf_url}}`
- **LLM Node** — use prompt from `prompts/analyze-paper.md`, structured JSON output
- **API Response** — output: `{{LLMNode.output}}`
Comment on lines +33 to +35
3. Deploy the flow and copy the **Flow ID** from Settings

### 2. Start the FastAPI Backend

```bash
cd apps/backend
cp .env.example .env
# Fill in your Flow ID and Lamatic credentials in .env
pip install -r requirements.txt
uvicorn main:app --reload
```

Backend runs at [http://localhost:8000](http://localhost:8000).
Check [http://localhost:8000/docs](http://localhost:8000/docs) for the auto-generated API docs.

`.env` values to fill in:
```
RESEARCH_PAPER_ANALYZER_FLOW_ID=<your-flow-id>
LAMATIC_API_URL=<from Lamatic Settings>
LAMATIC_PROJECT_ID=<from Lamatic Settings>
LAMATIC_API_KEY=<from Lamatic Settings>
```

### 3. Start the React Frontend

```bash
cd apps/frontend
npm install
npm run dev
```

Frontend runs at [http://localhost:5173](http://localhost:5173).
Vite proxies `/analyze` → FastAPI automatically, so no CORS issues in dev.

---

## Usage

1. Paste any publicly accessible PDF URL (e.g., an arXiv paper)
2. Click **Analyze Paper**
3. Browse the structured breakdown — expand/collapse each section
4. Click **JSON** to copy the raw JSON output

### Example URLs to try

- `https://arxiv.org/pdf/2303.08774.pdf` — GPT-4 Technical Report
- `https://arxiv.org/pdf/1706.03762.pdf` — Attention Is All You Need

---

## API Reference

### `POST /analyze`

**Request:**
```json
{ "pdf_url": "https://arxiv.org/pdf/2303.08774.pdf" }
```

**Response:**
```json
{
"success": true,
"data": {
"title": "...",
"authors": ["..."],
"year": 2023,
"problem_statement": "...",
"methodology": "...",
"key_findings": ["..."],
"limitations": ["..."],
"plain_english_summary": "...",
"follow_up_questions": ["..."]
}
}
```

---

## Tech Stack

- **Backend**: FastAPI, Python, httpx, Pydantic, python-dotenv
- **Frontend**: React.js, Vite, JavaScript/JSX, Tailwind CSS, Lucide React
- **AI Orchestration**: Lamatic.ai flows

---

## Requirements

- Python 3.10+
- Node.js 18+, npm 9+
- Lamatic.ai account ([sign up free](https://lamatic.ai))
44 changes: 44 additions & 0 deletions kits/research-paper-analyzer/agent.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Research Paper Analyzer Agent

## Identity

You are an expert academic research analyst. Your role is to read scientific papers and produce clear, structured analyses that help researchers, students, and professionals quickly understand complex academic work.

## Capabilities

- Extract and articulate the core research problem and motivation
- Identify and explain the methodology used
- Summarize key findings and results objectively
- Surface limitations and potential gaps in the research
- Translate academic language into plain English for non-specialists
- Generate thoughtful follow-up research questions

## Behavior Guidelines

- Always base your analysis strictly on the paper content — do not hallucinate facts
- Be objective; do not editorialize beyond what the paper states
- If a section of the paper is unclear or missing, state that explicitly
- Keep the plain-English summary accessible to a smart non-expert
- Format all output as structured JSON matching the defined schema

## Output Schema

```json
{
"title": "string",
"authors": ["string"],
"year": "number | null",
"problem_statement": "string",
"methodology": "string",
"key_findings": ["string"],
"limitations": ["string"],
"plain_english_summary": "string",
"follow_up_questions": ["string"]
}
```

## Constraints

- Never invent citations, statistics, or claims not present in the paper
- Refuse requests to misrepresent or plagiarize research
- If the uploaded file is not an academic paper, respond with a clear error message
4 changes: 4 additions & 0 deletions kits/research-paper-analyzer/apps/backend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RESEARCH_PAPER_ANALYZER_FLOW_ID=your_flow_id_here
LAMATIC_API_URL=https://your-lamatic-endpoint.lamatic.ai
LAMATIC_PROJECT_ID=your_project_id_here
LAMATIC_API_KEY=your_api_key_here
7 changes: 7 additions & 0 deletions kits/research-paper-analyzer/apps/backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.env
__pycache__/
*.py[cod]
*.pyo
.venv/
venv/
env/
95 changes: 95 additions & 0 deletions kits/research-paper-analyzer/apps/backend/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
from fastapi import FastAPI, HTTPException
from fastapi.middleware.cors import CORSMiddleware
from pydantic import BaseModel
import httpx
import os
from dotenv import load_dotenv

load_dotenv()

LAMATIC_API_URL = os.getenv("LAMATIC_API_URL", "").rstrip("/")
LAMATIC_PROJECT_ID = os.getenv("LAMATIC_PROJECT_ID", "")
LAMATIC_API_KEY = os.getenv("LAMATIC_API_KEY", "")
FLOW_ID = os.getenv("RESEARCH_PAPER_ANALYZER_FLOW_ID", "")

# Lamatic uses GraphQL — single POST endpoint per project
EXECUTE_QUERY = """
query ExecuteWorkflow($workflowId: String!, $payload: JSON) {
executeWorkflow(workflowId: $workflowId, payload: $payload) {
status
result
}
}
"""

app = FastAPI(title="Research Paper Analyzer", version="1.0.0")

app.add_middleware(
CORSMiddleware,
allow_origins=["http://localhost:5173", "http://localhost:3000"],
allow_methods=["POST", "GET"],
allow_headers=["*"],
)


class AnalyzeRequest(BaseModel):
pdf_url: str


@app.get("/health")
def health():
return {"status": "ok"}


@app.post("/analyze")
async def analyze_paper(req: AnalyzeRequest):
if not FLOW_ID:
raise HTTPException(500, "RESEARCH_PAPER_ANALYZER_FLOW_ID is not set.")
if not LAMATIC_API_URL or not LAMATIC_API_KEY or not LAMATIC_PROJECT_ID:
raise HTTPException(500, "Lamatic API credentials are not set.")

headers = {
"Authorization": f"Bearer {LAMATIC_API_KEY}",
"x-project-id": LAMATIC_PROJECT_ID,
"Content-Type": "application/json",
}

body = {
"query": EXECUTE_QUERY,
"variables": {
"workflowId": FLOW_ID,
"payload": {"pdf_url": req.pdf_url},
},
}

try:
async with httpx.AsyncClient(timeout=120.0) as client:
response = await client.post(LAMATIC_API_URL, headers=headers, json=body)

if response.status_code == 401:
raise HTTPException(401, "Invalid Lamatic API key or project ID.")
if response.status_code != 200:
raise HTTPException(response.status_code, f"Lamatic API error: {response.text}")

data = response.json()

# GraphQL errors surface inside data.errors
if "errors" in data:
raise HTTPException(500, f"Flow error: {data['errors'][0].get('message', 'unknown')}")

execute_result = data.get("data", {}).get("executeWorkflow", {})

if execute_result.get("status") != "success":
raise HTTPException(500, f"Flow did not succeed: {execute_result.get('status')}")

analysis = execute_result.get("result")

if not analysis:
raise HTTPException(500, "No analysis returned by the flow.")

return {"success": True, "data": analysis}

except httpx.TimeoutException:
raise HTTPException(504, "Request timed out. The PDF may be too large.")
except httpx.RequestError as e:
raise HTTPException(503, f"Network error: {str(e)}")
5 changes: 5 additions & 0 deletions kits/research-paper-analyzer/apps/backend/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
fastapi>=0.111.0
uvicorn[standard]>=0.29.0
httpx>=0.27.0
python-dotenv>=1.0.0
pydantic>=2.0.0
3 changes: 3 additions & 0 deletions kits/research-paper-analyzer/apps/frontend/.env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Leave empty when using Vite's built-in proxy (dev mode)
# Set to your deployed FastAPI URL for production builds
VITE_BACKEND_URL=
4 changes: 4 additions & 0 deletions kits/research-paper-analyzer/apps/frontend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
dist/
.env
.env.local
12 changes: 12 additions & 0 deletions kits/research-paper-analyzer/apps/frontend/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Research Paper Analyzer · Lamatic.ai</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>
</body>
</html>
23 changes: 23 additions & 0 deletions kits/research-paper-analyzer/apps/frontend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "research-paper-analyzer-frontend",
"version": "0.1.0",
"private": true,
"type": "module",
"scripts": {
"dev": "vite",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
"lucide-react": "^0.469.0",
"react": "^18.3.1",
"react-dom": "^18.3.1"
},
"devDependencies": {
"@vitejs/plugin-react": "^4.3.1",
"autoprefixer": "^10.4.19",
"postcss": "^8.4.38",
"tailwindcss": "^3.4.4",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | 🏗️ Heavy lift

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Locate and print the relevant package.json with line numbers
FILE="kits/research-paper-analyzer/apps/frontend/package.json"
echo "---- $FILE (tailwindcss line vicinity) ----"
nl -ba "$FILE" | sed -n '1,120p' | sed -n '15,40p'

# Search for tailwind config in this app/kit
echo "---- tailwind config files ----"
find kits/research-paper-analyzer -maxdepth 6 -type f \( -name "tailwind.config.*" -o -name "postcss.config.*" \) | sort

# Search for Tailwind v3/v4 indicators in config
echo "---- tailwind config contents (if present) ----"
for f in $(find kits/research-paper-analyzer -maxdepth 6 -type f -name "tailwind.config.*" 2>/dev/null | sort); do
  echo "### $f"
  nl -ba "$f" | head -n 220 | sed -n '1,120p'
done

# List CSS files within this app that would trigger the kits/**/*.css guideline
echo "---- CSS files in this app (for tailwind requirement applicability) ----"
find kits/research-paper-analyzer/apps/frontend -type f \( -name "*.css" -o -name "*.scss" -o -name "*.sass" -o -name "*.less" \) | sort

# Show any reference to tailwind directives in CSS (e.g., `@tailwind`)
echo "---- Tailwind directives in CSS ----"
rg -n "`@tailwind`|tailwindcss" kits/research-paper-analyzer/apps/frontend --glob='*.{css,scss,less,sass,ts,tsx}' || true

Repository: Lamatic/AgentKit

Length of output: 215


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="kits/research-paper-analyzer/apps/frontend/package.json"

echo "---- JSON tailwindcss dependency in $FILE ----"
python3 - <<'PY'
import json
from pathlib import Path
p=Path("kits/research-paper-analyzer/apps/frontend/package.json")
data=json.loads(p.read_text())
for section in ["dependencies","devDependencies"]:
    if section in data and "tailwindcss" in data[section]:
        print(f"{section}.tailwindcss = {data[section]['tailwindcss']}")
PY

echo "---- package.json lines 1-60 (for context) ----"
cat -n "$FILE" | sed -n '1,60p'

echo "---- tailwind/postcss config files under kits/research-paper-analyzer/apps/frontend ----"
find kits/research-paper-analyzer/apps/frontend -maxdepth 4 -type f \( -name "tailwind.config.*" -o -name "postcss.config.*" \) | sort

echo "---- tailwind directives in CSS under apps/frontend ----"
rg -n "`@tailwind`|tailwindcss" kits/research-paper-analyzer/apps/frontend --glob='*.{css,scss,less,sass}' || true

echo "---- list CSS files under apps/frontend ----"
find kits/research-paper-analyzer/apps/frontend -type f \( -name "*.css" -o -name "*.scss" -o -name "*.sass" -o -name "*.less" \) | sort

Repository: Lamatic/AgentKit

Length of output: 1498


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "---- tailwind.config.js ----"
cat -n kits/research-paper-analyzer/apps/frontend/tailwind.config.js | sed -n '1,200p'

echo "---- postcss.config.js ----"
cat -n kits/research-paper-analyzer/apps/frontend/postcss.config.js | sed -n '1,200p'

Repository: Lamatic/AgentKit

Length of output: 459


Mission risk: Tailwind v3 is powering this kit—upgrade to Tailwind CSS v4+.

  • kits/research-paper-analyzer/apps/frontend/package.json pins devDependencies.tailwindcss to ^3.4.4 (line 20), but this kit’s CSS uses Tailwind directives in apps/frontend/src/index.css (@tailwind base/components/utilities).
  • Upgrade tailwindcss to a v4+ release and adjust tailwind.config.js / PostCSS setup and any Tailwind usage in src/index.css for v4 compatibility.
  • This kit’s package.json also uses caret ranges (not pinned versions), conflicting with the kit dependency pinning guideline.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/research-paper-analyzer/apps/frontend/package.json` at line 20, Update
the frontend kit to use Tailwind CSS v4+ by changing devDependencies.tailwindcss
in package.json from "^3.4.4" to a pinned v4+ version (e.g. "4.0.0" or the exact
release you choose), then update tailwind.config.js and the PostCSS config to
the v4 config shape and plugin usage, and modify apps/frontend/src/index.css to
use any v4-compatible directive or plugin imports if needed; also replace caret
ranges in package.json devDependencies with exact pinned versions to follow kit
dependency pinning guidelines.

"vite": "^5.3.1"
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="kits/research-paper-analyzer/apps/frontend/package.json"

echo "== File =="
wc -l "$FILE"
echo

echo "== Relevant dependency block =="
# Print around dependencies/devDependencies
sed -n '1,120p' "$FILE" | nl -ba | sed -n '1,120p'

echo
echo "== Check for caret ranges in dependency sections =="
rg -n '"(dependencies|devDependencies)"\s*:' -S "$FILE"
echo
rg -n '\^' "$FILE" || true

Repository: Lamatic/AgentKit

Length of output: 225


🏁 Script executed:

#!/bin/bash
set -euo pipefail

FILE="kits/research-paper-analyzer/apps/frontend/package.json"

echo "== File =="
wc -l "$FILE"
echo

echo "== Show package.json =="
# Small file (23 lines); safe to print fully with line numbers via awk
awk '{print NR ":" $0}' "$FILE"
echo

echo "== Check dependency keys exist =="
rg -n '"dependencies"\s*:' "$FILE" || true
rg -n '"devDependencies"\s*:' "$FILE" || true
echo

echo "== Check for caret (^) semver ranges in the file =="
rg -n '\^' "$FILE" || true

Repository: Lamatic/AgentKit

Length of output: 1093


Mission brief: pin dependency versions.
In kits/research-paper-analyzer/apps/frontend/package.json (lines 11–22), both dependencies and devDependencies use caret semver ranges (e.g., ^18.3.1, ^5.3.1). Replace all ^x.y.z with exact x.y.z to comply with the kits/**/package.json pinned-version policy.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/research-paper-analyzer/apps/frontend/package.json` around lines 11 -
22, The package.json dependencies and devDependencies currently use caret ranges
(e.g., "react": "^18.3.1", "vite": "^5.3.1"); change every version string that
starts with a caret to the exact version without the caret (e.g., "react":
"18.3.1", "vite": "5.3.1") so all entries under "dependencies" and
"devDependencies" are pinned; update the entries for lucide-react, react,
react-dom, `@vitejs/plugin-react`, autoprefixer, postcss, tailwindcss, and vite
accordingly to their exact x.y.z values.

}
6 changes: 6 additions & 0 deletions kits/research-paper-analyzer/apps/frontend/postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🌐 Web query:

For Tailwind CSS v4, what is the official PostCSS setup and recommended CSS entry syntax, and how does it differ from Tailwind v3's tailwindcss+autoprefixer plugin config?

💡 Result:

Tailwind CSS v4 (official) PostCSS setup 1) Install packages - Install tailwindcss, the dedicated PostCSS plugin @tailwindcss/postcss, and postcss: npm i tailwindcss @tailwindcss/postcss postcss [1]. 2) PostCSS config - In your postcss.config.mjs (or wherever PostCSS is configured), add only the Tailwind v4 PostCSS plugin: export default { plugins: { "@tailwindcss/postcss": {}, } }; [1]. 3) Recommended CSS entry syntax - In your main CSS file, import Tailwind with a regular CSS import: @import "tailwindcss"; [1][2]. - Tailwind’s v4 docs/upgrade guide explicitly note that the v3 @tailwind base/components/utilities directives are replaced by @import "tailwindcss" in v4 [2]. How this differs from Tailwind v3 (tailwindcss + autoprefixer) - In Tailwind v3, Tailwind’s PostCSS plugin is the tailwindcss package and it’s typically paired with autoprefixer in postcss.config to handle vendor prefixing. - In Tailwind v4, the PostCSS plugin has moved into a dedicated package (@tailwindcss/postcss) and the recommended PostCSS configuration shown by Tailwind contains @tailwindcss/postcss as the plugin [1]. Tailwind v4’s own v4.0 announcement also describes “zero configuration” regarding vendor prefixing/transforms by using Lightning CSS under the hood, implying autoprefixer is no longer needed in this setup [3]. - In Tailwind v3, the CSS entry file uses three @tailwind directives (base/components/utilities). Tailwind’s upgrade guide shows these v3 directives being replaced in v4 by the single @import "tailwindcss" statement [2].

Citations:


Mission: Replace Tailwind v3 PostCSS wiring with Tailwind v4’s official setup

This postcss.config.js uses the Tailwind v3-style plugin map (tailwindcss + autoprefixer), but Tailwind v4’s official PostCSS setup is to install/use @tailwindcss/postcss and configure only that plugin:

  • plugins: { "@tailwindcss/postcss": {} }
  • In your main CSS, replace v3 directives (@tailwind base/components/utilities) with @import "tailwindcss";

Align this kit’s Tailwind toolchain to v4 to avoid build/lint drift against the Tailwind v4+ kit styling requirement.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@kits/research-paper-analyzer/apps/frontend/postcss.config.js` around lines 2
- 4, The PostCSS plugin map currently uses the v3-style keys (plugins object
containing tailwindcss and autoprefixer); replace that plugin map so it only
registers the v4 plugin key "`@tailwindcss/postcss`" with an empty config object
and remove the separate "tailwindcss" and "autoprefixer" entries, and then
update the main CSS files to replace any v3 directives "`@tailwind`
base/components/utilities" with a single import directive '`@import`
"tailwindcss";' so the build uses Tailwind v4’s official PostCSS wiring.

},
};
Loading