AI-Powered Emergency Dispatch and Incident Management System
Vigilis is a comprehensive emergency services platform that combines real-time incident tracking, AI-powered dispatch assistance, and intelligent decision support to help 911 dispatchers and emergency personnel respond more effectively to critical situations.
Vigilis integrates multiple systems to provide a unified emergency management solution:
- Real-time Incident Tracking: MongoDB-based incident database with live updates
- AI Assistant (Vigilis Agent): Google Gemini-powered conversational AI that answers dispatcher queries
- Police Car Management: Track and dispatch police vehicles with real-time location monitoring
- Intelligent Suggestions: Vector-based semantic search retrieves insights from similar past incidents
- Live Location Streaming: Redis-backed real-time GPS tracking with WebSocket support
- Fill Agent: AI-powered automatic field detection and incident data enrichment
- Framework: FastAPI (Python 3.11)
- Database: MongoDB Atlas (primary storage)
- Cache/Streaming: Redis (real-time location data)
- AI Models: Google Gemini (via google.adk and google-genai)
- Framework: Next.js 16 with React 19
- Styling: Tailwind CSS 4
- Maps: Mapbox GL JS with react-map-gl
- State Management: TanStack Query (React Query)
- Automatic Incident Creation: New incidents auto-created from 911 call transcripts
- Multi-conversation Support: Track multiple communication streams (911 calls, radio, etc.)
- AI Summarization: Automatic incident status summaries
- Dynamic Field Updates: AI agent monitors transcripts and updates location/severity fields
The Vigilis Agent provides intelligent assistance to dispatchers:
- Natural language queries about incident details
- Real-time access to incident data via function calling
- Contextual responses based on incident history
- Integration with the incident database
- Vector Embeddings: Incidents embedded using Gemini embedding model (768 dimensions)
- Semantic Search: Finds similar past incidents based on content similarity
- Data-Driven Suggestions: Provides actionable recommendations based on historical outcomes
- Pattern Recognition: Identifies successful strategies from past incidents
- Fleet Management: Track all police units with officer details
- Status Tracking: Multiple states (inactive, dispatched, en_route, on_scene, returning)
- Dispatch History: Complete audit trail of unit deployments
- Real-time Updates: Live location streaming via Redis and WebSocket
- High-Frequency Updates: Redis stores GPS data updated every second
- Car Simulator: Built-in movement simulation for testing
- Geospatial Queries: Find nearby units within a radius
- WebSocket Streaming: Subscribe to individual car location updates
- Sync Service: Periodic synchronization from Redis to MongoDB
GET /incidents - Get all active incidents
POST /incident/update_transcript - Add transcript to incident
GET /incident/chat_elements/{id} - Get chat history
POST /incident/context - Get full incident document
POST /incident/summary - Get AI-generated summary
POST /incident/suggestions - Get AI recommendations
POST /incident/report - Generate comprehensive report
POST /incident/post_story - Conclude incident and save to knowledge base
PUT /incident/status - Update incident status
POST /police/cars - Create new police car
GET /police/cars - Get all police cars (filter by status)
GET /police/cars/{id} - Get specific car
POST /police/dispatch - Dispatch car to incident
POST /police/conclude - Conclude dispatch
PUT /police/status - Update car status
PUT /police/location - Update car location
GET /police/available - Get available cars
GET /police/incident/{id} - Get cars for incident
DELETE /police/cars/{id} - Delete police car
GET /police/realtime/{car_id} - Get real-time location from Redis
GET /police/realtime - Get all real-time locations
POST /police/nearby - Find nearby cars within radius
WS /ws/track/{car_id} - WebSocket stream for car location
POST /chat - Chat with Vigilis AI assistant
- Python 3.11+
- Node.js 18+
- MongoDB Atlas account
- Redis instance (for real-time features)
- Google Gemini API key
- Clone the repository
git clone <repository-url>
cd Vigilis- Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies
pip install -r requirements.txt- Configure environment variables
Create a
.envfile in the root directory:
MONGO_URI=mongodb+srv://username:password@cluster.mongodb.net/
GEMINI_API_KEY=your_gemini_api_key_here
GOOGLE_GENAI_USE_VERTEXAI=0
REDIS_HOST=localhost
REDIS_PORT=6379
WEBSOCKET_SECRET=vigilis_secret_2024- Run the backend
cd backend
uvicorn api:app --host 0.0.0.0 --port 8000 --reload- Navigate to frontend directory
cd frontend/vigilis- Install dependencies
npm install- Configure environment
Create
.env.local:
NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_MAPBOX_TOKEN=your_mapbox_token_here- Run development server
npm run devThe frontend will be available at http://localhost:3000
- Create vector search index for incident knowledge base:
{
"fields": [
{
"type": "vector",
"path": "final_summary_embedding",
"numDimensions": 768,
"similarity": "cosine"
}
]
}- Collections required:
active_incidents- Current incidentsincident_knowledge_base- Historical concluded incidentspolice_cars- Police fleet data
For local development without MongoDB triggers:
python run_local_watcher.pyThis watches for database changes and triggers the fill agent automatically.
See RENDER_DEPLOY.md for detailed deployment instructions.
Quick steps:
- Push to GitHub
- Connect repository to Render
- Set environment variables
- Deploy with:
uvicorn backend.api:app --host 0.0.0.0 --port $PORT
- Configure CORS origins in
backend/api.py - Set up MongoDB replica set for change streams
- Use managed Redis service (e.g., Redis Cloud, AWS ElastiCache)
- Enable MongoDB Atlas network access for production IPs
- Use secure WebSocket secrets
Automatically analyzes incident transcripts and updates dynamic fields:
- Detects location changes from conversation
- Updates severity levels based on new information
- Triggers on transcript updates
The main conversational AI assistant:
- Uses Google ADK's
LlmAgent - Function calling for database queries
- Context-aware responses
Real-time location management:
car_simulator.py- Simulates vehicle movementlocation_sync.py- Syncs Redis to MongoDBredis_client.py- Redis connection management
Historical incident analysis:
- Embeds current incident summary
- Performs vector search in knowledge base
- Generates actionable suggestions from similar cases
{
"incident_id": str,
"title": str,
"severity": str,
"status": "active" | "concluded",
"created_at": ISO8601,
"location": {
"address_text": str,
"geojson": {
"type": "Point",
"coordinates": [lng, lat]
}
},
"transcripts": {
"conversation_id": [str]
},
"current_summary": str,
"chat_elements": [dict],
"last_summary_update_at": ISO8601
}{
"car_id": str,
"car_model": str,
"unit_number": str,
"officer": {
"name": str,
"badge": str,
"rank": str
},
"status": "inactive" | "dispatched" | "en_route" | "on_scene" | "returning",
"incident_id": str | None,
"location": {
"lat": float,
"lng": float,
"address": str
},
"dispatch_history": [dict]
}- FastAPI - Modern async web framework
- PyMongo - MongoDB driver
- Redis-py - Redis client
- Google Generative AI - Gemini API client
- Google ADK - Agent Development Kit
- Uvicorn - ASGI server
- Pydantic - Data validation
- WebSockets - Real-time communication
- Next.js - React framework with SSR
- TypeScript - Type-safe JavaScript
- Mapbox GL JS - Interactive maps
- Framer Motion - Animation library
- TanStack Query - Server state management
- Tailwind CSS - Utility-first CSS
- Google Gemini - Large language model
- Gemini Embeddings - Text vectorization (768-dim)
- MongoDB Vector Search - Semantic similarity search
python seed_db.pycd backend/redis_tracking
python test_e2e.py
python test_redis_system.py
python test_websocket.pycd backend/redis_tracking
python debug_websocket.pyThis project uses:
- Python 3.11 with type hints
- Black for Python code formatting
- ESLint for frontend linting
- Git for version control
ISC
For issues or questions, please refer to the API documentation at the root endpoint (/) when the server is running.
Built with ❤️ for emergency services personnel