Skip to content

dhilanfye34/HavenAI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

65 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

HavenAI

AI-powered personal cybersecurity agent that learns your behavior and protects you from threats.

Project Overview

HavenAI is a multi-agent AI system that monitors your computer for security threats. Unlike traditional antivirus that relies on signatures, HavenAI learns what's "normal" for you and alerts you when something unusual happens. It combines a native desktop application with a cloud-backed web dashboard, keeping raw telemetry private on-device while syncing only critical alerts to the cloud.

Key Features

  • Multi-Agent Monitoring β€” Five specialized agents (File, Process, Network, Email Inbox, Message/Notification) each watch a different surface of your system
  • Perceive-Analyze-Act Pattern β€” Every agent continuously observes, scores risk, and acts on findings in autonomous loops
  • Correlated Threat Detection β€” The Coordinator cross-references findings across agents (e.g., a downloaded file being immediately executed)
  • Local-First Storage β€” All raw telemetry is stored in SQLite on-device with a 7-day rolling window; only medium+ severity alerts sync to the cloud
  • Email Inbox Monitoring β€” Connects to your email via IMAP app passwords with auto-detected provider settings (Gmail, Outlook, Yahoo, iCloud) to scan for phishing
  • AI Chat Assistant β€” Conversational security assistant with full context of all active agents, powered by OpenAI
  • Real-Time Dashboard β€” Live file events, process spawns, network connections, health metrics, and alert feed
  • Notification Channels β€” Email, SMS (Twilio), and automated voice call alerts based on configurable severity thresholds
  • Privacy-First β€” IMAP and account credentials are encrypted on-device via the OS keychain (macOS Keychain / Windows DPAPI / libsecret); raw telemetry (file events, processes, connections) stays in local SQLite; only medium+ severity alerts (with the context needed to explain them) sync to the cloud
  • Modern UI β€” Glassmorphism design system with WebGL shader backgrounds, built with Tailwind CSS and lucide-react

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                           CLOUD                                      β”‚
β”‚                                                                      β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”‚
β”‚   β”‚   Web App    β”‚   β”‚   Backend    β”‚   β”‚   Database   β”‚           β”‚
β”‚   β”‚  (Next.js)   β”‚   β”‚  (FastAPI)   β”‚   β”‚ (PostgreSQL) β”‚           β”‚
β”‚   β”‚   Vercel     β”‚   β”‚   Render     β”‚   β”‚   Render     β”‚           β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β”‚
β”‚         β”‚                    β”‚                  β”‚                    β”‚
β”‚         β”‚           Alerts, Auth, Devices       β”‚                   β”‚
β”‚         β”‚            medium+ severity           β”‚                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
          β”‚              HTTPS β”‚                   β”‚
          β”‚                    β”‚                   β”‚
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         β”‚          USER'S COMPUTER               β”‚                   β”‚
β”‚         β–Ό                    β–Ό                                        β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚   β”‚                  HavenAI Desktop App (Electron)              β”‚   β”‚
β”‚   β”‚                                                              β”‚   β”‚
β”‚   β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚   β”‚
β”‚   β”‚   β”‚  File    β”‚ β”‚ Process  β”‚ β”‚ Network  β”‚ β”‚ Email Inbox  β”‚  β”‚   β”‚
β”‚   β”‚   β”‚  Agent   β”‚ β”‚  Agent   β”‚ β”‚  Agent   β”‚ β”‚    Agent     β”‚  β”‚   β”‚
β”‚   β”‚   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚   β”‚
β”‚   β”‚        β”‚             β”‚            β”‚              β”‚           β”‚   β”‚
β”‚   β”‚        β–Ό             β–Ό            β–Ό              β–Ό           β”‚   β”‚
β”‚   β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚   β”‚
β”‚   β”‚   β”‚              Coordinator (Orchestrator)              β”‚   β”‚   β”‚
β”‚   β”‚   β”‚  - Correlates findings across agents                 β”‚   β”‚   β”‚
β”‚   β”‚   β”‚  - Writes to SQLite first, syncs medium+ to cloud   β”‚   β”‚   β”‚
β”‚   β”‚   β”‚  - Manages agent lifecycles                          β”‚   β”‚   β”‚
β”‚   β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚   β”‚
β”‚   β”‚                          β”‚                                   β”‚   β”‚
β”‚   β”‚                          β–Ό                                   β”‚   β”‚
β”‚   β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚   β”‚
β”‚   β”‚   β”‚          SQLite (~/.havenai/havenai.db)               β”‚  β”‚   β”‚
β”‚   β”‚   β”‚   events | alerts | agent_snapshots | 7-day prune     β”‚  β”‚   β”‚
β”‚   β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚   β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Project Structure

HavenAI/
β”œβ”€β”€ webapp/                          # Next.js web application (Vercel)
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ page.tsx                 # Landing page with shader backgrounds
β”‚   β”‚   β”œβ”€β”€ about/                   # About page
β”‚   β”‚   β”œβ”€β”€ features/                # Features page
β”‚   β”‚   β”œβ”€β”€ download/                # Desktop app download page
β”‚   β”‚   β”œβ”€β”€ login/                   # Authentication page
β”‚   β”‚   β”œβ”€β”€ dashboard/               # Main command center
β”‚   β”‚   β”‚   β”œβ”€β”€ page.tsx             # Dashboard with Overview/Runtime/Agents tabs
β”‚   β”‚   β”‚   β”œβ”€β”€ components/          # TopBar, HealthScore, QuickStats, AlertFeed,
β”‚   β”‚   β”‚   β”‚                        # ChatPanel, RuntimeInspector, AgentPanel,
β”‚   β”‚   β”‚   β”‚                        # SetupPanel, ResourceMonitor, etc.
β”‚   β”‚   β”‚   β”œβ”€β”€ hooks/               # useAlerts, useAgentStatus, useChat,
β”‚   β”‚   β”‚   β”‚                        # useSetupPreferences
β”‚   β”‚   β”‚   └── services/            # Mock data providers (web fallback)
β”‚   β”‚   └── components/              # Shared: Navbar, Footer, shader backgrounds
β”‚   β”‚                                # (ShaderBackground, SmokeBackground,
β”‚   β”‚                                #  DottedSurface, WaveShader, etc.)
β”‚   β”œβ”€β”€ tailwind.config.js
β”‚   └── package.json
β”‚
β”œβ”€β”€ desktop-app/
β”‚   β”œβ”€β”€ electron/                    # Electron shell
β”‚   β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”‚   β”œβ”€β”€ main.ts              # Main process: window, tray, IPC handlers,
β”‚   β”‚   β”‚   β”‚                        # python-bridge, electron-store
β”‚   β”‚   β”‚   └── preload.ts           # Context bridge API exposed to renderer
β”‚   β”‚   β”œβ”€β”€ renderer/                # Next.js static export for Electron
β”‚   β”‚   β”‚   └── app/
β”‚   β”‚   β”‚       β”œβ”€β”€ page.tsx          # Root (auth check -> dashboard)
β”‚   β”‚   β”‚       β”œβ”€β”€ login/page.tsx    # Desktop login
β”‚   β”‚   β”‚       └── globals.css       # Desktop design system
β”‚   β”‚   └── package.json
β”‚   β”‚
β”‚   └── agent/                       # Python agent system
β”‚       └── havenai/
β”‚           β”œβ”€β”€ agents/
β”‚           β”‚   β”œβ”€β”€ base.py           # Abstract Agent with perceive/analyze/act
β”‚           β”‚   β”œβ”€β”€ coordinator.py    # Orchestrator, alert routing, cloud sync
β”‚           β”‚   β”œβ”€β”€ file_agent.py     # Watchdog-based file monitoring
β”‚           β”‚   β”œβ”€β”€ process_agent.py  # psutil process monitoring
β”‚           β”‚   β”œβ”€β”€ network_agent.py  # Network connection monitoring
β”‚           β”‚   β”œβ”€β”€ email_inbox_agent.py  # IMAP phishing detection
β”‚           β”‚   └── message_agent.py  # Notification channel router
β”‚           β”œβ”€β”€ api/
β”‚           β”‚   └── client.py         # Backend API client (auth, alerts, heartbeat)
β”‚           └── storage/
β”‚               └── local_db.py       # SQLite local storage (events, alerts, prune)
β”‚
β”œβ”€β”€ backend/                         # FastAPI backend (Render)
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ main.py                  # App entry, CORS, router registration
β”‚   β”‚   β”œβ”€β”€ config.py                # Environment configuration
β”‚   β”‚   β”œβ”€β”€ security.py              # JWT token handling
β”‚   β”‚   β”œβ”€β”€ schemas.py               # Pydantic request/response models
β”‚   β”‚   β”œβ”€β”€ dependencies.py          # Auth dependency injection
β”‚   β”‚   β”œβ”€β”€ db/
β”‚   β”‚   β”‚   β”œβ”€β”€ database.py          # SQLAlchemy engine + session
β”‚   β”‚   β”‚   └── models.py            # User, Device, Alert, UserSetupPreferences
β”‚   β”‚   β”œβ”€β”€ routers/
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.py              # Register, login, token refresh
β”‚   β”‚   β”‚   β”œβ”€β”€ devices.py           # Device registration, heartbeat
β”‚   β”‚   β”‚   β”œβ”€β”€ alerts.py            # Alert CRUD
β”‚   β”‚   β”‚   β”œβ”€β”€ chat.py              # AI chat endpoint (OpenAI)
β”‚   β”‚   β”‚   β”œβ”€β”€ setup.py             # User preferences (monitoring toggles, phones)
β”‚   β”‚   β”‚   β”œβ”€β”€ downloads.py         # Desktop app download links
β”‚   β”‚   β”‚   └── health.py            # Health check
β”‚   β”‚   └── services/
β”‚   β”‚       └── notifications.py     # SendGrid email, Twilio SMS/voice calls
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── tests/
β”‚
β”œβ”€β”€ .env                             # Root environment variables
└── README.md

Tech Stack

Layer Technology Hosting
Web Frontend Next.js 14, Tailwind CSS, Three.js (shaders) Vercel
Desktop App Electron, Next.js (static export) GitHub Releases (.dmg + .exe)
Agent System Python 3, psutil, watchdog, imaplib Runs locally
Local Storage SQLite (via Python sqlite3) ~/.havenai/havenai.db
Backend API FastAPI, SQLAlchemy, Pydantic Render
Cloud Database PostgreSQL Render
Auth JWT (access + refresh tokens) β€”
Notifications SendGrid (email), Twilio (SMS/voice) β€”
AI Chat OpenAI GPT API β€”
IPC Electron IPC + stdin/stdout JSON (Python bridge) β€”

Agent System

Each agent follows the perceive-analyze-act pattern in its own thread:

Agent What it monitors Key libraries
FileAgent File creates/modifies in Downloads and Desktop watchdog
ProcessAgent New process spawns, suspicious parent-child chains psutil
NetworkAgent Active TCP connections, suspicious ports/destinations psutil, socket
EmailInboxAgent Unread emails for phishing indicators via IMAP imaplib
MessageAgent Routes alerts to configured notification channels β€”

The Coordinator runs the main loop, processes alerts from all agents, performs cross-agent correlation (e.g., downloaded file + immediate execution = critical threat), and manages data flow between local SQLite and the cloud backend.

Data Storage Strategy

Data Where Retention
Raw file/process/network events SQLite on device 7-day rolling window
All alerts (any severity) SQLite on device 7-day rolling window
Medium/high/critical alerts PostgreSQL (cloud) Indefinite
User accounts, devices, preferences PostgreSQL (cloud) Indefinite
IMAP credentials electron-store (device only) Until user clears
Agent state snapshots SQLite on device 7-day rolling window

Getting Started

Prerequisites

  • Node.js 18+
  • Python 3.11+
  • PostgreSQL (for backend, or use Render)

Environment Variables

Create a .env in the project root:

# Backend
DATABASE_URL=postgresql://user:pass@host:5432/havenai
SECRET_KEY=your-jwt-secret
OPENAI_API_KEY=sk-...

# Notifications (optional)
SENDGRID_API_KEY=SG...
SENDGRID_FROM_EMAIL=alerts@yourdomain.com
TWILIO_ACCOUNT_SID=AC...
TWILIO_AUTH_TOKEN=...
TWILIO_FROM_NUMBER=+1...

# Frontend
NEXT_PUBLIC_API_URL=http://localhost:8000

Running Locally

Backend:

cd backend
pip install -r requirements.txt
uvicorn app.main:app --reload

Web App:

cd webapp
npm install
npm run dev

Desktop App (development):

cd desktop-app/electron
npm install
npm run dev

Python Agents (standalone):

cd desktop-app/agent
pip install -r requirements.txt
python -m havenai.agents.coordinator

Packaging the Desktop App

cd desktop-app/electron
npm run package:mac
npm run package:win
npm run package:linux
# Output: release/HavenAI-0.1.0-arm64.dmg
# Output: release/HavenAI-Setup-0.1.0.exe
# Output: release/HavenAI-0.1.0.AppImage

For tagged releases, keep these versions aligned:

  • desktop-app/electron/package.json (version)
  • backend/app/routers/downloads.py (APP_VERSION)
  • Git tag (v<version>)

Deployment

Service Platform URL
Web App Vercel Configured via webapp/vercel.json
Backend API Render Web service with uvicorn app.main:app
Database Render PostgreSQL (internal URL for backend)
Desktop App GitHub Releases .dmg (macOS), .exe (Windows), and .AppImage (Linux) uploaded per release

Team

License

This project is part of ECE 481/482 Senior Design at the University of Miami.