Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

docs: add development guide and expand SQLCipher troubleshooting (#2117)

LearningCircuit96d189762536
diff --git a/docs/SQLCIPHER_INSTALL.md b/docs/SQLCIPHER_INSTALL.md
index 3e297d9538..ed85e245d1 100644
--- a/docs/SQLCIPHER_INSTALL.md
+++ b/docs/SQLCIPHER_INSTALL.md
@@ -107,14 +107,36 @@ Make sure you've set the LDFLAGS and CPPFLAGS environment variables as shown abo
Ensure you're using the Visual Studio Native Tools Command Prompt and have all required dependencies installed.
-### Python: "No module named sqlcipher3"
+### Python: "No module named sqlcipher3" or "pysqlcipher3"
+
+**Error variants:**
+- `ModuleNotFoundError: No module named 'sqlcipher3'`
+- `ModuleNotFoundError: No module named 'pysqlcipher3'`
The project automatically selects the correct SQLCipher package based on your platform:
- **x86_64 Linux**: Uses `sqlcipher3-binary` (pre-compiled wheel)
- **ARM64 Linux**: Uses `sqlcipher3` (builds from source with system SQLCipher)
- **Other platforms**: Uses `sqlcipher3`
-If you encounter issues, ensure you have `libsqlcipher-dev` installed first.
+**Solution:**
+1. First, ensure you have the system SQLCipher library installed:
+ ```bash
+ # Debian/Ubuntu
+ sudo apt-get install libsqlcipher-dev
+
+ # macOS
+ brew install sqlcipher
+ ```
+
+2. Then reinstall the Python package:
+ ```bash
+ # If using PDM (recommended)
+ pdm install
+
+ # If NOT using PDM (e.g., pip-only setup):
+ pip install --force-reinstall sqlcipher3-binary # x86_64 Linux
+ pip install --force-reinstall sqlcipher3 # Other platforms
+ ```
## For Developers
diff --git a/docs/developing.md b/docs/developing.md
index 714cf676ed..baedd4cd19 100644
--- a/docs/developing.md
+++ b/docs/developing.md
@@ -7,50 +7,98 @@
- **[Extension Guide](developing/EXTENDING.md)** - How to add custom search engines, strategies, and LLM providers
- **[Testing and CI](CI_CD_INFRASTRUCTURE.md)** - GitHub Actions workflows, pre-commit hooks, and security scanning
-## Configuring the Environment
+## Development Setup
-The most convenient way to configure the Python environment is to use
-[PDM](https://pdm-project.org/en/latest/). After installing PDM, configure the
-environment and install dependencies:
+### Prerequisites
+- **Python**: 3.11+
+- **Node.js**: 24.0.0+
+- **Docker**: Latest version (for production builds)
+- **PDM**: Python package manager
+- **SQLCipher**: Required for encrypted database support. See [SQLCIPHER_INSTALL.md](SQLCIPHER_INSTALL.md) for platform-specific instructions.
-```bash
-pdm install --no-self
-```
+### Initial Setup
-You can run a command in the environment by prefixing it with `pdm run`. You
-can also activate the environment with `pdm venv activate`.
+1. **Clone and Prepare Environment**
+ ```bash
+ git clone [email protected]:LearningCircuit/local-deep-research.git
+ # Or via HTTPS: https://github.com/LearningCircuit/local-deep-research.git
+ cd local-deep-research
+ ```
-## Setting up Pre-Commit Hooks
+2. **Backend Setup**
+ ```bash
+ # Create and activate virtual environment
+ python -m venv .venv
+ source .venv/bin/activate
-These hooks will automatically run linting for every commit. You need to
-initialize them once after configuring the environment:
+ # Install dependencies
+ pip install pdm
+ pdm install --no-self
+ ```
-```bash
-pre-commit install
-pre-commit install-hooks
-```
+3. **Frontend Setup**
+ ```bash
+ # Install frontend dependencies
+ npm install
+ ```
+
+4. **Enable Git Hooks**
+ ```bash
+ # Install pre-commit hooks
+ pre-commit install
+ pre-commit install-hooks
+ ```
+ We use the `pre-commit` framework to manage git hooks. This repository includes both standard checks (ruff, eslint, gitleaks) and custom local checks located in `.pre-commit-hooks/`.
+
+## Running the Application
+
+### Development Mode
+
+1. **Start the Backend**
+ ```bash
+ source .venv/bin/activate
+
+ # Option A: Using the installed entry point
+ ldr-web
-# Running the Application
+ # Option B: Using Python module directly
+ python -m local_deep_research.web.app
+ ```
-You can run the application directly using Python module syntax:
+2. **Start the Frontend** (in a new terminal)
+ ```bash
+ npm run dev
+ ```
+ Access the app at `http://localhost:5173`.
+
+### Development Environment Variables
+
+For local development and testing, you may want to configure these environment variables:
+
+| Variable | Default | Description |
+|----------|---------|-------------|
+| `LDR_DATA_DIR` | Platform default | Override data/database storage location |
+| `LDR_BOOTSTRAP_ALLOW_UNENCRYPTED` | `false` | Allow unencrypted database (dev only!) |
+| `CI` or `TESTING` | unset | Enables testing mode (bypasses some security checks) |
+
+> **Warning**: Never set `LDR_BOOTSTRAP_ALLOW_UNENCRYPTED=true` in production. User data will be stored unencrypted.
+
+### Docker (Production-like)
+
+To build and run the entire stack in Docker:
```bash
-# Activate the environment.
-pdm venv activate
-# You need to be in the src directory if you are not.
-cd src
-
-# Run the web interface
-python -m local_deep_research.web.app
-# Run the CLI version
-python -m local_deep_research.main
+docker build -t localdeepresearch/local-deep-research:dev .
+docker run -p 5000:5000 -e LDR_DATA_DIR=/data -v ldr_data:/data localdeepresearch/local-deep-research:dev
```
-# Building a Package
+## Building
+
+### Building a Package
To build a wheel and source distribution, simply run `pdm build`.
-# Building Frontend Assets
+### Building Frontend Assets
If you're developing from source and want to use the Web UI, you need to build the frontend assets:
@@ -62,3 +110,136 @@ npm run build
This builds the Vite frontend into `src/local_deep_research/web/static/dist/`.
> **Note:** pip users don't need this step - pre-built assets are included in the PyPI package.
+
+### Dependency Lockfile Management
+
+This project uses **PDM** with `pdm.lock` to pin exact dependency versions. If you see this warning during Docker builds:
+
+```
+WARNING: Lockfile hash doesn't match pyproject.toml, packages may be outdated
+```
+
+It means `pyproject.toml` has changed but `pdm.lock` hasn't been regenerated.
+
+**How to fix:**
+```bash
+pdm lock
+```
+
+Always commit `pdm.lock` alongside `pyproject.toml` changes to ensure reproducible builds.
+
+## Testing
+
+### Backend Tests (Pytest)
+
+We support two modes of backend testing:
+
+#### 1. Isolated Testing (No Server Required)
+This is the default and recommended way to run unit and integration tests. It uses Flask's `test_client` to mock the server.
+
+**How to run:**
+```bash
+source .venv/bin/activate
+# Run all isolated tests
+pytest tests/
+
+# Run specific API or Auth tests
+pytest tests/api_tests/
+pytest tests/auth_tests/
+```
+
+#### 2. Live System Testing (Requires Running Server)
+These tests make real HTTP requests to a running application instance.
+
+**Prerequisites:**
+1. Start the backend server in one terminal: `ldr-web` (or via Docker).
+2. Run the live test scripts in another terminal.
+
+**How to run:**
+```bash
+python tests/ui_tests/test_simple_research_api.py
+```
+
+### Frontend & E2E Tests (Puppeteer)
+We use `Puppeteer` for UI and End-to-End testing.
+
+**Prerequisites:**
+1. Navigate to the tests directory: `cd tests`
+2. Install test dependencies: `npm install`
+
+**How to run:**
+1. **Ensure the application is running** (locally on port 5000 or via Docker).
+2. Run the test suite:
+ ```bash
+ # Run all UI tests
+ node tests/ui_tests/run_all_ui_tests.js
+
+ # Run specific test
+ node tests/ui_tests/test_simple_auth.js
+ ```
+
+## Database Management
+
+### Backup & Restore
+Before testing changes, you may wish to backup your Local Deep Research data volume.
+
+**Create a Backup**
+```bash
+docker run --rm \
+ -v ldr_data:/from \
+ -v ldr_data-backup:/to \
+ debian:latest \
+ bash -c "cd /from ; tar -cf - . | (cd /to ; tar -xpf -)"
+```
+
+**Restore from Backup**
+
+*Warning: This overwrites existing data*
+```bash
+docker run --rm \
+ -v ldr_data:/target \
+ -v ldr_data-backup:/source \
+ debian:latest \
+ bash -c "rm -rf /target/* /target/.[!.]* ; \
+ cd /source ; tar -cf - . | (cd /target ; tar -xpf -)"
+```
+
+## Troubleshooting
+
+### SQLCipher Issues
+
+See [SQLCIPHER_INSTALL.md](SQLCIPHER_INSTALL.md#troubleshooting) for SQLCipher-related errors.
+
+### Permission Denied on Docker Volume
+
+**Error:** `PermissionError: [Errno 13] Permission denied: '/app/.config/...'`
+
+**Solution:** The volume may have been created with different ownership. Reset it:
+```bash
+docker volume rm ldr_data
+# Re-run the container to create a fresh volume
+```
+
+### Session Lost After Server Restart
+
+**Cause:** The application's secret key is used to sign session cookies.
+
+**Solution:** The secret key is automatically generated on first run and persisted to a `.secret_key` file in your data directory (controlled by `LDR_DATA_DIR`). Sessions are only lost if this file is deleted. If using Docker, ensure your data volume (`ldr_data:/data`) is persistent.
+
+### NoSettingsContextError in Background Threads
+
+**Error:** `NoSettingsContextError: No settings context available`
+
+**Cause:** Background threads don't have access to the Flask request context.
+
+**Solution:** This is handled automatically by the application. If you encounter this during development, ensure your LLM settings are configured via the web UI settings page. For CI/testing environments, the `LDR_TESTING_USE_FALLBACK_LLM=true` environment variable enables a mock LLM fallback.
+
+### PDM Lockfile Out of Sync
+
+**Error:** `Lockfile hash doesn't match pyproject.toml`
+
+**Solution:**
+```bash
+pdm lock
+git add pdm.lock
+```