Metadata-Version: 2.4
Name: chimeradb
Version: 0.1.0
Summary: Knowledge graph + vector search + SQL analytics in SQLite
Home-page: https://github.com/codimusmaximus/chimeradb
Author: Alexander Leirvåg
Author-email: Alexander Leirvåg <alexander@prismeta.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/codimusmaximus/chimeradb
Project-URL: Documentation, https://github.com/codimusmaximus/chimeradb/tree/main/docs
Project-URL: Repository, https://github.com/codimusmaximus/chimeradb
Project-URL: Issues, https://github.com/codimusmaximus/chimeradb/issues
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Topic :: Database
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy>=1.20.0
Requires-Dist: sentence-transformers>=2.0.0
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: black>=23.0.0; extra == "dev"
Dynamic: author
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python

# ChimeraDB

**Knowledge graph + vector search + SQL analytics in SQLite.**

For LLM apps that need structured memory: RAG, AI agents, question answering, recommendations.

[![Python 3.8+](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)

[Examples](examples/) • [Docs](docs/)

---

## Quick Start

```bash
pip install chimeradb
```

```python
from chimeradb import KnowledgeGraph

# Auto-embeddings enabled by default
kg = KnowledgeGraph("my.db")

# Create nodes with Cypher
kg.cypher("CREATE (d:Document {text: 'LLMs are transforming software'})")
kg.cypher("CREATE (d:Document {text: 'RAG combines retrieval with generation'})")

# Or bulk insert with SQL
import json
kg.execute(
    "INSERT INTO graph_nodes (labels, properties) VALUES (?, ?)",
    (json.dumps(["Document"]), json.dumps({"text": "Vector databases enable semantic search"}))
)
kg.commit()

# Semantic search
results = kg.search("how do AI apps work?", top_k=3)
for r in results:
    print(f"{r['properties']['text'][:50]}: {r['similarity']:.1%}")

# Graph traversal
network = kg.traverse("node_id", direction="outgoing", max_depth=3)

# SQL analytics
stats = kg.query("SELECT COUNT(*) FROM graph_nodes")
```

## What You Get

- **Semantic search**: Embeddings auto-generated on every insert
- **Graph queries**: Cypher for patterns, SQL for complex analytics
- **Zero infrastructure**: Single SQLite file, runs anywhere
- **Any language**: Pure SQL extensions work with Python, Node.js, Go, Rust, etc.

## Installation

### Python Package

```bash
pip install chimeradb
```

Or from source:
```bash
git clone https://github.com/codimusmaximus/chimeradb.git
cd chimeradb
./setup.sh && source .venv/bin/activate
```

### SQL Only (Any Language)

```bash
# macOS ARM64
mkdir -p extensions
curl -L https://github.com/agentflare-ai/sqlite-graph/releases/latest/download/libgraph.dylib -o extensions/libgraph.dylib
curl -L https://github.com/sqliteai/sqlite-vector/releases/latest/download/vector-macos-arm64.dylib -o extensions/vector.dylib
```

Then load in any SQLite client:
```sql
.load extensions/libgraph
.load extensions/vector
```

Use from Python, Node.js, Go, Rust, Java, C++, or any language with SQLite support.

## Python API

```python
from chimeradb import KnowledgeGraph

# Create database
kg = KnowledgeGraph("my_graph.db")  # Or ":memory:"

# Optional: disable embeddings or use different model
# kg = KnowledgeGraph("my.db", embedding_model=None)
# kg = KnowledgeGraph("my.db", embedding_model="text-embedding-3-small")

# Add nodes
kg.add_entity(
    entity_id="person1",
    labels=["Person"],
    properties={"name": "Alice", "bio": "AI researcher"},
    embed_field="bio"
)

# Add relationships
kg.add_relationship(
    from_id="person1",
    to_id="company1",
    relation_type="WORKS_AT",
    properties={"since": 2020}
)

# Semantic search
results = kg.search("machine learning expert", top_k=10)

# Graph traversal
network = kg.traverse("person1", direction="outgoing", max_depth=3)

# SQL queries
data = kg.query("""
    SELECT json_extract(properties, '$.name') as name
    FROM graph_nodes
    WHERE json_extract(properties, '$.role') = 'Engineer'
""")

kg.close()
```

## Examples

- **[00_sql_only.sql](examples/00_sql_only.sql)**: Pure SQL usage (no Python)
- **[01_getting_started.py](examples/01_getting_started.py)**: Python API basics
- **[02_basic.py](examples/02_basic.py)**: Semantic search + graph traversal + SQL analytics
- **[03_advanced.py](examples/03_advanced.py)**: Research paper recommendations with graph analysis

## Performance

M1 MacBook Pro:
- **Inserts**: 10,000+ nodes/second
- **Vector search**: < 1ms for 100k embeddings
- **Storage**: ~500 bytes per node (with 384-dim embeddings)

Good for:
- Prototypes and MVPs
- Small-to-medium apps (millions of nodes)
- Edge AI and on-device intelligence

Not designed for:
- Billions of nodes
- Distributed systems
- High-write concurrent workloads

## Requirements

- Python 3.8+
- macOS (ARM64 or Intel) - Linux and Windows coming soon
- `sentence-transformers` (auto-installed by setup.sh)

## Documentation

- [Getting Started Guide](docs/GETTING_STARTED.md)
- [Cypher Guide](docs/CYPHER_GUIDE.md)
- [Labels Guide](docs/LABELS_GUIDE.md)
- [Limitations](docs/LIMITATIONS.md)

## Tech Stack

Built on:
- [SQLite](https://sqlite.org) - World's most deployed database
- [sqlite-vector](https://github.com/sqliteai/sqlite-vector) - Vector similarity search
- [sqlite-graph](https://github.com/agentflare-ai/sqlite-graph) - Cypher queries

## License

MIT - see [LICENSE](LICENSE)
