How niconielsen32/vision-system works
Project type and purpose
• This is a full-stack real-time AI vision processing system.
• Frontend: React + Vite SPA for camera management, live/recorded video analysis, dashboards, and settings.
• Backend: FastAPI server providing REST and WebSocket (real-time) endpoints, orchestrating AI model inference, and persisting data to PostgreSQL.
• Monitoring: Prometheus scrapes metrics exposed by the backend.
• Deployment: Docker-Compose orchestrates PostgreSQL, FastAPI, Prometheus, and the frontend.
File structure
• Top-level:
• docker-compose.yml + Dockerfile + .env.example – container definitions and env templates.
• prometheus/ – Prometheus server config, alert/rules, and console templates.
• backend/ – FastAPI application:
– main.py – application entrypoint (Uvicorn server, routes).
– db_settings.py – DB connection setup (PostgreSQL).
– models.py / schemas.py – ORM & Pydantic models.
– monitoring/metrics.py – Prometheus client exporter.
• frontend/ – React application scaffolded by Vite:
– src/pages, src/components – UI modules for Home, Dashboard, LiveAnalysis, Settings, etc.
– src/services/api.js – HTTP client to backend endpoints.
– vite.config.js, package.json – build config.
• requirements.txt – Python dependencies.
• package.json – Root-level (if any tooling at root).
• Notice stray src/App.jsx at root – likely can be ignored or consolidated under frontend.
Key architectural patterns & technologies
• Client-Server (SPA + REST/WebSocket).
• MVC-style separation: Pydantic schemas (input/output), SQLAlchemy/ORM models, and API routers.
• Real-time data flow: WebSocket or Server-Sent Events for live video.
• Observer/Exporter for metrics (Prometheus).
• Containerized micro-services via Docker Compose.
Main components & their relationships
a. Frontend (browser SPA)
– Hosts UI, consumes REST APIs for configuration, metadata, dashboards.
– Opens WebSocket or SSE connection to backend for live video analysis frames.
b. Backend (FastAPI)
– REST endpoints: camera CRUD, model selection, analytics data.
– Real-time stream endpoints: receives video frames (or URLs) from client or reads camera streams, forwards to AI inference module.
– Data Layer: communicates with PostgreSQL for persisting camera configs, historical analytics.
– Monitoring Exporter: collects internal metrics and exposes HTTP /metrics for Prometheus.
c. Database (PostgreSQL)
– Stores user/camera metadata, analytics results, and model configuration.
d. Monitoring (Prometheus + Console)
– Scrapes backend /metrics.
– Rules generate alerts; consoles present custom HTML dashboards.
e. External Camera Streams
– IP or USB cameras feeding RTSP/HLS streams that backend ingests.