Skip to content

Saurabhkhire/akash

Repository files navigation

Threat Detection System

AI-powered threat detection system for the Akash Hackathon Agent Track. Runs entirely on Akash infrastructure with AkashML for LLM inference.

Features

  • Autonomous Agent: Continuously runs on Akash; maintains persistent state and survives restarts
  • AkashML Integration: Uses hosted LLMs (Llama 3.3 70B) for threat analysis, suggestions, and danger zone assessment
  • Real-world actions: Email/SMS notifications, emergency service escalation, API orchestration
  • Danger Zone Tracking: Marks areas with recurring incidents as dangerous (LLM-assisted)
  • Dashboard: React UI for case history, ongoing cases, reporting threats
  • State persistence: SQLite DB; fault-tolerant across redeploys

Requirements

  • Python 3.11 or 3.12 (Pydantic has no pre-built wheels for Python 3.14 yet; 3.14 will try to compile Rust and fail.)
  • On Windows with multiple Pythons, use a venv with 3.12:
    py -3.12 -m venv .venv
    .venv\Scripts\activate
    pip install -r backend/requirements.txt

Quick Start

Local Development

# Backend (from project root)
cd akash
# Use Python 3.11 or 3.12 (see Requirements above)
pip install -r backend/requirements.txt
cp .env.example .env   # Add AKASHML_API_KEY
uvicorn backend.main:app --reload --host 0.0.0.0 --port 8000

# Dashboard (new terminal)
cd dashboard
npm install && npm run dev

Open http://localhost:5173 (dashboard) and http://localhost:8000/docs (API).

Configure Dashboard API URL

For production, set VITE_API_URL when building the dashboard:

VITE_API_URL=https://your-akash-deployment.com npm run build

Deploy on Akash

  1. Build and push Docker image:

    docker build -t YOUR_DOCKERHUB_USER/threat-detection:1.0 .
    docker push YOUR_DOCKERHUB_USER/threat-detection:1.0
  2. Update deploy.yaml with your image name.

  3. Deploy via Akash Console:

    • Connect wallet (Keplr/Leap)
    • Deploy → Upload/use deploy.yaml
    • Set env vars: AKASHML_API_KEY, etc.
    • Accept bid and deploy
  4. Get AkashML API key from chatapi.akash.network

API

Endpoint Method Description
/threats POST Report new threat
/threats GET List threats (filter: status, place, risk)
/threats/{id} GET Get threat details
/threats/{id} PATCH Update status
/danger-zones GET List dangerous areas
/contacts GET List area contacts
/health GET Health check
/agent/state GET Agent persistent state

Report Threat Example

curl -X POST http://localhost:8000/threats \
  -H "Content-Type: application/json" \
  -d '{
    "description": "person is choking someone",
    "threat_percent": 85,
    "risk": "high",
    "place": "Room 411",
    "contact_name": "John Doe",
    "contact_email": "john@example.com",
    "contact_phone": "+1234567890",
    "send_email": true,
    "send_sms": true
  }'

Architecture

[Threat Input] → [FastAPI] → [Agent: process_threat]
                                ├── AkashML (analyze, suggestions, danger zone)
                                ├── Similar cases lookup
                                ├── Email/SMS (Resend, Twilio)
                                └── Emergency webhook (high risk)
[Agent Loop] → Heartbeat + state persistence (fault-tolerant)
[Dashboard] → Case history, danger zones, report form

Hackathon Compliance

  • Akash Infrastructure: App runs on Akash providers
  • AkashML: Hosted models via chatapi.akash.network
  • Autonomous Agent: Background agent loop, stateful, fault-tolerant
  • Real-world Actions: Email, SMS, emergency webhook, API calls
  • Persistent State: SQLite + AgentState table
  • No centralized fallback: Core logic on Akash

Environment

Variable Required Description
AKASHML_API_KEY Yes From chatapi.akash.network
RESEND_API_KEY No Email (Resend)
TWILIO_* No SMS (Twilio)
EMERGENCY_SERVICE_WEBHOOK No High-risk escalation URL

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors