Skip to content

yonko2/Seraphim

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

14 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ›‘οΈ Seraphim β€” Emergency Assistant

AI-powered emergency detection and response app built for hackathon

Overview

Seraphim is a two-mode mobile app (Victim and Helper) that detects emergencies through device sensors and AI camera analysis, generates objective reports free of panic or emotion, and automatically alerts operators via Telegram voice messages.

When a victim's phone detects a fall or the camera recognizes a disaster, Seraphim builds a structured emergency report β€” including GPS location and health vitals β€” converts it to speech, and sends it directly to an operator on Telegram.

Features

  • 🚨 Automatic Emergency Detection β€” Fall detection via accelerometer, disaster recognition via camera + Gemini AI
  • πŸ“Š Smart Reporting β€” AI-filtered objective reports (removes panic/emotion from raw data)
  • πŸ“ž Telegram Alerts β€” Automated voice messages and text alerts to emergency operators
  • ❀️ Health Integration β€” Apple HealthKit & Google Health Connect support (heart rate, blood oxygen, blood glucose)
  • 🎯 Helper Mode β€” AI-powered first-aid guidance for bystanders
  • πŸ“· Camera AI β€” Real-time disaster classification (fire, flood, crash, medical emergency, violence)
  • πŸ—£οΈ Text-to-Speech β€” Emergency reports narrated via Google TTS for voice delivery

Tech Stack

Layer Technology
Mobile App React Native 0.83 Β· Expo 55 Β· TypeScript
Navigation React Navigation (native stack + bottom tabs)
State Zustand
AI / Vision Google Gemini (@google/generative-ai)
Sensors expo-sensors (accelerometer), expo-camera, expo-location
Backend Python 3.10+ Β· FastAPI Β· Uvicorn
Telegram Telethon Β· py-tgcalls
TTS gTTS (Google Translate TTS)

Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              Mobile App (Expo)               β”‚
β”‚                                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚ Sensors  β”‚  β”‚ Camera + β”‚  β”‚  Health    β”‚  β”‚
β”‚  β”‚ (Fall    β”‚  β”‚ Gemini   β”‚  β”‚  (Apple /  β”‚  β”‚
β”‚  β”‚ Detect)  β”‚  β”‚ AI       β”‚  β”‚  Google)   β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜  β”‚
β”‚       β”‚              β”‚              β”‚         β”‚
β”‚       β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β”‚
β”‚              β–Ό                                β”‚
β”‚     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                       β”‚
β”‚     β”‚ Panic Filter +  β”‚                       β”‚
β”‚     β”‚ Report Generatorβ”‚                       β”‚
β”‚     β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
               β”‚  POST /emergency
               β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚           Backend (FastAPI)                   β”‚
β”‚                                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚ Report         β”‚  β”‚ TTS Service       β”‚   β”‚
β”‚  β”‚ Processor      │──│ (gTTS β†’ MP3)      β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                               β”‚              β”‚
β”‚                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚                    β”‚ Telegram Caller     β”‚   β”‚
β”‚                    β”‚ (Telethon)          β”‚   β”‚
β”‚                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                β”‚
                                β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚  Operator (Telegram)  β”‚
                    β”‚  πŸ”Š Voice message     β”‚
                    β”‚  πŸ“ Text alert        β”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Project Structure

Seraphim/
β”œβ”€β”€ app/                          # React Native / Expo mobile app
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   β”œβ”€β”€ CameraView.tsx        # Camera preview + AI trigger
β”‚   β”‚   β”‚   β”œβ”€β”€ EmergencyReport.tsx   # Report display UI
β”‚   β”‚   β”‚   β”œβ”€β”€ FirstAidGuide.tsx     # Helper mode first-aid steps
β”‚   β”‚   β”‚   β”œβ”€β”€ HealthMetrics.tsx     # Vitals display
β”‚   β”‚   β”‚   └── SensorMonitor.tsx     # Real-time sensor readout
β”‚   β”‚   β”œβ”€β”€ hooks/
β”‚   β”‚   β”‚   β”œβ”€β”€ useEmergencyDetection.ts
β”‚   β”‚   β”‚   β”œβ”€β”€ useHealthData.ts
β”‚   β”‚   β”‚   └── useSensors.ts
β”‚   β”‚   β”œβ”€β”€ navigation/
β”‚   β”‚   β”‚   β”œβ”€β”€ AppNavigator.tsx
β”‚   β”‚   β”‚   └── MainTabs.tsx
β”‚   β”‚   β”œβ”€β”€ screens/
β”‚   β”‚   β”‚   β”œβ”€β”€ HomeScreen.tsx        # Mode selection (Victim / Helper)
β”‚   β”‚   β”‚   β”œβ”€β”€ VictimDashboard.tsx   # Sensor monitoring + alerts
β”‚   β”‚   β”‚   β”œβ”€β”€ HelperDashboard.tsx   # First-aid guidance
β”‚   β”‚   β”‚   β”œβ”€β”€ EmergencyScreen.tsx   # Active emergency view
β”‚   β”‚   β”‚   └── SettingsScreen.tsx    # API keys, backend URL
β”‚   β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”‚   β”œβ”€β”€ ai/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ GeminiService.ts      # Gemini API wrapper
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ DisasterDetector.ts   # Camera frame classification
β”‚   β”‚   β”‚   β”‚   └── PanicFilter.ts        # Strips emotion from reports
β”‚   β”‚   β”‚   β”œβ”€β”€ sensors/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ FallDetector.ts       # Accelerometer-based fall detection
β”‚   β”‚   β”‚   β”‚   └── SensorManager.ts      # Sensor lifecycle management
β”‚   β”‚   β”‚   β”œβ”€β”€ emergency/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ EmergencyManager.ts   # Orchestrates detection β†’ report β†’ send
β”‚   β”‚   β”‚   β”‚   └── ReportGenerator.ts    # Builds structured report JSON
β”‚   β”‚   β”‚   β”œβ”€β”€ health/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ HealthProvider.ts      # Abstract health interface
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ AppleHealthProvider.ts # HealthKit integration
β”‚   β”‚   β”‚   β”‚   └── GoogleHealthProvider.ts# Health Connect integration
β”‚   β”‚   β”‚   └── api/
β”‚   β”‚   β”‚       └── BackendClient.ts      # HTTP client for FastAPI backend
β”‚   β”‚   β”œβ”€β”€ store/
β”‚   β”‚   β”‚   └── useStore.ts               # Zustand global state
β”‚   β”‚   └── types/
β”‚   β”œβ”€β”€ App.tsx
β”‚   └── package.json
β”œβ”€β”€ backend/                      # Python FastAPI server
β”‚   β”œβ”€β”€ main.py                       # FastAPI app + endpoints
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ report_processor.py       # Formats report for TTS narration
β”‚   β”‚   β”œβ”€β”€ tts_service.py            # gTTS text-to-speech
β”‚   β”‚   └── telegram_caller.py        # Telethon voice messages + alerts
β”‚   β”œβ”€β”€ audio/                        # Generated TTS audio files
β”‚   β”œβ”€β”€ .env.example                  # Environment variable template
β”‚   └── requirements.txt
β”œβ”€β”€ LICENSE                       # MIT License
└── README.md

Getting Started

Prerequisites

Mobile App Setup

cd app/
npm install
npx expo start --dev-client
# or build for a specific platform:
# npx expo run:android
# npx expo run:ios

Configure your Gemini API key in the app's Settings screen after launch.

Backend Setup

cd backend/

# Create & activate virtual environment
python -m venv venv
# Windows:
venv\Scripts\activate
# macOS / Linux:
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

# Configure environment
cp .env.example .env
# Edit .env and fill in:
#   TELEGRAM_API_ID, TELEGRAM_API_HASH, TELEGRAM_PHONE,
#   OPERATOR_TELEGRAM_ID

# Run the server
python main.py

The server starts at http://0.0.0.0:8000 with auto-reload enabled.

Usage

Victim Mode

  1. Open Seraphim and choose Victim.
  2. The app begins monitoring the accelerometer for falls and (optionally) the camera for disaster scenes.
  3. When an emergency is detected, the app:
    • Collects GPS location and available health data.
    • Runs observations through the Panic Filter to keep the report objective.
    • Sends the structured report to the backend.
  4. The backend converts the report to speech and delivers a voice message + text alert to the Telegram operator.

Helper Mode

  1. Open Seraphim and choose Helper.
  2. The app provides AI-powered first-aid guidance: point your camera at the scene and receive step-by-step instructions for how to assist.

API Endpoints

Method Path Description
GET /health Health check β€” returns server status and Telegram connection state
POST /emergency Submit an emergency report; triggers TTS generation and Telegram alert
GET /status/{call_id} Check the status of a previously initiated emergency call
POST /test-call Send a test voice message to the operator to verify the pipeline

Interactive API docs are available at /docs (Swagger UI) when the backend is running.

Environment Variables

Variable Description
TELEGRAM_API_ID Telegram API ID from my.telegram.org
TELEGRAM_API_HASH Telegram API hash
TELEGRAM_PHONE Phone number associated with the Telegram account
OPERATOR_TELEGRAM_ID Telegram user ID of the operator who receives alerts
HOST Server bind address (default 0.0.0.0)
PORT Server port (default 8000)

License

This project is licensed under the MIT License β€” see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors