{"id":28996626,"url":"https://github.com/observedobserver/vecal","last_synced_at":"2025-06-25T05:10:47.276Z","repository":{"id":295005492,"uuid":"793182341","full_name":"ObservedObserver/vecal","owner":"ObservedObserver","description":"vector database in browser based on indexeddb","archived":false,"fork":false,"pushed_at":"2025-06-17T03:12:03.000Z","size":330,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-17T04:21:56.911Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://vecal-docs.vercel.app","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ObservedObserver.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-04-28T16:55:04.000Z","updated_at":"2025-06-17T03:12:07.000Z","dependencies_parsed_at":"2025-05-23T05:39:01.403Z","dependency_job_id":null,"html_url":"https://github.com/ObservedObserver/vecal","commit_stats":null,"previous_names":["observedobserver/vecal"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ObservedObserver/vecal","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ObservedObserver%2Fvecal","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ObservedObserver%2Fvecal/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ObservedObserver%2Fvecal/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ObservedObserver%2Fvecal/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ObservedObserver","download_url":"https://codeload.github.com/ObservedObserver/vecal/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ObservedObserver%2Fvecal/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261808072,"owners_count":23212694,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-25T05:10:46.528Z","updated_at":"2025-06-25T05:10:47.262Z","avatar_url":"https://github.com/ObservedObserver.png","language":"TypeScript","readme":"# vecal\n\n![NPM Version](https://img.shields.io/npm/v/vecal)\n\nVector database in browser based on IndexedDB.\n\n## Features\n\n- CRUD operations for vectors\n- Similarity search using multiple distance metrics\n- Optional LSH based index with approximate nearest neighbour (ANN) search\n\n## Installation\n\n```bash\nnpm install vecal\n# or\nyarn add vecal\n```\n\n## Basic Usage\n\n```ts\nimport { VectorDB } from 'vecal';\n\nconst db = new VectorDB({ dbName: 'example', dimension: 3 });\n\nconst id = await db.add(new Float32Array([0.9, 0.1, 0.1]), { label: 'Apple' });\n\nconst results = await db.search(new Float32Array([0.85, 0.2, 0.15]), 2);\nconsole.log(results);\n```\n\n### Using the LSH index\n\n```ts\nawait db.buildIndex(8);\nconst ann = await db.annSearch(new Float32Array([0.85, 0.2, 0.15]), 2);\n```\n\n### Closing the database\n\n```ts\nawait db.close();\n```\n\n## API Reference\n\n### `new VectorDB(config: VectorDBConfig)`\nCreates a database instance. `config` fields:\n- `dbName` – name of the IndexedDB database.\n- `dimension` – length of the stored vectors.\n- `storeName` – optional object store name (defaults to `\"vectors\"`).\n- `distanceType` – optional default distance metric.\n- `minkowskiP` – power parameter when using Minkowski distance (default `3`).\n\n### `add(vector, metadata?) =\u003e Promise\u003cstring\u003e`\nAdd a vector with optional metadata. Returns the generated id.\n\n### `get(id) =\u003e Promise\u003cVectorEntry | undefined\u003e`\nRetrieve a stored entry.\n\n### `update(id, update) =\u003e Promise\u003cvoid\u003e`\nPartially update an entry.\n\n### `delete(id) =\u003e Promise\u003cvoid\u003e`\nRemove an entry from the database.\n\n### `buildIndex(numHashes?) =\u003e Promise\u003cvoid\u003e`\nBuild an LSH index from all entries. `numHashes` controls the number of hyperplanes (default `10`).\n\n### `search(query, k?, distanceType?) =\u003e Promise\u003cSearchResult[]\u003e`\nExact similarity search. `distanceType` can be `\"cosine\"`, `\"l2\"`, `\"l1\"`, `\"dot\"`, `\"hamming\"`, or `\"minkowski\"`.\n\n### `annSearch(query, k?, radius?, distanceType?) =\u003e Promise\u003cSearchResult[]\u003e`\nApproximate nearest neighbour search using the LSH index. The index is built lazily when first needed. `distanceType` uses the same options as `search`.\n\n### `close() =\u003e Promise\u003cvoid\u003e`\nClose the underlying IndexedDB connection.\n\n### Types\n- `VectorDBConfig`\n- `VectorEntry`\n- `SearchResult`\n- `DistanceType`\n\n## Tutorial: indexing text with OpenAI embeddings\nThe `src/main.ts` file in this repository demonstrates how to build a small Hacker News search tool. The high level steps are:\n1. obtain an OpenAI API key;\n2. fetch items to index;\n3. convert each title to an embedding using the API;\n4. create a `VectorDB` with the embedding dimension and store each vector;\n5. run searches with `db.search` or `db.annSearch`.\n\nRefer to the code for a full example.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobservedobserver%2Fvecal","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fobservedobserver%2Fvecal","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fobservedobserver%2Fvecal/lists"}