A full-stack safety application with live video recording, AI threat detection, emergency calling, and safety mapping features.
- Node.js (v18 or higher) - Download
- npm (comes with Node.js)
- Git - Download
- FFmpeg (for video processing) - Download
- macOS:
brew install ffmpeg - Windows: Download from ffmpeg.org and add to PATH
- Linux:
sudo apt-get install ffmpegorsudo yum install ffmpeg
- macOS:
git clone https://github.com/Jxyy14/Sentinel.git
cd Sentinelcd backend
npm installcd ../frontend
npm installCreate a file named .env in the backend folder with the following content:
# Server Configuration
PORT=3001
SERVER_URL=http://localhost:3001
# JWT Secret (generate a random string)
JWT_SECRET=your-super-secret-jwt-key-change-this-to-random-string
# Database (SQLite - will be created automatically)
DATABASE_PATH=./safestream.db
# TwelveLabs API (for video threat detection)
# Get your API key from: https://elevenlabs.io/app/settings/api-keys
TWELVELABS_KEY=your_twelvelabs_api_key_here
TWELVELABS_INDEX_ID=your_twelvelabs_index_id_here
# Google Gemini API (for AI analysis and chat)
# Get your API key from: https://aistudio.google.com/app/apikey
GEMINI_API_KEY=your_gemini_api_key_here
# Twilio (for real phone calls)
# Get these from: https://console.twilio.com/
TWILIO_ACCOUNT_SID=your_twilio_account_sid_here
TWILIO_AUTH_TOKEN=your_twilio_auth_token_here
TWILIO_PHONE_NUMBER=your_twilio_phone_number_here
# ElevenLabs API (for text-to-speech)
# Get your API key from: https://elevenlabs.io/app/settings/api-keys
ELEVENLABS_API_KEY=your_elevenlabs_api_key_hereImportant: Replace all your_*_here values with your actual API keys and credentials (see API Setup section below).
- Go to TwelveLabs Platform
- Sign up or log in
- Navigate to API Keys section
- Create a new API key and copy it →
TWELVELABS_KEY - Navigate to Indexes section
- Create a new index (or use existing) and copy the Index ID →
TWELVELABS_INDEX_ID - Add both to your
backend/.envfile
- Go to Google AI Studio
- Sign in with your Google account
- Click "Get API Key" or "Create API Key"
- Select or create a Google Cloud project
- Copy the API key →
GEMINI_API_KEY - Add to your
backend/.envfile
Note: Free tier has rate limits. For production, consider upgrading.
- Go to Twilio Console
- Sign up for a free account
- Once logged in, find your:
- Account SID (on dashboard) →
TWILIO_ACCOUNT_SID - Auth Token (click "Show" next to Auth Token) →
TWILIO_AUTH_TOKEN
- Account SID (on dashboard) →
- To get a phone number:
- Go to Phone Numbers → Buy a number
- Select a number (free tier has limitations)
- Copy the phone number in E.164 format (e.g.,
+1234567890) →TWILIO_PHONE_NUMBER
- Important: Verify your test phone number:
- Go to Phone Numbers → Manage → Verified Caller IDs
- Add your phone number for testing
- Add all three values to your
backend/.envfile
Note: Twilio trial accounts can only call verified numbers. Upgrade for production use.
- Go to ElevenLabs
- Sign up or log in
- Go to Profile → API Keys
- Click "Generate New API Key" and copy it →
ELEVENLABS_API_KEY - Add to your
backend/.envfile
Generate a random secret for JWT token signing:
# macOS/Linux
openssl rand -base64 32
# Or use Node.js
node -e "console.log(require('crypto').randomBytes(32).toString('base64'))"Copy the output and use it as JWT_SECRET in your .env file.
The database will be created automatically on first run, but you can also seed it with sample data:
cd backend
node -e "require('./database.js')"
node seedIncidents.js # Optional: Add sample incident datacd backend
npm start
# Or for development with auto-reload:
node -r dotenv/config server.jsThe backend should start on http://localhost:3001
cd frontend
npm run devThe frontend should start on http://localhost:5173
Open your browser and navigate to:
- Local: http://localhost:5173
- Network (for phone access): Check the terminal output for the network URL (e.g.,
http://192.168.1.100:5173)
- Open the app in your browser
- Click "Sign Up" to create a new account
- Enter your name, email, and password
- You'll be automatically logged in
The Safety Map works out of the box. Sample incident data is included when you seed the database:
cd backend
node seedIncidents.js- Make sure
TWELVELABS_KEYandTWELVELABS_INDEX_IDare set inbackend/.env - Start recording in the app
- Stop and save the recording
- TwelveLabs will automatically analyze the video for threats
- View analysis in the History page
Requirements:
TWILIO_ACCOUNT_SID,TWILIO_AUTH_TOKEN,TWILIO_PHONE_NUMBERset in.envGEMINI_API_KEYset in.envELEVENLABS_API_KEYset in.env- Verified phone number in Twilio (for trial accounts)
Setup:
- Ensure all API keys are in
backend/.env - Verify your phone number in Twilio Console (see Twilio setup above)
- Start a video recording
- Click the "911" button
- Your phone will ring (if Twilio is configured)
- Answer and speak with the AI assistant
Note: The emergency call uses test number +14372541201 by default. NEVER use actual 911.
- Record a video and let it finish processing with TwelveLabs
- Open the video from the History page
- Click "Ask Questions About This Video"
- Chat with Gemini about what happened in the video
- Check if port 3001 is already in use:
lsof -i :3001 - Verify all required npm packages are installed:
cd backend && npm install - Check
.envfile exists and has correct format (no quotes around values)
- Check if port 5173 is already in use
- Verify all dependencies:
cd frontend && npm install - Clear cache:
rm -rf node_modules package-lock.json && npm install
- Check FFmpeg is installed:
ffmpeg -version - Verify
TWELVELABS_KEYandTWELVELABS_INDEX_IDin.env - Check backend logs for errors
- Verify Twilio credentials in
.env - Check phone number is verified in Twilio Console
- Ensure
GEMINI_API_KEYis set (for AI responses) - Check backend logs for specific errors
If you see "429 Too Many Requests" errors:
- Gemini: Free tier has daily limits. Wait for reset or upgrade.
- TwelveLabs: Check your plan limits.
- Twilio: Trial accounts have limitations. Upgrade for production.
If the database is corrupted:
cd backend
rm safestream.db safestream.db-shm safestream.db-wal
# Restart the server - database will be recreatedSentinel/
├── backend/
│ ├── .env # Environment variables (create this)
│ ├── database.js # Database schema
│ ├── server.js # Express server
│ ├── routes/ # API routes
│ ├── services/ # External API services
│ ├── middleware/ # Auth middleware
│ └── uploads/ # Video uploads (auto-created)
│
├── frontend/
│ ├── src/
│ │ ├── pages/ # React pages
│ │ ├── components/ # React components
│ │ ├── services/ # API client
│ │ └── App.jsx # Main app component
│ └── package.json
│
└── README.md # This file
- Never commit
.envfiles to Git - Use strong, unique
JWT_SECRET - Keep API keys private
- Use environment variables, never hardcode secrets
- For production, use a proper database (PostgreSQL, MySQL) instead of SQLite
For production deployment:
- Set
SERVER_URLto your production domain - Use a production database (PostgreSQL recommended)
- Set up HTTPS/SSL certificates
- Configure proper CORS origins
- Use environment variables or a secrets manager
- Set up proper logging and monitoring
- Configure backup strategies for videos and database
[Add your license here]
- Marwan0606
- Jxyy14
For issues, check:
- This README troubleshooting section
- Backend logs (
console.logoutput in terminal) - Browser console (F12) for frontend errors
- API service documentation (Twilio, Gemini, TwelveLabs, ElevenLabs)
Made with ❤️ for safety and security