@ouim/vectoriadb-server 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +209 -0
  2. package/package.json +5 -1
package/README.md ADDED
@@ -0,0 +1,209 @@
1
+ # VectoriaDB SDK
2
+
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![Version](https://img.shields.io/badge/version-1.0.0-blue.svg)]()
4
+
5
+ A lightweight, JavaScript-only client/server SDK for [VectoriaDB](https://github.com/agentfront/vectoriadb). Forward vector database operations from client applications to a centralized server instance with ease.
6
+
7
+ > ⚠️ **Not for large production deployments.** This SDK is primarily intended for small applications, prototypes, demos, and hobby projects where quick setup and simplicity are priorities. For mission‑critical or large-scale production use, consider a hardened, production-grade solution.
8
+
9
+ ---
10
+
11
+ ## Features
12
+
13
+ - **Mirror API**: Client SDK replicates the full VectoriaDB API surface.
14
+ - **Remote Execution**: Perform heavy vector operations on the server; keep your client light.
15
+ - **Smart Filtering**: Send JavaScript functions as filters; they are automatically serialized and executed on the server.
16
+ - **Streaming Support**: Smoothly handle large result sets with built-in chunking.
17
+ - **Robust Connection**: Automatic reconnection, request queueing, and configurable timeouts.
18
+ - **Collection Helpers**: High-level abstractions for simplified document management.
19
+
20
+ ## Project Structure
21
+
22
+ ```text
23
+ vectoriadb-sdk/
24
+ ├── server/ # Server implementation (hosts VectoriaDB instance)
25
+ └── client/ # Client implementation (forwards requests via Socket.io)
26
+ ```
27
+
28
+ ## Quick Start
29
+
30
+ ### 1. Start the Server
31
+
32
+ The server requires `vectoriadb` to be installed.
33
+
34
+ ```bash
35
+ cd server
36
+ npm install
37
+ npm start
38
+ ```
39
+
40
+ **Basic Server Configuration (`server/index.js`):**
41
+
42
+ ```javascript
43
+ import VectoriaDBServer from '@ouim/vectoriadb-server'
44
+
45
+ const server = new VectoriaDBServer({
46
+ port: 3001,
47
+ cors: ['http://localhost:3000'],
48
+ // apiKey: 'your-secure-key' // Optional authentication
49
+ })
50
+
51
+ await server.listen()
52
+ ```
53
+
54
+ ### 2. Connect the Client
55
+
56
+ ```bash
57
+ npm install @ouim/vectoriadb-client
58
+ ```
59
+
60
+ **Basic Usage:**
61
+
62
+ ```javascript
63
+ import VectoriaDB from '@ouim/vectoriadb-client'
64
+
65
+ const db = new VectoriaDB({
66
+ serverUrl: 'http://localhost:3001',
67
+ // apiKey: 'your-secure-key'
68
+ })
69
+
70
+ await db.initialize()
71
+
72
+ // Add documents
73
+ await db.add('doc1', 'Vector databases are awesome!', { category: 'tech' })
74
+
75
+ // Search with semantic similarity
76
+ const results = await db.search('vector database', { topK: 5 })
77
+ console.log(results)
78
+ ```
79
+
80
+ ---
81
+
82
+ ## Advanced Search & Filtering
83
+
84
+ ### Remote Function Filtering
85
+
86
+ One of the most powerful features is the ability to filter results server-side using client-defined functions:
87
+
88
+ ```javascript
89
+ const results = await db.search('cloud computing', {
90
+ filter: metadata => metadata.category === 'tech' && metadata.priority > 5,
91
+ threshold: 0.7, // Strict similarity matching
92
+ })
93
+ ```
94
+
95
+ ### Collection-Style API
96
+
97
+ Use `insert` and `query` for a more traditional database feel:
98
+
99
+ ```javascript
100
+ await db.insert('my-collection', [
101
+ { text: 'Hello World', metadata: { author: 'Alice' } },
102
+ { text: 'Goodbye World', metadata: { author: 'Bob' } },
103
+ ])
104
+
105
+ const bobDocs = await db.query('my-collection', 'farewell', {
106
+ filter: m => m.author === 'Bob',
107
+ })
108
+ ```
109
+
110
+ ---
111
+
112
+ ## ⚙️ Configuration
113
+
114
+ ### Server Options
115
+
116
+ | Option | Description | Default |
117
+ | :---------------- | :------------------------------------- | :--------- |
118
+ | `port` | Server listening port | `3001` |
119
+ | `host` | Server host address | `0.0.0.0` |
120
+ | `apiKey` | Optional key for client authentication | `null` |
121
+ | `cors` | Allowed origins (array) | `[]` (All) |
122
+ | `streamChunkSize` | Max results per chunk for streaming | `500` |
123
+
124
+ ### Client Options
125
+
126
+ | Option | Description | Default |
127
+ | :--------------- | :--------------------------- | :----------- |
128
+ | `serverUrl` | URL of the VectoriaDB server | **Required** |
129
+ | `apiKey` | Authentication key | `null` |
130
+ | `requestTimeout` | API request timeout in ms | `30000` |
131
+
132
+ ---
133
+
134
+ ## Large Datasets & Streaming
135
+
136
+ The SDK automatically handles large result sets by chunking data on the server and assembling it on the client. This prevents memory issues and payload limits when retrieving thousands of vectors.
137
+
138
+ - **Automatic assembly**: You don't need to worry about chunks; the `Promise` resolves only when all data has arrived.
139
+ - **Configurable limits**: Set `streamChunkSize` on the server to tune the chunking behavior.
140
+
141
+ ## Connection Resilience
142
+
143
+ Built for real-world networks, the client includes:
144
+
145
+ - **Offline Queueing**: Requests made while the connection is down are queued and sent automatically upon reconnection.
146
+ - **Heartbeat & Health Checks**: Monitors connection status to ensure reliable delivery.
147
+ - **Configurable Timeouts**: Each request can have its own timeout, or use a global default.
148
+
149
+ ---
150
+
151
+ ## Security Note
152
+
153
+ > [!WARNING] Filter functions passed from the client are serialized and evaluated on the server using `new Function()`. **Never** expose the server to untrusted clients without strict network controls or additional sandboxing.
154
+
155
+ ---
156
+
157
+ ## Docker Integration
158
+
159
+ When deploying with Docker, ensure you persist the database state:
160
+
161
+ ```yaml
162
+ services:
163
+ vectoriadb-server:
164
+ image: node:18
165
+ # ... other config
166
+ volumes:
167
+ - vectoria-data:/app/server/.cache/vectoriadb
168
+
169
+ volumes:
170
+ vectoria-data:
171
+ ```
172
+
173
+ ## Best Practices
174
+
175
+ - **Intended use**: Not recommended for large production systems — best suited for prototypes, demos, and hobby projects where quick setup matters.
176
+ - **Batching**: Use `addMany` instead of repeated `add` calls for efficiency.
177
+ - **Timeouts**: Adjust `requestTimeout` for large-scale operations.
178
+ - **Shutdown**: Always call `db.close()` on the client and `server.close()` on the server for graceful termination.
179
+
180
+ ---
181
+
182
+ ## FAQ
183
+
184
+ **Q: Do I need `vectoriadb` on the client?**
185
+ A: No! The client only needs `socket.io-client`. It's designed to be used in browsers or lightweight Node environments.
186
+
187
+ **Q: How does the server-side filtering work?**
188
+ A: The client SDK stringifies your filter function. The server then reconstructs it using `new Function()`. This is why the filter must be self-contained and not rely on variables outside its scope.
189
+
190
+ ---
191
+
192
+ ## Future Roadmap
193
+
194
+ - [ ] **JWT Authentication**: Add more robust auth options.
195
+ - [ ] **Data Encryption**: Support for end-to-end encryption of metadata.
196
+ - [ ] **Multi-Instance**: Support for multiple VectoriaDB instances managed by one server.
197
+ - [ ] **Python Client**: A compatible SDK for Python applications.
198
+
199
+ ---
200
+
201
+ ## Credits
202
+
203
+ This SDK builds on and integrates with [VectoriaDB](https://github.com/agentfront/vectoriadb). See the Vectoria product website at [https://agentfront.dev/vectoria](https://agentfront.dev/vectoria) for more information and additional resources.
204
+
205
+ ---
206
+
207
+ ## License
208
+
209
+ MIT © 2026 VectoriaDB SDK Authors
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ouim/vectoriadb-server",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -16,5 +16,9 @@
16
16
  },
17
17
  "engines": {
18
18
  "node": ">=18"
19
+ },
20
+ "repository": {
21
+ "type": "git",
22
+ "url": "git+https://github.com/thezem/vectoriadb-sdk.git"
19
23
  }
20
24
  }