Skip to content

feat: make SQLite database path configurable via environment variable #43

Description

@charannyk06

Priority: P3 — Low

Problem

The SQLite database path is hardcoded in src/server/server.ts as ~/.chainreview/chainreview.db. This prevents:

  • Running multiple isolated ChainReview instances on one machine
  • Using an in-memory database for testing (':memory:')
  • Custom storage locations for enterprise setups
  • CI environments where home directory writes may be restricted

Solution

Add environment variable support:

const dbPath = process.env.CHAINREVIEW_DB_PATH ?? 
  path.join(os.homedir(), '.chainreview', 'chainreview.db');

For testing, set CHAINREVIEW_DB_PATH=:memory: to use SQLite in-memory mode:

const dbPath = process.env.CHAINREVIEW_DB_PATH === ':memory:' 
  ? ':memory:' 
  : resolveDbPath(process.env.CHAINREVIEW_DB_PATH);

Add to .env.example:

# Custom path for ChainReview database (default: ~/.chainreview/chainreview.db)
# Use ':memory:' for in-memory database (useful for testing)
CHAINREVIEW_DB_PATH=

Update VS Code extension settings schema to expose this as chainreview.database.path.

Acceptance Criteria

  • CHAINREVIEW_DB_PATH env var overrides default path
  • ':memory:' value works for in-memory testing
  • VS Code setting for database path
  • Unit tests use in-memory database
  • .env.example updated

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions