Skip to content

mahdibani/AI-Scientist

Repository files navigation

AI Scientist

AI Scientist is a research-planning assistant that turns a rough scientific idea into a structured experiment plan. The app helps a scientist move from an initial question to a reviewed hypothesis, a literature-aware protocol, materials, timeline, validation plan, and a feedback loop that improves the next run.

Demo

Watch the demo video

Architecture

Architecture diagram

What the app does

The product is built around two phases:

  1. Idea phase: a scientist enters a question, the system rewrites it into research-ready language, surfaces ambiguity, and asks for human confirmation.
  2. Planning phase: once the question is approved, the pipeline generates literature QC, protocol steps, materials, timeline, and validation guidance.

The scientist can then edit the generated plan in the UI. Those edits are saved as structured feedback and reused later through the Cognee learning loop.

How the system is organized

Frontend

The frontend lives in frontend/ and is built with Next.js and React. It provides the review interface where the scientist:

  • enters the initial scientific question,
  • validates the model's interpretation,
  • reviews the generated plan,
  • edits protocol, materials, and timeline sections,
  • saves feedback back into the system.

Backend API

The backend API lives in backend/server.js and acts as the single application entry point. It:

  • receives requests from the frontend,
  • validates payloads,
  • calls the Python pipeline when a full plan is needed,
  • saves feedback and local memory,
  • returns merged JSON responses to the UI.

Pipeline engine

The planning pipeline lives in backend/app/agents/graph.py and is executed through backend/run_generate_plan.py. It runs the main planning stages:

  1. Parse the hypothesis.
  2. Run literature quality control.
  3. Design the protocol.
  4. Build materials and timeline outputs.
  5. Add validation logic.
  6. Synthesize the final plan.

Learning loop

The project includes a lightweight learning loop called Cognee.

  • Scientist corrections are saved locally as structured records.
  • Similar past corrections are retrieved for future runs.
  • Those corrections are injected as feedback into the next generation.

This means the system becomes more useful over time without requiring a full re-design of the prompting flow.

Tech stack

  • Frontend: Next.js, React, TypeScript, Lucide
  • Backend API: Node.js
  • Planning engine: Python, LangGraph
  • LLM access: NVIDIA NIM through an OpenAI-compatible client
  • Search and retrieval: Tavily, Semantic Scholar, PubMed-style retrieval utilities, Qdrant hooks

Repository structure

.
|-- frontend/                 # Next.js scientist review UI
|-- backend/
|   |-- server.js             # Node API layer
|   |-- run_generate_plan.py  # Python entry point used by the Node API
|   |-- app/
|   |   |-- agents/           # LangGraph planning agents
|   |   |-- models/           # Pydantic response models
|   |   |-- services/         # LLM and tracing helpers
|   |   `-- database/         # Local feedback store helpers
|   `-- data/                 # Local memory and feedback files
|-- docker-compose.yml
|-- frontend/Dockerfile
`-- backend/Dockerfile

Local development

1. Install dependencies

At the root:

npm install

Frontend dependencies:

npm --prefix frontend install

Backend dependencies:

npm --prefix backend install
python -m pip install -r backend/requirements.txt

2. Configure environment variables

Create backend/.env.local from backend/.env.example and fill in the keys you want to use.

The most important variables are:

  • NVIDIA_API_KEY
  • NVIDIA_BASE_URL
  • NVIDIA_MODEL
  • TAVILY_API_KEY

3. Start the app

Run the backend:

npm run dev:backend

In another terminal, run the frontend:

npm run dev:frontend

Default local URLs:

  • Frontend: http://127.0.0.1:3001
  • Backend: http://127.0.0.1:4000

Docker

The Docker setup is split into two services:

  • backend: Node API plus the Python LangGraph pipeline
  • frontend: Next.js UI

1. Prepare environment variables

Create backend/.env.local from backend/.env.example.

2. Build and start

docker compose up --build

3. Open the app

  • Frontend: http://localhost:3001
  • Backend health check: http://localhost:4000/health

4. Stop the stack

docker compose down

API flow

The main request path is:

  1. The frontend sends a request to the Node backend.
  2. The backend validates the request and decides which workflow to run.
  3. For full plan generation, the backend spawns run_generate_plan.py.
  4. The Python pipeline runs the LangGraph workflow and returns structured JSON.
  5. The backend merges supporting metadata and returns the final response to the frontend.

Main endpoints

  • POST /api/idea-phase: refine an initial scientific question
  • POST /api/idea-phase/validate: save scientist validation
  • POST /api/lqc-plan: generate the literature QC plus experiment plan
  • POST /api/feedback: save scientist edits for future reuse
  • GET /health: basic backend health check

Notes for presenting the project

If you are using this repository for a demo or portfolio, the easiest structure is:

  1. Put the architecture diagram near the top of the README.
  2. Add the demo video right after the project summary.
  3. Keep the "How the system is organized" section because it explains the image in words.
  4. Keep the "Docker" section because it gives reviewers a fast path to run the project.

Current behavior to know

  • Runtime memory is stored locally in backend/data/*.local.json.
  • The Node server is the single API surface for the UI.
  • The Python layer is not exposed directly to the frontend.
  • The frontend expects the backend API on port 4000 by default.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors