Local-first context archival system with PNG serialization and AI indexing
Project description
๐ ContextVault
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/withraw_data)
- From files (
- ๐จ 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:
- 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
- Upload file or raw text/JSON
- Serializer โ ZIP โ PNG encoding
- Metadata โ record (hash, size, entry_type, collection, etc.)
- Indexer โ keyword (SQLite) + semantic embeddings
- Context Object โ logical view of collections/categories
- Search/Decode โ recover or query contexts
- 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
- Fork the repo
- Create a feature branch (
git checkout -b feat/my-feature) - Commit (
git commit -m "Add new feature") - Push (
git push origin feat/my-feature) - Open a Pull Request ๐
โ๏ธ License
MIT ยฉ 2024 [Suryanarayana Bollapragada]
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file contextvault-0.2.0.tar.gz.
File metadata
- Download URL: contextvault-0.2.0.tar.gz
- Upload date:
- Size: 3.4 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4be1bac89ef6fd1adc6040d7cd4b63e0a219269fde7b4c7783619eb538f0e630
|
|
| MD5 |
8b6606caf11d4698a175188c699ccf12
|
|
| BLAKE2b-256 |
46c8aeecf10f23c3d1d287c44c6f13ea4512099aebe21975e17ca6ec005b95eb
|
File details
Details for the file contextvault-0.2.0-py3-none-any.whl.
File metadata
- Download URL: contextvault-0.2.0-py3-none-any.whl
- Upload date:
- Size: 129.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f98529628d19ba14bcf72bf628c766b847fcfd288e072794157ad12ff820e467
|
|
| MD5 |
0dbdcfbae9cdf77230f7ab12744bb428
|
|
| BLAKE2b-256 |
67ac42ac3b0ff636c99a5f6f1bab016491e1e43b543ff064e039aa0395470ef9
|