A React + TypeScript baby safety monitor powered by the Gemini Vision API. Point a camera at a room, detect hazards, define dangerous actions, and get alerted in real time.
| Layer | Technology |
|---|---|
| Frontend | React, TypeScript, Vite |
| Styling | Tailwind CSS, Framer Motion |
| AI | Google Gemini |
| Camera | WebRTC, Raspberry Pi camera |
- Node.js 18+
- A Google Gemini API key (free tier works)
cd cradle-guard
npm installnpm run devOpen http://localhost:3000 in your browser.
npm run build
npm run preview- Enter your Gemini API key in the input field (used only in your browser, never sent to any server other than Google's)
- Click Start Camera — allow camera permissions when prompted
- Point the camera at the room where your baby will be
- Click Scan Room — Gemini Vision analyses the frame and returns a list of detected hazards with severity ratings
- Click Generate to have Gemini create a list of specific dangerous scenarios based on the hazards found (e.g. "Baby pulls lamp off nightstand")
- Toggle actions on/off using the toggle switches
- Add your own custom alerts in the input box (e.g. "baby touches the lamp")
- Remove any actions you don't want
- Choose one or more notification methods:
- Push Notification — browser notification to your device
- Sound Alarm — plays an audio beep through your speakers
- Email Alert — enter your email (you'll need a backend/service like EmailJS to actually send)
- SMS / Text — enter your phone number (requires Twilio or similar)
- Set Detection Sensitivity (Low / Medium / High)
- Click Activate Monitor
- Live camera feed with a real-time scan line
- Gemini checks a frame every 8 seconds
- Any triggered danger actions appear as alerts
- All events are logged with timestamps
- Click Stop Monitoring to return to settings
# On your dev machine
npm run build
# Copy the dist/ folder to your Pi
scp -r dist/ pi@raspberrypi.local:~/cradle-guard
# On the Pi — serve with any static server
npx serve dist
# or
python3 -m http.server 3000 --directory distThen open a browser on the Pi (or from another device on the same network) at http://raspberrypi.local:3000.
Tip: For best results on a Pi camera, set
facingMode: 'environment'(already configured inuseCamera.ts).
- Your Gemini API key is never stored — it lives only in React state and is cleared on page refresh
- The monitor checks one frame every 8 seconds to stay within free API rate limits — adjust
INTERVAL_MSinMonitor.tsxto change this - Email and SMS alerts are UI-only in this version; wire them up to EmailJS or Twilio to fully activate