Spaces:
Running on Zero
Running on Zero
File size: 1,439 Bytes
4346a4c | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | # Database Architecture & Vector Storage
## Overview
The platform supports two vector storage modes:
- **Hosted Mode**: PostgreSQL + `pgvector` extension for scalable multi-tenant cloud deployments.
- **Standalone / Offline Mode**: Lightweight SQLite (`objects.db`) with stored L2 normalized embedding vectors and in-memory cosine similarity search.
---
## Schema Overview
```sql
-- Objects Table
CREATE TABLE objects (
id TEXT PRIMARY KEY,
name TEXT UNIQUE NOT NULL,
category TEXT NOT NULL,
description TEXT,
status TEXT DEFAULT 'active',
created_at TEXT NOT NULL,
updated_at TEXT NOT NULL
);
-- Reference Images Table
CREATE TABLE object_images (
id TEXT PRIMARY KEY,
object_id TEXT NOT NULL,
file_path TEXT NOT NULL,
image_hash TEXT,
created_at TEXT NOT NULL,
FOREIGN KEY (object_id) REFERENCES objects(id) ON DELETE CASCADE
);
-- Object Embeddings Table
CREATE TABLE object_embeddings (
id TEXT PRIMARY KEY,
object_id TEXT NOT NULL,
model_name TEXT NOT NULL,
model_version TEXT NOT NULL,
embedding TEXT NOT NULL, -- JSON Array [f32 x 512]
created_at TEXT NOT NULL,
FOREIGN KEY (object_id) REFERENCES objects(id) ON DELETE CASCADE
);
```
---
## Database Backup & Export
Users can export their custom taught object library as a ZIP archive via the web UI or API endpoint:
```
my-object-library.zip
├── database.db
└── manifest.json
```
|