Skip to main content

A session-scoped self-adaptive database framework for logical object-oriented data management.

Project description

ChiralDB

ChiralDB is an autonomous, session-scoped database framework that transparently bridges the gap between Relational (SQL) and Document (JSONB) paradigms over a single PostgreSQL instance.

Instead of defining strict schemas or maintaining a separate MongoDB cluster for unstructured data, ChiralDB completely abstracts storage placement, schema evolution, and SQL JOINs away from the developer.

📚 Read the Full Documentation


⚡ Key Features

  • Zero Schema Definition: Ingest raw JSON. ChiralDB uses Shannon Entropy to autonomously infer data types and split repeating arrays into highly normalized SQL tables.
  • Hybrid Storage Engine: Flat, stable scalars go to SQL columns. Drift-prone, heavily nested, or sparse data gracefully spills over into JSONB automatically.
  • Logical Session Isolation: Data is physically stored in the same tables, but logically separated by session_id.
  • ACID Transactions: No Two-Phase Commit (2PC) overhead. By utilizing PostgreSQL's JSONB alongside relational tables with begin_nested(), we achieve perfect Atomicity and Isolation across paradigms.
  • Built-in Dashboard: Ships with a React SPA to visualize your logical schemas and execute CRUD operations.

🛠️ Quick Start

Installation

pip install chiral-db

Start the Server & Dashboard

ChiralDB ships with a built-in FastAPI server and React Dashboard. Just provide your PostgreSQL credentials in a .env file and run:

chiral serve --port 8000

Open http://localhost:8000 in your browser to access the interactive Query Executor.

Programmatic Usage

You can use ChiralDB natively in your Python asyncio applications. You don't write DDL. You don't write SQL. You just use data.

import asyncio
from chiral.client import ChiralClient

async def main():
    async with ChiralClient("postgresql+asyncpg://user:pass@localhost:5432/db") as db:
        
        # 1. Ingest arbitrary, schema-less data
        await db.ingest(
            session_id="experiment_01", 
            data={
                "username": "devansh", 
                "sensors": [{"type": "temp", "val": 22}, {"type": "humid", "val": 40}]
            }
        )
        
        # 2. Query it logically. ChiralDB handles the SQL Joins and JSONB unpacking!
        result = await db.query({
            "operation": "read",
            "session_id": "experiment_01",
            "select": ["username", "sensors.val"],
            "filters": [{"field": "sensors.val", "op": "gt", "value": 20}]
        })
        
        print(result["rows"])

if __name__ == "__main__":
    asyncio.run(main())

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.


### Step 3: Update PyPI with the new README
Because PyPI packages are immutable, you must bump the version number to push the new README to the website.
1. Open `pyproject.toml` and change `version = "1.0.0"` to `version = "1.0.1"`.
2. Rebuild and publish:
   ```bash
   uv build
   uv publish

(Go check your package on PyPI right after this—it will look incredible!)

Step 4: Push to GitHub & Deploy the Website

MkDocs has a magical built-in command that automatically compiles your documentation into HTML and pushes it to a special gh-pages branch on your GitHub repository. GitHub then hosts this branch for free!

1. Update repo_url in mkdocs.yml Open mkdocs.yml and update the repo_url at the top to point to your actual GitHub repository:

repo_url: https://github.com/your-username/chiral-db

2. Commit and Push your code to GitHub:

git add .
git commit -m "feat: Finalize PyPI package, README, and MkDocs setup"
git push origin main

3. Deploy the Website: Run this single command in your terminal:

uv run mkdocs gh-deploy --force

(This command builds the site and pushes it to the gh-pages branch on GitHub).

4. Turn on GitHub Pages:

  1. Go to your repository on GitHub.com.
  2. Click on the Settings tab.
  3. Click on Pages in the left sidebar.
  4. Under "Build and deployment", set the Source to Deploy from a branch.
  5. Under "Branch", select gh-pages and click Save.

Wait about 60 seconds, and your website will be live at https://<your-username>.github.io/chiral-db/! Make sure to update the placeholder link in your README.md to point to the real URL.

Let me know when the site is live! You have officially completed the entire lifecycle of a production-grade software project!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

chiral_db-1.0.1.tar.gz (450.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

chiral_db-1.0.1-py3-none-any.whl (56.0 kB view details)

Uploaded Python 3

File details

Details for the file chiral_db-1.0.1.tar.gz.

File metadata

  • Download URL: chiral_db-1.0.1.tar.gz
  • Upload date:
  • Size: 450.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for chiral_db-1.0.1.tar.gz
Algorithm Hash digest
SHA256 d4098f8987a0b9206e2959326d797689f92ff8c7ad0247a40dd5126077daa688
MD5 0ab5bee78cc6e0a0c0b8ec3600b20b66
BLAKE2b-256 142640d04a6d68f128c0ce6b9b2d2d6184759b9644cc0819da833d83a01f2657

See more details on using hashes here.

File details

Details for the file chiral_db-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: chiral_db-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 56.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for chiral_db-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9f6c166472484485a34f512d304de2b2560ccebd1b2262546d3cb5c85460e910
MD5 1724c6ea37c3cb616e992c8a978a657b
BLAKE2b-256 6a39b78e09e461883ada771b40ec825f49445dd6cf0d9a7dd2cfd779ad3bf9ca

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page