Spaces:
Runtime error
Runtime error
File size: 8,181 Bytes
ed0b977 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 | ---
title: Swift Query
emoji: π
colorFrom: blue
colorTo: indigo
sdk: docker
pinned: false
license: apache-2.0
short_description: Privacy-Preserving Clinical Intelligence System
---
# SwiftQuery: Secure Medical AI with CyborgDB
**A Privacy-First Healthcare OS validating Encrypted Vector Search.**
---
> [!CAUTION]
> **OS REQUIREMENT: LINUX OR WSL (Windows Subsystem for Linux)**
> due to the **"CyborgDB Effect"**, this application **CANNOT** run on native Windows.
> The core `cyborgdb-core` encryption libraries currently require a Linux environment.
> Users on Windows **MUST** use WSL2 (Ubuntu 20.04+ recommended).
---
## Project Details
SwiftQuery is a secure, AI-powered healthcare operating system designed to demonstrate the power of encrypted vector search in a medical context. It provides a platform for managing patient data, interacting with AI assistants, and ensuring that sensitive patient information remains private and secure, even during complex AI-powered searches.
The backend is built with Python and Flask, leveraging MongoDB for data storage. The AI capabilities are powered by Google's Gemini models and the Langchain framework.
The core of SwiftQuery's security model is **CyborgDB**.
## Features
### Core Features
* **Secure User Authentication:** Separate login and registration for doctors, patients, and assistants.
* **Role-Based Dashboards:** Customized dashboards for each user type, providing access to relevant information and actions.
* **AI-Powered Clinical Summarization:** Utilizes generative AI to create concise summaries of patient records.
* **Intelligent Patient Search:** Enables searching for patients based on symptoms, diagnoses, or other clinical notes.
### Focus on CyborgDB: Encrypted Vector Search
CyborgDB is central to SwiftQuery's mission of providing a privacy-first healthcare platform. Here's how it's used:
* **Encryption at the Core:** Instead of performing similarity searches on raw, unencrypted patient data, SwiftQuery uses CyborgDB to encrypt the vector embeddings of patient information. This means that sensitive data is never exposed in its raw form during AI-powered search operations.
* **Secure Similarity Search:** When a doctor searches for patients with similar symptoms, the query is also encrypted and sent to CyborgDB. The similarity search is performed on the *encrypted* data, ensuring that the underlying patient information remains confidential.
* **Privacy-Preserving AI:** By integrating CyborgDB, SwiftQuery can leverage the power of AI for tasks like patient similarity search without compromising patient privacy. The AI models interact with encrypted data, not the raw, sensitive information.
* **"The CyborgDB Effect":** This project highlights the "CyborgDB Effect," where the use of advanced encryption technologies necessitates a specific development environment (Linux/WSL) to ensure the highest level of security. This is a deliberate design choice to prioritize security and privacy.
## π Getting Started
### 1. Prerequisites
- **OS:** Linux (Ubuntu/Debian) or Windows + WSL2.
- **Python:** 3.9+
- **MongoDB:** A URI for a MongoDB Instance (Local or Atlas).
- **API Keys:**
- `GOOGLE_AI_API_KEY`: For Gemini 1.5 Pro/Flash.
- `CYBORGDB_API_KEY`: For Encrypted Vector Search.
### 2. Installation
1. **Clone the Repository**
```bash
git clone https://github.com/Darshanroy/SwiftQuery.git
cd SwiftQuery
```
2. **Set Up Virtual Environment**
```bash
python3 -m venv .venv
source .venv/bin/activate
```
3. **Install Dependencies**
*Note: This step will fail on native Windows due to CyborgDB dependencies.*
```bash
pip install -r requirements.txt
```
### 3. Configuration
Create a `.env` file in the root directory:
```ini
# Core Secrets
SECRET_KEY=your_development_secret_key
MONGO_URI=mongodb+srv://<user>:<password>@cluster.mongodb.net/?retryWrites=true&w=majority
# AI & Encrypted Search
GOOGLE_AI_API_KEY=your_gemini_api_key
CYBORGDB_API_KEY=your_cyborgdb_api_key
# Optional: Port Configuration
PORT=8092
```
### 4. Running the Application
Use the provided helper script to start the server:
```bash
chmod +x devserver.sh
./devserver.sh
```
Or run manually with Python:
```bash
python3 main.py
```
Server will start at `http://localhost:8092`.
---
## File Structure
```
.
βββ GEMINI.md
βββ README.md
βββ ai_agents
β βββ clinical_summarizer.py
β βββ patient_rag.py
β βββ rag_similar_patient.py
βββ app.log
βββ db.py
βββ devserver.sh
βββ documentation
β βββ backend_ai.md
β βββ backend_general.md
β βββ vectordb_integration.md
βββ global_error.txt
βββ main.py
βββ patient.py
βββ requirements.txt
βββ static
β βββ script.js
βββ templates
β βββ admin
β βββ assistant
β βββ doctor
β βββ index.html
β βββ patient
βββ tests
β βββ audit_assistants.py
β βββ check_env.py
β βββ create_chat_session_collection.py
β βββ debug_assistant_routes.py
β βββ debug_dashboard_error.py
β βββ debug_direct.py
β βββ debug_dns_python.py
β βββ debug_patient_search.py
β βββ debug_patients.py
β βββ debug_render.py
β βββ debug_simple.py
β βββ debug_uri.py
β βββ debug_uri_2.py
β βββ extract_data.py
β βββ init_db.py
β βββ inspect_db.py
β βββ inspect_patient.py
β βββ reset_db_schema.py
β βββ reset_password.py
β βββ test_google_dns.py
β βββ test_render_assistant.py
β βββ verify_fix.py
β βββ verify_history.py
β βββ verify_login.py
β βββ verify_recording.py
β βββ verify_search_mode.py
β βββ verify_view.py
β βββ verify_workflow.py
βββ utils
βββ blueprints
β βββ admin.py
β βββ ai.py
β βββ assistant.py
β βββ auth.py
β βββ chat.py
β βββ doctor.py
β βββ enhancer.py
β βββ history.py
β βββ patient.py
βββ db
β βββ db.py
β βββ helper.py
βββ logging
βββ logger.py
βββ logger_setup.py
```
## File Details
| File/Folder | Description |
|---|---|
| `main.py` | The main entry point for the Flask application. It initializes the app, registers blueprints, and starts the server. |
| `requirements.txt` | Lists all the Python dependencies for the project. |
| `.env` | Configuration file for storing secrets and environment variables like API keys and database URIs. |
| `devserver.sh` | A shell script for convenience to run the development server. |
| `ai_agents/` | Contains the core AI logic. This includes scripts for clinical summarization, patient RAG, and similar patient search using encrypted vector search. |
| `utils/blueprints/` | This directory contains the Flask Blueprints, which organize the application's routes into modular components (e.g., `auth.py`, `patient.py`, `doctor.py`). |
| `templates/` | Contains all the HTML templates for the web interface, organized by user roles (admin, assistant, doctor, patient). |
| `static/` | Holds static assets such as CSS, JavaScript (`script.js`), and images. |
| `tests/` | Contains all the testing, debugging, and utility scripts for the project. |
| `db.py` | Includes functions for interacting with the MongoDB database. |
| `patient.py` | Defines the `Patient` class and related functions for patient data management. |
## β οΈ Known Limitations
- **Windows Support:** Not available. Requires WSL or Linux VM.
- **Memory Usage:** The local embedding model (`all-MiniLM-L6-v2`) requires ~500MB RAM.
- **SRV Timeouts:** On some WSL configurations, DNS issues may occur. The app includes a patch to force Google DNS (`8.8.8.8`).
---
**Built for the CyborgDB Hackathon.**
*Demonstrating Encrypted Vector Search in Healthcare.*
|