Skip to documentation
Docs navigation
Docs/Development setup
Contributing

Development setup

Prepare a local MemoGrafter checkout with PostgreSQL, optional Redis, migrations, tests, and Studio.

Requirements

Node.js 18 or newer. The repository CI currently runs Node.js 20.
npm. The repository commits package-lock.json, so use npm for dependency changes.
Git and a GitHub account for the fork-and-pull-request workflow.
Docker Desktop or Docker Engine with Compose when using the repository-provided local services.
A compatible existing PostgreSQL installation with pgvector can be used instead of Docker.
Redis is required only when working on queue mode or the optional recall cache.

Fork and clone

Fork mayhemking007/memo-grafter on GitHub, clone your fork, and add the main repository as the upstream remote.

terminal
git clone https://github.com/<your-github-username>/memo-grafter.git
cd memo-grafter
git remote add upstream https://github.com/mayhemking007/memo-grafter.git
git remote -v

Install dependencies

terminal
npm install

Configure the environment

Copy the example environment file. Its default DATABASE_URL matches the PostgreSQL service in the repository's compose.yml.

If you use an existing database, replace the default URL. Leave REDIS_URL empty unless you are enabling queue mode or the recall cache; the environment variable alone does not activate either feature.

macOS or Linux
cp .env.example .env
PowerShell
Copy-Item .env.example .env

Start PostgreSQL only

PostgreSQL with pgvector is sufficient for normal development and the default unit tests. Start only the postgres service when you are not working on Redis-backed features.

terminal
docker compose up -d postgres

Start PostgreSQL and Redis

Start the complete contributor stack when testing queue mode, recall caching, or Redis integrations.

terminal
docker compose up -d

Inspect local services

Run the Redis command only when Redis is running; a healthy Redis service returns PONG.

terminal
docker compose ps
docker compose logs -f postgres
docker compose exec postgres pg_isready -U memografter -d memografter
docker compose exec postgres psql -U memografter -d memografter -c "SELECT extname FROM pg_extension WHERE extname IN ('vector', 'pgcrypto') ORDER BY extname;"
docker compose exec redis redis-cli ping

Build, initialize, and migrate

Initialization creates the project-local MemoGrafter configuration and schema reference. Migration enables vector and pgcrypto and creates or updates MemoGrafter-owned mg_* tables. It is safe to run again.

terminal
npm run build
npx memo-grafter init
npx memo-grafter migrate
npx memo-grafter doctor

Run the standard checks

terminal
npm run typecheck
npm run lint
npm run test:run

Start Studio

Start the local Studio after migration to inspect sessions, graphs, tables, and Prompt Preview. Studio is local development tooling and should not be exposed as a public application endpoint.

terminal
npx memo-grafter studio

Provider setup smoke tests

Provider smoke tests require a working DATABASE_URL and the matching provider API key. They call external APIs and may incur normal usage charges. Redis is not required.

terminal
# Requires OPENAI_API_KEY
npx tsx --env-file=.env tests/manual/setup-test/openai-smoke.ts

# Requires ANTHROPIC_API_KEY
npx tsx --env-file=.env tests/manual/setup-test/anthropic-smoke.ts

# Requires GEMINI_API_KEY
npx tsx --env-file=.env tests/manual/setup-test/gemini-smoke.ts

Reset local services

Stop the containers without removing local database or Redis data with docker compose down.

terminal
docker compose down

# Permanently remove local PostgreSQL and Redis data
docker compose down -v

Common setup failures

Unsupported Node.js version: install Node.js 18 or newer; use Node.js 20 to match CI.
Docker daemon not running: start Docker Desktop or Docker Engine before running Compose.
Port 5432 or 6379 already in use: stop the conflicting service or adjust the Compose mapping and matching environment URL.
PostgreSQL container unhealthy: inspect docker compose ps and docker compose logs postgres.
Missing .env or DATABASE_URL mismatch: copy .env.example and make the credentials, database, host, and port match the active PostgreSQL service.
Old credentials persist: existing Docker volumes retain their initialized database credentials even after compose.yml changes.
Studio reports an incomplete schema: run npx memo-grafter init, npx memo-grafter migrate, and npx memo-grafter doctor.
pgvector or pgcrypto unavailable: use the repository Compose service or install and enable the extensions on the selected PostgreSQL server.
Queue or cache tests fail without Redis: start the full Compose stack and explicitly configure the queue or cache.
Provider smoke test fails: confirm the corresponding API key is loaded and the selected model is available.