Spaces:
Running
Running
A newer version of the Streamlit SDK is available: 1.61.0
metadata
title: SecureVault AI
emoji: π
colorFrom: blue
colorTo: gray
sdk: streamlit
sdk_version: 1.42.0
app_file: main.py
pinned: false
SecureVault AI: Privacy-Focused RAG System
A secure note-taking application implementing Retrieval-Augmented Generation (RAG) and Zero-Knowledge Encryption. This project demonstrates the integration of LLMs with local vector databases while maintaining high data privacy standards.
Live Demo: SecureVault AI on Hugging Face
Core Implementation Features
- Security Architecture: Implements a hybrid model using PBKDF2 for key derivation and AES-256 (Fernet) for symmetric encryption. All decryption happens strictly in-memory during session runtime.
- Vector Search: Uses FAISS and the
all-MiniLM-L6-v2transformer model for semantic indexing. This enables local retrieval without exposing sensitive data to external APIs. - Resource Monitoring: Built-in tracking for token consumption and API costs, paired with a feedback mechanism for monitoring RAG retrieval accuracy.
- Session Management: Automated "Zero-Knowledge" protection. If the Master PIN is lost, encrypted data is mathematically unrecoverable.
- Automated Security: Includes a session-based auto-lock engine that purges decrypted data from memory after 150 seconds of inactivity.
- Fail-Safe Recovery: Implements a hashed Recovery Key system for account resets while maintaining the mathematical integrity of encrypted data.
- Smart Exports: Unicode-compliant PDF and DOCX generation with specialized font embedding for multi-language support.
Engineering Challenges & Production Fixes
Deploying from a local Windows environment to Hugging Face (Debian Linux) required solving several infrastructure-level issues:
- Character Encoding Fixes: Resolved
UnicodeEncodeErrorin the PDF export module by implementing a preprocessing pipeline to handle non-Latin characters in a Linux environment. - Binary Serialization: Fixed
RuntimeErrorissues with Streamlit's download triggers by explicitly casting file buffers tobytesobjects to ensure consistent behavior across OS environments. - Version Compatibility: Refactored the UI components to maintain stability across Streamlit versions (specifically addressing the removal of deprecated
iconarguments in cloud deployments).
Technical Stack
- UI/UX: Streamlit (Session State & Custom CSS)
- AI/LLM: Google Gemini API, Sentence-Transformers, FAISS
- Security: Python
cryptographylibrary, SHA-256 hashing - Persistence: JSON-based local storage
Installation
Clone the repository:
git clone [https://github.com/mubi0613/SecureVault-AI.git](https://github.com/mubi0613/SecureVault-AI.git) cd SecureVault-AISetup environment: Ensure you have Python 3.9+ installed, then run:
pip install -r requirements.txtRun locally:
streamlit run main.py
Project Structure
SecureVault-AI/
- βββ main.py # Streamlit UI & Session Management
- βββ vault_logic.py # Cryptography, RAG, & File IO Logic
- βββ requirements.txt # Project Dependencies
- βββ .github/workflows/ # Auto-sync to Hugging Face
- βββ fonts/ # Custom fonts for cross-platform PDF rendering
- βββ README.md # Documentation
Architecture Diagram
graph TD
subgraph "User Interface (Streamlit)"
A[User Input] --> B{Vault Status}
end
subgraph "Security Layer"
B -- Unlocked --> C[AES-256 Decryption]
B -- Locked --> D[Access Denied]
end
subgraph "RAG Engine"
C --> E[FAISS Vector Index]
E --> F[Context Retrieval]
F --> G[Gemini Pro LLM]
end
G --> H[Final Secure Answer]
Important Note on Security
This tool follows Zero-Knowledge principles. Neither the developer nor the host can recover data if the Master PIN and Recovery Key are lost.
Usage Guide
- Initialize: Set your Master PIN and save your Recovery Key.
- Create Notes: Use the sidebar to add notes. Toggle "Mark as Secret" to apply AES-256 encryption.
- AI Search: Open the "Ask Your Vault" expander to query your notes using natural language.
- Manage: Edit or delete notes, and export them as PDF/DOCX for offline use.
- Monitor: Check the "AI Resources" section in the sidebar to view estimated token usage and costs.