docs/7-DEVELOPMENT/development-setup.md
This guide walks you through setting up Open Notebook for local development. Follow these steps to get the full stack running on your machine.
Before you start, ensure you have the following installed:
python --version# Clone the repository
git clone https://github.com/lfnovo/open-notebook.git
cd open-notebook
# Add upstream remote for keeping your fork updated
git remote add upstream https://github.com/lfnovo/open-notebook.git
# Using uv (recommended)
uv sync
# Or using pip
pip install -e .
Create a .env file in the project root with your configuration:
# Copy from example
cp .env.example .env
Edit .env with your settings:
# Database
SURREAL_URL=ws://localhost:8000/rpc
SURREAL_USER=root
SURREAL_PASSWORD=password
SURREAL_NAMESPACE=open_notebook
SURREAL_DATABASE=development
# Credential encryption (required for storing API keys)
OPEN_NOTEBOOK_ENCRYPTION_KEY=my-dev-secret-key
# Application
APP_PASSWORD= # Optional password protection
DEBUG=true
LOG_LEVEL=DEBUG
After starting the API and frontend, configure your AI provider via the Settings UI:
Popular providers:
For local development, you can also use:
Note: API key environment variables (e.g.,
OPENAI_API_KEY) are deprecated. Use the Settings UI to manage credentials instead.
# Start SurrealDB in memory
docker run -d --name surrealdb -p 8000:8000 \
surrealdb/surrealdb:v2 start \
--user root --pass password \
--bind 0.0.0.0:8000 memory
# Or with persistent storage
docker run -d --name surrealdb -p 8000:8000 \
-v surrealdb_data:/data \
surrealdb/surrealdb:v2 start \
--user root --pass password \
--bind 0.0.0.0:8000 file:/data/surreal.db
make database
docker compose up -d surrealdb
# Should show server information
curl http://localhost:8000/
Database migrations run automatically when you start the API. The first startup will apply any pending migrations.
To verify migrations manually:
# API will run migrations on startup
uv run python -m api.main
Check the logs - you should see messages like:
Running migration 001_initial_schema
Running migration 002_add_vectors
...
Migrations completed successfully
In a new terminal window:
# Terminal 2: Start API (port 5055)
uv run --env-file .env uvicorn api.main:app --host 0.0.0.0 --port 5055
# Or using the shortcut
make api
You should see:
INFO: Application startup complete
INFO: Uvicorn running on http://0.0.0.0:5055
# Check health endpoint
curl http://localhost:5055/health
# View API documentation
open http://localhost:5055/docs
If you want to work on the frontend, start Next.js in another terminal:
# Terminal 3: Start Next.js frontend (port 3000)
cd frontend
npm install # First time only
npm run dev
You should see:
> next dev
▲ Next.js 16.x
- Local: http://localhost:3000
Open your browser to: http://localhost:3000
After setup, verify everything is working:
curl http://localhost:8000/ returns contentcurl http://localhost:5055/health returns {"status": "ok"}open http://localhost:5055/docs workshttp://localhost:3000 loadsmake start-all
This starts SurrealDB, API, and frontend in one command.
Terminal 1 - Database:
make database
Terminal 2 - API:
make api
Terminal 3 - Frontend:
cd frontend && npm run dev
Install git hooks to automatically check code quality:
uv run pre-commit install
Now your commits will be checked before they're made.
# Lint Python code (auto-fix)
make ruff
# or: ruff check . --fix
# Type check Python code
make lint
# or: uv run python -m mypy .
# Run tests
uv run pytest
# Run tests with coverage
uv run pytest --cov=open_notebook
# Run all tests
uv run pytest
# Run specific test file
uv run pytest tests/test_notebooks.py
# Run with coverage report
uv run pytest --cov=open_notebook --cov-report=html
# Create and switch to new branch
git checkout -b feature/my-feature
# Make changes, then commit
git add .
git commit -m "feat: add my feature"
# Push to your fork
git push origin feature/my-feature
# Fetch latest changes
git fetch upstream
# Rebase your branch
git rebase upstream/main
# Push updated branch
git push origin feature/my-feature -f
Problem: API can't connect to SurrealDB
Solutions:
docker ps | grep surrealdb.env: Should be ws://localhost:8000/rpcdocker stop surrealdb && docker rm surrealdbdocker run -d --name surrealdb -p 8000:8000 surrealdb/surrealdb:v2 start --user root --pass password --bind 0.0.0.0:8000 memoryProblem: Port 5055 or 3000 is already in use
Solutions:
# Find process using port
lsof -i :5055 # Check port 5055
# Kill process (macOS/Linux)
kill -9 <PID>
# Or use different port
uvicorn api.main:app --port 5056
Problem: Import errors when running API
Solutions:
# Reinstall dependencies
uv sync
# Or with pip
pip install -e .
Problem: API fails to start with migration errors
Solutions:
curl http://localhost:8000/.env match your SurrealDB setupmake api 2>&1 | grep -i migrationProblem: Database schema seems outdated
Solutions:
make api/migrations/ folder exists and has filesFor testing with local AI models:
# Install Ollama from https://ollama.ai
# Pull a model (e.g., Mistral 7B)
ollama pull mistral
Then configure via the Settings UI:
http://localhost:11434Run entire stack in Docker:
# Start all services
docker compose --profile multi up
# Logs
docker compose logs -f
# Stop services
docker compose down
After setup is complete:
If you get stuck:
Ready to contribute? Go to contributing.md for the contribution workflow.