How ishwanku/rtsp-stream-viewer works
Project type and purpose
• This is a full-stack web application (“RTSP Stream Viewer”) whose goal is to let users view live RTSP camera feeds in the browser.
• Frontend: React (Vite, Tailwind CSS), deployed on Vercel.
• Backend: Django + Django Channels (ASGI), FFmpeg for stream transcoding, Redis for channel layer, deployed on Vercel.
File structure
• Top-level “frontend” directory contains a React project (Vite config, package.json, tailwind, components under src/ components).
• Top-level “backend” directory contains a Django project (manage.py, requirements.txt, asgi.py and wsgi.py, apps under backend/stream).
• “stream” app uses consumers.py (WebSocket consumers), models.py, views.py.
• Configuration files: backend/vercel.json, front- end/vercel.json for deployment; backend/build.sh; Redis URL set via environment variables.
README for additional insights
• The README clarifies use of FFmpeg to pull RTSP and push frames to Channels group.
• Environment variables: SECRET_KEY, DEBUG, REDIS_URL.
• Local dev instructions for both front and back; mentions Upstash Redis.
Relationships & data flow
1. User loads React app from Vercel.
2. User submits RTSP URL → React sends HTTP POST to Django REST endpoint.
3. Django view triggers an FFmpeg process to pull RTSP, convert to frames or HLS/chunks, and publish into a Channels group via Redis.
4. React opens a WebSocket to the Django Channels endpoint (ASGI).
5. Django Channels consumer reads processed frames from the group (via Redis) and pushes them over the open WebSocket.
6. React StreamPlayer receives binary/frame data and renders video.
Architectural patterns & design principles
• Separation of concerns: UI (React) / API & real-time (Django Channels)
• Event-driven real-time streaming via WebSockets and channel layer (Redis)
• Micro-pub/sub pattern: FFmpeg acts as publisher, Django Channels as dispatcher, React as subscriber.
• Stateless frontend; backend uses ephemeral subprocesses for FFmpeg and Redis for stateful pub/sub.
Technologies & frameworks to label
• React, Vite, Tailwind CSS (frontend)
• Django, Django Channels, Redis (backend)
• FFmpeg (stream processing)
• Vercel (deployment)
• Upstash or cloud Redis (channel layer)
Elements
• Labels for each component (e.g., “React UI,” “Django ASGI,” “FFmpeg Process,” “Redis Channel Layer”).
– RTSP camera → FFmpeg
– FFmpeg → Redis
– React HTTP → Django REST
– React WS ↔ Django Channels
– Browser render path
– Blue for frontend components
– Green for backend services
– Orange for external systems (RTSP, Redis)
Final advice
– Be as granular as necessary: each subprocess (FFmpeg), each protocol (HTTP vs WS), each service (Redis).
– Emphasize the real-time streaming path (camera → FFmpeg → Redis → WebSocket → browser).
– Review routes in backend/rtsp_viewer/routing.py and stream/consumers.py to ensure all endpoints and channel groups are represented.