Thanks for your interest. BrainDB is a small, opinionated project — the bar is "does this make the memory system more useful for LLM agents?" If your change meets that bar, we'd love the PR.
Prerequisites: Docker Desktop (or any Docker Engine), Python 3.12, a Postgres 16 instance reachable from the container.
git clone <repo-url> braindb
cd braindb
cp .env.example .env
# edit .env — set DATABASE_URL, pick an LLM_PROFILE, fill in the matching API key or OpenAI-compatible endpoint
docker network create local-network # one-time; docker-compose expects this
docker compose up -d --build
curl http://localhost:8000/health # {"status":"ok","embeddings":true}For a native Python workflow (tests, IDE imports):
python -m venv .venv && source .venv/bin/activate # or `.venv\Scripts\activate` on Windows
pip install -e ".[dev]"pytest # full suite (needs the stack up)
pytest -k "not agent" # skip the live-LLM smoke tests
pytest tests/test_split_chunks.py # a single fileSee tests/README.md for what is and isn't covered.
LiteLLM does the heavy lifting — providers are selected by a prefix in the model string. To add a provider:
- Open
braindb/config.pyand add an entry to_LLM_PROFILES:"my_provider": { "model": "my_provider/vendor/model-id", # exact string LiteLLM expects "api_key_env": "MY_PROVIDER_API_KEY", },
- Add
MY_PROVIDER_API_KEY=to.env.exampleif the provider needs auth. - Add the env passthrough to
docker-compose.ymlunder theapiservice. OpenAI-compatible endpoints can useLLM_PROFILE=openai_compatibleplusAGENT_BASE_URL/AGENT_API_KEYvariables. - (Optional) Document the provider in the README and BRAINDB_GUIDE.
No other code changes required — the agent resolves model and key through settings.resolved_agent_model and settings.resolved_api_key, which read the active profile.
For a server you run yourself that speaks the OpenAI REST shape, the profile takes an optional third field, base_url, and uses LiteLLM's openai/ prefix to route through the OpenAI-compatible code path:
"vllm_workstation": {
"model": "openai/cyankiwi/gemma-4-31B-it-AWQ-4bit",
"api_key_env": "VLLM_API_KEY",
"base_url": "http://host.docker.internal:8002/v1",
},When base_url points at the Docker host (host.docker.internal), the api service in docker-compose.yml needs extra_hosts: ["host.docker.internal:host-gateway"] so the container can reach the host's loopback. The compose file in this repo already declares it.
If your server runs without auth, leave the matching *_API_KEY env var unset — settings.resolved_api_key falls back to the literal "EMPTY" for any profile that has a base_url, which keeps the OpenAI client happy.
BrainDB uses raw-SQL Alembic migrations (no ORM). Current revision is in alembic/versions/.
# Create a new revision file from a template
alembic revision -m "short description" --rev-id=005Edit the generated file's upgrade() and downgrade() functions with raw SQL. Migrations run automatically on container startup (see docker-compose.yml's command), but you can run them manually:
docker exec braindb_api alembic upgrade head
docker exec braindb_api alembic downgrade -1 # roll back one stepKeep migrations small and independently reversible where possible.
- Python 3.12. Prefer modern type hints (
list[str],str | None), f-strings, dataclasses or Pydantic models where appropriate. - Raw SQL via
psycopg2withRealDictCursor— no ORM, don't introduce one. - Sync
defendpoints; the only async path is the agent loop. - No internal "framework" abstractions; the project is small enough that clarity beats indirection.
- One logical change per PR. A feature + its tests in the same PR is fine; a feature plus unrelated cleanup is not.
- If your change touches the agent's toolset, the watcher pipeline, or the data model, update both:
BRAINDB_GUIDE.md— user-facing API referenceCLAUDE.md— project context for the LLM assistants working in this repo
- Add tests for any new HTTP endpoint, tool, or scorer. The suite should stay green.
Include:
- What you tried (exact command or curl, expected result)
- What happened instead (response body, docker logs, stack trace)
docker logs braindb_api --tail 100often has the real story
By contributing you agree your contributions are licensed under Apache 2.0 — the same license as the rest of the project. See LICENSE.