Skip to main content

Local-first context archival system with PNG serialization and AI indexing

Project description

ContextVault Banner

ContextVault Logo

๐ŸŒŒ ContextVault

FastAPI Python License: MIT

CI

ContextVault is a local-first archival system that turns any file or raw data (text/JSON) into PNG images.
It provides versioning, metadata, search, recovery, RBAC, audit logging, and retention โ€” all fully offline and now SaaS-ready.


โœจ Features

  • ๐Ÿ”„ Create Contexts
    • From files (/create_context/)
    • From raw text/JSON (/create_context/ with raw_data)
  • ๐ŸŽจ PNG Encoding โ†’ Store data inside PNG snapshots
  • ๐Ÿ“‚ Collections & Categories โ†’ Organize logically
  • ๐Ÿ•’ Snapshots & Versions โ†’ Track history over time
  • ๐Ÿ” Search
    • Keyword (filenames, metadata, raw text/JSON) โœ… SQLite inverted index (scales to 10k+ contexts)
    • Semantic (cosine TF-IDF) โœ… Stub in place (CPU-only, local JSON)
  • ๐Ÿงน Delete & Retention
    • Hard delete / conditional delete / soft delete (tombstones)
    • Expiry metadata (expires_at) + scheduled cleanup
    • โœ… Audit log of deletes & retention runs
  • ๐Ÿ“ฆ Compression Toggle (ZIP stored vs DEFLATE)
  • ๐Ÿ›ก๏ธ 100% Offline, Local-First (no cloud, no GPU required)
  • โšก Indexing Enhancements
    • Deterministic keyword & semantic search
    • JSON โ†’ SQLite migration script included
    • Health endpoint with deep consistency check (JSON vs SQLite)
  • ๐Ÿ”‘ Enterprise Features
    • RBAC roles + permission checks (JWT tokens, admin-only routes)
    • Retention policies with scheduler
    • โœ… Audit log (append-only, rotation + retention policies)
    • โœ… Admin-only endpoints for audit tail/export

๐Ÿ“… Project Status

  • v0.9 (Pilot Safe) โ†’ โœ… Core serialization + APIs
  • v1.0.0 Candidate (Now) โ†’ โœ… Search, RBAC, Audit, Retention, SaaS-readiness
  • v2.0 Candidate (Planned) โ†’ โš™๏ธ Extended tests & compliance hardening
  • v2.0 Final โ†’ ๐ŸŽฏ Production-ready release

For detailed requirement coverage, see docs/requirements_status.md.


๐Ÿš€ Roadmap

Hereโ€™s the planned evolution of ContextVault:

ContextVault Roadmap

  • P0 โ€“ Foundations โ†’ Entities, Contexts + Lineage, Logs & Indexes, Policy Validation, Migration
  • P1 โ€“ Reliability + Graph โ†’ Integrity Sweeps, Hybrid Search, DAG Linking, Master Export, Admin CLI
  • P2 โ€“ Governance + Compliance โ†’ Embeddings, Previews, Retention, Security, โœ… Audit rotation/export
  • P3 โ€“ Scale + GUI โ†’ Storage Interface, Sharding/Replication, Desktop Browser
  • Future Sprint โ†’ Multimedia previews, Incremental versioning, Multi-tenant foundation, Audit UI

๐Ÿš€ Quick Start

1. Install

git clone https://github.com/yourusername/contextvault.git
cd contextvault
pip install -r requirements.txt

Or install as a package:

pip install .

2. Run the API

uvicorn app.main:app --reload

Visit: ๐Ÿ‘‰ http://127.0.0.1:8000/docs


๐Ÿงฉ Example Usage

Create a Context from File

curl -X POST "http://127.0.0.1:8000/create_context/"   -F "upload=@myfile.pdf"   -F "compress=true"

Create a Context from Raw JSON

curl -X POST "http://127.0.0.1:8000/create_context/"   -H "Content-Type: application/json"   -d '{"raw_data": "{ \"project\": \"ContextVault\", \"status\": \"active\" }"}'

Decode a Context

curl -X POST "http://127.0.0.1:8000/decode_context_raw/"   -F "image=@data/ctx_abcd1234.png"

Search Contexts (Keyword)

curl "http://127.0.0.1:8000/search_index?q=Alpha"

Semantic Search (Stub)

curl "http://127.0.0.1:8000/search/semantic?q=project"

Admin Audit Tail (RBAC protected)

curl -H "Authorization: Bearer <admin-token>"   "http://127.0.0.1:8000/admin/audit/tail?lines=50"

๐Ÿ“‚ Project Structure

app/
  api/               # FastAPI routes
  core/              # serializer, indexer, metadata, audit, retention, scheduler
  main.py            # FastAPI entrypoint
data/
  index/             # keyword/semantic indexes (JSON + SQLite)
  extractions/       # decoded files
  ctx_*.png          # encoded contexts
  audit/             # audit logs (rotated)

๐ŸŸฅ Red Line โ€” What ContextVault Is Not

ContextVault solves a specific problem: a universal, portable, verifiable vault for small-to-medium mixed data.
It is not:

  • โŒ A Data Lake (not optimized for TBโ€“PB scale analytics)
  • โŒ A DAM/MAM (not Bynder/Adobe AEM)
  • โŒ A Dropbox/Google Drive alternative (no real-time collaboration)
  • โŒ A turnkey compliance platform โ€” but it now has audit + retention primitives
  • โŒ High-performance vector DB (designed CPU-only, offline)

๐Ÿ”ฌ Architecture

ContextVault Architecture

  1. Upload file or raw text/JSON
  2. Serializer โ†’ ZIP โ†’ PNG encoding
  3. Metadata โ†’ record (hash, size, entry_type, collection, etc.)
  4. Indexer โ†’ keyword (SQLite) + semantic embeddings
  5. Context Object โ†’ logical view of collections/categories
  6. Search/Decode โ†’ recover or query contexts
  7. Audit/Retention โ†’ track all actions + auto-clean expired entries

๐Ÿ’ก Use Case Examples

  • ๐Ÿ” Personal Knowledge Archiving โ†’ Save notes, PDFs, logs, retrieve with keyword search
  • ๐Ÿง  AI Knowledge Index โ†’ Archive raw text/JSON, index for offline retrieval
  • ๐Ÿ“Š Data Science & Research โ†’ Archive CSV/JSON, keep provenance & reproducibility
  • ๐Ÿฆ Enterprise Compliance โ†’ Archive sensitive files, audit logs, retention enforcement
  • ๐ŸŽจ Creative Projects โ†’ Store drafts/snippets, search by tags/collections
  • ๐Ÿ›ฐ๏ธ Field/Offline Environments โ†’ Encode IoT/geo data, decode & search later

๐Ÿ”ฎ Roadmap

  • GUI (Electron/Tkinter) for browsing snapshots
  • Offline LLM-powered semantic search (replace stub with FAISS/Annoy)
  • Batch upload โ†’ single snapshot
  • Multimedia previews (audio/video thumbnails) โš™๏ธ Future sprint
  • Master archive export
  • Multi-tenant foundation โš™๏ธ Future sprint

๐Ÿ› ๏ธ Development

Run tests

pytest

Dev server

uvicorn app.main:app --reload --port 9000

Code style

black app
isort app

๐Ÿค Contributing

  1. Fork the repo
  2. Create a feature branch (git checkout -b feat/my-feature)
  3. Commit (git commit -m "Add new feature")
  4. Push (git push origin feat/my-feature)
  5. Open a Pull Request ๐Ÿš€

โš–๏ธ License

MIT ยฉ 2024 [Suryanarayana Bollapragada]

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

contextvault-0.2.1.tar.gz (3.4 MB view details)

Uploaded Source

Built Distribution

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

contextvault-0.2.1-py3-none-any.whl (130.7 kB view details)

Uploaded Python 3

File details

Details for the file contextvault-0.2.1.tar.gz.

File metadata

  • Download URL: contextvault-0.2.1.tar.gz
  • Upload date:
  • Size: 3.4 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.8

File hashes

Hashes for contextvault-0.2.1.tar.gz
Algorithm Hash digest
SHA256 e6e93708796bccea3c5476569859842aef3e973337c63cb0baea7bb8f1760a1d
MD5 6fcf3b3ab024b6325f382ac7cc018881
BLAKE2b-256 dc17c097cd69de03044c73e5f688f46b44814685c12d0047d4a5304951c2f47f

See more details on using hashes here.

File details

Details for the file contextvault-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for contextvault-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 21ae476c19d00a8c883dad906dffb270ca486b8110e08b17957f69d8e3c596fe
MD5 6ef788d9e28a932e2886487d2679c13f
BLAKE2b-256 1de027e66e497610f6da7f1c81a0f9bbcd66a5365a632b1658794e51d9adc664

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