Project Info
Inspiration
Healthcare is rapidly adopting AI tools, cloud platforms, and smart medical devices. While this improves efficiency and patient outcomes, it also introduces a serious compliance risk: sensitive patient data can leave the hospital network in seconds. A simple AI prompt containing a name, diagnosis, or SSN can unintentionally create a HIPAA violation. We were inspired by a core question: What if hospital networks could defend themselves automatically? Instead of relying on post-incident audits and manual reviews, we wanted to build a system that enforces privacy in real time, at the network layer, before sensitive data ever leaves the building. That vision became ShadowGuard.
What it does
ShadowGuard is a real-time AI-powered PII firewall for hospitals. It sits inline as a Layer 7 proxy between internal devices and the internet. ShadowGuard: Intercepts outgoing HTTP/HTTPS traffic Reconstructs payloads (JSON, form data, AI prompts) Detects Protected Health Information (PHI/PII) Redacts or tokenizes sensitive data in transit Alerts administrators for high-risk incidents Instead of blocking workflows, ShadowGuard intelligently modifies packets before forwarding them, ensuring compliance without disrupting clinical operations.
How we built it
We designed ShadowGuard as a modular network-layer system. 1️⃣ Packet Interception We implemented a proxy-based Man-in-the-Middle architecture to route outbound traffic through ShadowGuard for inspection. 2️⃣ Payload Reconstruction We parse and reconstruct application-layer content from packets to analyze real data rather than raw bytes. 3️⃣ Hybrid PII Detection We combined: Regex-based pattern detection (SSNs, phone numbers, MRNs) Named Entity Recognition (NER) LLM-based contextual classification 4️⃣ Inline Redaction Engine Instead of blocking traffic, we dynamically rewrite payloads: Before After 5️⃣ Real-Time Alerting High-severity events trigger logging, alerts, and escalation workflows.
Challenges we ran into
🔐 HTTPS Decryption Intercepting HTTPS traffic requires certificate injection and careful trust-chain handling, especially sensitive in medical environments. We used the MITMProxy to handle this. ⚡ Latency vs Accuracy LLMs provide contextual detection but introduce delay. We engineered a layered system where fast deterministic checks run first, and AI scoring is applied selectively. 🎯 False Positives Over-redaction can break workflows. We prioritized precision and designed conservative thresholds to maintain usability. ⚖️ Compliance Considerations Modifying packets inline raises auditing and legal questions. We ensured every action is logged and traceable for compliance review.
Accomplishments we're proud of
Successfully implemented real-time packet interception and rewriting Built a hybrid AI + deterministic PII detection engine Reduced latency through layered scoring Designed a system that preserves workflow instead of blocking traffic Created a proactive privacy enforcement model rather than reactive logging Most importantly, we demonstrated that network-layer AI governance is possible in real time.
What we learned
Security is most powerful when implemented at the network layer. AI systems must include deterministic fallbacks for reliability. Compliance solutions must balance protection with usability. Real-world healthcare systems require transparency and auditability. We also learned that privacy enforcement should not rely solely on user behavior, it should be architected into the system itself.
What's next
Optimizing detection models for lower latency Training lightweight on-device classifiers for IoT medical devices Integrating automated voice-based incident response Building adaptive policy learning for hospital-specific compliance rules Exploring zero-trust deployment architectures Our long-term vision is to make ShadowGuard the foundation for AI-native compliance infrastructure in healthcare. Privacy. Enforced in Transit.
ShadowGuard
Healthcare Shadow AI Detection & Governance System | TreeHacks 2026
ShadowGuard intercepts HTTPS traffic to AI services (ChatGPT, Claude, Gemini), detects Protected Health Information (PHI) using NLP, redacts it in real-time, and provides a cybersecurity-themed governance dashboard with live WebSocket updates and automated voice alerts.
Architecture
┌──────────────┐
Browser/App ───► │ mitmproxy │ ──► AI Service (OpenAI, Anthropic, Google)
│ + addon │
└──────┬───────┘
│ POST /api/events
┌──────▼───────┐
│ FastAPI │ ──► VAPI Voice Calls (high-risk alerts)
│ Backend │
└──────┬───────┘
│ WebSocket + REST
┌──────▼───────┐
│ React │
│ Dashboard │
└──────────────┘
| Component | Stack | Port |
|---|---|---|
| Proxy | mitmproxy + Python addon | 8080 |
| Backend | FastAPI, PostgreSQL 14, psycopg2 | 8000 |
| Dashboard | React 18, Vite, D3.js, TailwindCSS | 3000 |
| Voice Alerts | VAPI + GPT-5.2 + ElevenLabs | - |
Quick Start
1. Start the backend + dashboard + database
docker compose up --build
This starts PostgreSQL, the FastAPI backend, and the React dashboard.
2. Seed demo data
curl -X POST http://localhost:8000/api/seed
3. Open the dashboard
Navigate to http://localhost:3000
4. Start the proxy (separate terminal)
# Activate the conda environment
source /path/to/anaconda3/etc/profile.d/conda.sh && conda activate shadow
# Run mitmproxy with the ShadowGuard addon
mitmproxy -s shadowguard_addon.py
5. Route traffic through the proxy
export HTTPS_PROXY=http://localhost:8080
export HTTP_PROXY=http://localhost:8080
export SSL_CERT_FILE=~/.mitmproxy/mitmproxy-ca-cert.pem
Or launch a proxied Chrome:
# macOS
open -na "Google Chrome" --args \
--proxy-server="http://localhost:8080" \
--user-data-dir="/tmp/chrome-proxy-test"
VAPI Voice Alerts
When a high-risk PHI exposure is detected (severity critical/high, risk score >= 70), ShadowGuard can automatically call the responsible staff via VAPI to notify them.
Setup
- Create a VAPI account at vapi.ai
- Configure a phone number and an assistant on the VAPI dashboard
- The assistant should use template variables:
{{service}},{{phi_types}},{{risk_score}},{{action_taken}},{{timestamp}},{{department}} - Add your credentials to
.env:
VAPI_ENABLED=true
VAPI_API_KEY=your-private-key
VAPI_PHONE_NUMBER_ID=your-vapi-phone-id
VAPI_ASSISTANT_ID=your-assistant-id
ALERT_PHONE_NUMBER=+1XXXXXXXXXX
CALL_COOLDOWN_SECONDS=300
How it works
- Calls are only triggered when
VAPI_ENABLED=true— safe to run without it - Seeding demo data does not trigger real calls (only inserts fake call records)
- Per-IP cooldown prevents call spam (default: 5 minutes)
- Test a call manually:
curl -X POST http://localhost:8000/api/calls/test
Environment Variables
| Variable | Required | Default | Description |
|---|---|---|---|
DATABASE_URL | Yes (Docker sets it) | postgresql://shadowguard:shadowguard@localhost:5432/shadowguard | PostgreSQL connection string |
VAPI_ENABLED | No | false | Enable voice call alerts |
VAPI_API_KEY | For calls | - | VAPI private API key |
VAPI_PHONE_NUMBER_ID | For calls | - | VAPI phone number ID |
VAPI_ASSISTANT_ID | For calls | - | Pre-configured VAPI assistant ID |
ALERT_PHONE_NUMBER | For calls | - | Phone number to receive alert calls |
CALL_COOLDOWN_SECONDS | No | 300 | Minimum seconds between calls per source IP |
API Endpoints
| Method | Endpoint | Description |
|---|---|---|
GET | /api/health | Health check |
POST | /api/events | Ingest event from mitmproxy |
GET | /api/events | List events (supports limit, offset, severity, service, status) |
GET | /api/events/:id | Get single event |
PATCH | /api/events/:id/status | Update event status (active/mitigated/resolved) |
GET | /api/stats | Dashboard aggregate statistics |
POST | /api/seed | Seed database with demo data |
GET | /api/calls | List VAPI call records |
GET | /api/calls/stats | Voice call aggregate stats |
POST | /api/calls/test | Trigger a test VAPI call |
WS | /api/ws | WebSocket for real-time updates |
Testing Interception
Terminal test (with proxy running)
# Clean request (no PHI) — should be logged
curl -X POST https://api.openai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-fake-test-key" \
-d '{"model": "gpt-4", "messages": [{"role": "user", "content": "How do I sort a list in Python?"}]}'
# PHI request — should be detected and redacted
curl -X POST https://api.openai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-fake-test-key" \
-d '{"model": "gpt-4", "messages": [{"role": "user", "content": "Summarize notes for patient John Doe, SSN: 423-91-8847, DOB: 03/15/1958. Diagnosis E11.9 Type 2 Diabetes."}]}'
Browser test
- Launch Chrome with proxy:
--proxy-server="http://localhost:8080" - Navigate to
http://mitm.itand install the mitmproxy CA certificate - Go to
https://chatgpt.comand type a message - Watch the dashboard update in real-time
Project Structure
ShadowGuard/
├── shadowguard_addon.py # mitmproxy addon — intercepts, detects PHI, posts to backend
├── phi_redactor.py # PHI detection engine (Presidio + regex fallback)
├── docker-compose.yml # PostgreSQL + backend + dashboard
├── .env # VAPI and other environment variables
├── backend/
│ ├── main.py # FastAPI app, routes, WebSocket manager
│ ├── database.py # PostgreSQL connection pool, table creation
│ ├── models.py # Pydantic request/response models
│ ├── seed.py # Demo data generator
│ ├── vapi_caller.py # VAPI voice call integration
│ ├── requirements.txt # Python dependencies
│ └── Dockerfile
└── dashboard/
├── src/
│ ├── App.jsx # Main app with state management + WebSocket
│ ├── components/
│ │ ├── StatsCards.jsx # Summary stat cards
│ │ ├── ThreatFeed.jsx # Live threat feed sidebar
│ │ ├── TrafficTimeline.jsx # D3 traffic timeline chart
│ │ ├── RiskHeatmap.jsx # D3 risk heatmap
│ │ ├── NetworkGraph.jsx # D3 force-directed network graph
│ │ ├── AuditLog.jsx # Sortable/paginated audit table
│ │ └── RedactionViewer.jsx # Side-by-side original/redacted modal
│ ├── hooks/
│ │ └── useWebSocket.js # WebSocket hook with auto-reconnect
│ └── lib/
│ └── api.js # REST API client functions
├── package.json
└── Dockerfile
Troubleshooting
"SSL certificate verify failed"
Install/trust the mitmproxy CA cert: sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain ~/.mitmproxy/mitmproxy-ca-cert.pem
"Connection refused" on port 8000
Make sure docker compose up is running and the backend container is healthy.
VAPI calls failing with 403
Ensure User-Agent header is set (already handled in code). Check your VAPI API key is the private key, not the public one.
VAPI calls failing with SSL errors The backend Docker container disables SSL verification for outbound VAPI calls to avoid certificate issues with proxies.
Dashboard not updating Check the WebSocket connection indicator in the header. The dashboard auto-reconnects if the connection drops.
Analysis
View
Metric
- 3
Figures cover GitHub contributors during the hackathon window. A co-authored commit counts in full for each author, so per-member totals add up to more than the whole-team figures.
Technology
- CSSIn code
- FastAPIIn code
- HTMLIn code
- JavaScriptIn code
- PythonIn code
- ReactIn code
- Tailwind CSSIn code
- Node.jsClaimed
- OpenAIClaimed
7 of 9 appear in the indexed code. 2 claimed on Devpost could not be matched to code, which may simply mean the tool leaves no trace in the repository.
AI coding agents
No AI coding agent signals were found in this repository.
Detected from committed agent config files and commit authorship. Absence of a signal is not proof an agent was unused.
Codebase size
Source size
150 KB
Source files
29
Counts recognized source files only; vendored directories, binaries and lockfiles are excluded, so this is smaller than the repository on disk.
Repository
shamanthak-hegde/ShadowGuard
35 files · 252 KB · @ 3fd2d98
Structure
Interface
10 files · 29%Screens, components and styles rendered to the user.
Application logic
14 files · 40%Domain rules, services and shared utilities.
Supporting
Layers are inferred from where files sit in the tree, not from reading the code. A project that names its directories unconventionally will read oddly here — open the file browser to check anything the diagram implies.
Languages
- Python51%
- JavaScript36%
- Markdown6%
- CSS4%
- Shell2%
- YAML1%
- Other (1)0%
Share of indexed source by file size. Binary and vendored files are excluded.
Dependencies
dashboard/package.json
npm · 8- d3
- react
- react-dom
- +5 more
backend/requirements.txt
pypi · 6- certifi
- fastapi
- psycopg2-binary
- pydantic
- python-dotenv
- uvicorn[standard]
Declared in the repository’s manifests at the indexed commit. A declared package is not proof it is used, and runtime dependencies are listed first.
This project’s features have not been analysed yet.
Export this project's context (description, README, evidence, key source files) to chat with an AI agent elsewhere.