How sachin1880/homesmartcctv works
Smart Home Camera pairs an old phone in Camera Device mode with a current phone in Viewer mode; the FastAPI backend manages accounts, device state, events, and WebRTC signaling, while live media travels peer-to-peer. The main flow is role selection and authentication, camera registration and heartbeats, viewer monitoring, then signaling negotiation and direct streaming. The README also documents event history and retained capture/video features. Edges rely on the supplied README and source index; unsampled implementation details are represented only where the documented capability supports them.
Main entry points: devices.py API routes · App.tsx App navigation · main.py FastAPI application · camera_device.py Device and event records
Components 25
Mobile app
- App navigation
mobile/App.tsx - Sign-in and roles
mobile/src/screens/LoginScreen.tsx - Camera controls
mobile/src/screens/CameraDeviceScreen.tsx - Viewer dashboard
mobile/src/screens/ViewerDashboardScreen.tsx - Event history
mobile/src/screens/EventHistoryScreen.tsx - Video browsing
mobile/src/screens/VideoPlaylistScreen.tsx - REST client
mobile/src/api/client.ts - Device API
mobile/src/api/devices.ts - Auth storage
mobile/src/storage/authStorage.ts
Backend API
- FastAPI application
backend/app/main.py - API routes
backend/app/api/routes/devices.py - Authentication routes
backend/app/api/routes/auth.py - Heartbeat status
backend/app/services/device_status.py - Signaling relay
backend/app/services/signaling.py - Capture retention
backend/app/services/captures.py - Video retention
backend/app/services/videos.py
Persistence and media
- Database session
backend/app/db/session.py - Device and event records
backend/app/models/camera_device.py - User records
backend/app/models/user.py
Realtime streaming
- Camera peer hook
mobile/src/webrtc/useCameraPeerConnection.ts - Viewer peer hook
mobile/src/webrtc/useViewerPeerConnection.ts - Signaling client
mobile/src/webrtc/signalingClient.ts - Peer media stream
Other components
- Camera owner
- PostgreSQL
Connections 38
- Camera owner → App navigation: uses
mobile/App.tsx - App navigation → Sign-in and roles: navigates
mobile/App.tsx - App navigation → Camera controls: navigates
mobile/App.tsx - App navigation → Viewer dashboard: navigates
mobile/App.tsx - App navigation → Event history: navigates
mobile/App.tsx - App navigation → Video browsing: navigates
mobile/App.tsx - Sign-in and roles → REST client: requests
- REST client → Auth storage: reads token
mobile/src/api/client.ts - Camera controls → Device API: controls device
mobile/src/screens/CameraDeviceScreen.tsx - Viewer dashboard → Device API: loads devices
- Event history → Device API: loads events
- REST client → FastAPI application: REST requests
README.md - FastAPI application → API routes: routes requests
- FastAPI application → Database session: cleans expired media
backend/app/main.py - Authentication routes → User records: reads and writes
backend/app/api/routes/auth.py - Authentication routes → Database session: uses session
backend/app/api/routes/auth.py - API routes → Database session: uses session
backend/app/api/routes/devices.py - API routes → Device and event records: manages devices
backend/app/api/routes/devices.py - API routes → Heartbeat status: updates status
backend/app/api/routes/devices.py - API routes → Signaling relay: delegates signaling
backend/app/api/routes/devices.py - API routes → Capture retention: uses captures
backend/app/api/routes/devices.py - API routes → Video retention: uses videos
backend/app/api/routes/devices.py - Heartbeat status → Device and event records: updates records
backend/app/services/device_status.py - Database session → PostgreSQL: connects
backend/app/db/session.py - Device and event records → PostgreSQL: persists state
- User records → PostgreSQL: persists accounts
- Camera controls → Camera peer hook: starts camera
mobile/src/screens/CameraDeviceScreen.tsx - Viewer dashboard → Viewer peer hook: opens live view
- Camera peer hook → Signaling client: exchanges messages
mobile/src/webrtc/useCameraPeerConnection.ts - Viewer peer hook → Signaling client: exchanges messages
mobile/src/webrtc/useViewerPeerConnection.ts - Signaling client → FastAPI application: opens WebSocket
mobile/src/webrtc/signalingClient.ts - FastAPI application → Signaling relay: handles signaling
- Signaling relay → Camera peer hook: relays signaling
README.md - Signaling relay → Viewer peer hook: relays signaling
README.md - Camera peer hook → Peer media stream: streams media
README.md - Viewer peer hook → Peer media stream: receives media
README.md - Capture retention → Device and event records: retains capture records
- Video retention → Device and event records: retains video records