A polished Next.js + TypeScript frontend for uploading videos, running AI analysis via a backend API, and visualizing detections with an interactive timeline and contextual analysis. Includes a live monitoring mode using the browser camera.
https://drive.google.com/file/d/1t7SQylN68sd8SybEKN5MC2f2c0c9CZlg/view?usp=sharing
Full system demonstration showing video upload, AI analysis, and interactive timeline features.
- Violens Frontend — UI for AI-powered violence detection and monitoring.
- Supports video uploads, live camera monitoring, and backend-powered analysis.
src/: Core UI codeapp/: Next.js App Router pages and global stylescomponents/: Reusable UI modules
deployment/: N/A for this repo; CI/CD via Azure Static Web Apps workflowmonitoring/: N/A for this repo; frontend does not expose Prometheus/Grafana configsdocumentation/: Not included; see below for where to add proposal/reportvideos/: Optional; addsystem_demo.mp4when available.gitignore: Present.github/workflows/azure-static-web-apps-calm-hill-070f74e0f.yml: CI/CD workflow
- Main script:
src/app/page.tsx— componentHome(violens_frontend/src/app/page.tsx:28) - Global layout:
src/app/layout.tsx(violens_frontend/src/app/layout.tsx:1) - Running locally:
npm installnpm run dev→http://localhost:3000
- Production:
npm run buildnpm start
- API base URL:
- Set
NEXT_PUBLIC_API_BASE_URLfor backend calls. - Request issued in
handleAnalyze(violens_frontend/src/app/page.tsx:118).
- Set
videos/system_demo.mp4.
- Method: Azure Static Web Apps (CI/CD) on pushes to
main(violens_frontend/.github/workflows/azure-static-web-apps-calm-hill-070f74e0f.yml:1). - Alternative hosting: any Next.js-compatible platform (Vercel/Netlify/custom Node).
- Ensure
NEXT_PUBLIC_API_BASE_URLpoints to the production backend.
- Tools: Not applicable in this frontend-only repo.
- Optional: integrate browser analytics (e.g., privacy-friendly analytics) or error tracking.
- Main documentation: this
README.md. - https://docs.google.com/document/d/1NCgTxctWA1R-nC8Lgw_QSpdyGF6LuIvwu2E7hGq9rtM/edit?usp=sharing
- Branching:
mainis stable; use short-lived feature branches for changes. - Code review: open PRs against
main; require review and CI passing. - Commit hygiene: clear, scoped messages; group related changes.
- Secrets: store in GitHub/Azure secrets or environment variables; never commit
.env.
deployment/Dockerfileanddocker-compose.yml: not used here; CI/CD is via Azure Static Web Apps.monitoring/configs (Prometheus/Grafana): not present in the frontend repo.documentation/andvideos/: optional and can be added later.
- Video upload with preview, local conversion fallback when browser format isn’t supported
- One-click AI analysis via backend
/analysisendpoint - Interactive timeline with risk-highlighted segments (high/medium/low)
- Contextual analysis cards:
- Overall analysis: risk level, detection count, duration
- Detailed view: selected detection type, time range, confidence
- Live monitoring mode with camera stream and risk indicator
- Modern glassmorphism UI, responsive layout, and accessibility affordances
- Next.js (App Router) + React + TypeScript
- Tailwind CSS + custom design system (
globals.css) lucide-reacticons
- Node.js 18+ (recommended) and npm
- A running backend that exposes a POST
/analysisendpoint
- Install:
npm install - Run dev:
npm run dev(opens athttp://localhost:3000) - Build:
npm run build - Start production:
npm start
NEXT_PUBLIC_API_BASE_URL(string): Base URL of the backend API.- If not set, the app falls back to
http://{window.location.hostname}:8000. - Used for the
/analysisPOST request insrc/app/page.tsx.
- If not set, the app falls back to
Example:
export NEXT_PUBLIC_API_BASE_URL="http://localhost:8000"
POST /analysis with multipart form-data:
- Key:
file(video file)
Response JSON (example fields used by the UI):
{
"summary": "Detected 1 segments: class_0(1). Overall risk high.",
"totalDuration": 5.0,
"overallRisk": "high",
"violenceDetections": [
{
"startTime": 1.2,
"endTime": 3.4,
"confidence": 0.85,
"type": "Assault",
"description": "Detected aggressive motion and person-to-person contact."
}
]
}Notes:
overallRiskmust be one oflow | medium | high.violenceDetectionsare visualized in the timeline and contextual cards.
- Home
- Choose “Live Monitoring” or “Video Analysis”.
- Video Analysis
- Upload a video.
- If preview fails, the UI offers local conversion and shows a note.
- Click “Analyze Video” to call the backend. Results render:
- Timeline (
VideoTimeline.tsx): risk-colored segments, clickable to seek - Contextual Analysis (
ContextualAnalysis.tsx): overall stats and per-segment details
- Timeline (
- Live Monitoring
- Start camera, optional recording indicator, and risk badge.
src/components/VideoUpload.tsx: Upload area and error displaysrc/components/VideoTimeline.tsx: Time markers, segment highlights, current/hover indicatorssrc/components/ContextualAnalysis.tsx: Overall analysis and detection details; summary sanitization prevents noisy backend textsrc/components/LiveMonitoring.tsx: Camera stream with live detections panelsrc/components/LoadingSpinner.tsx: Busy state during analysis
src/app/globals.cssdefines the design tokens and utilities:card,btn,glass-strong,status-indicator- High contrast and reduced motion support
- Tailwind utilities are used per-component for layout and state styles.
src/app/— App Router pages, global styles, layoutsrc/components/— Reusable UI componentspublic/— Static assets
📁 violens_frontend
│
├── 📁 src
│ ├── 📁 app
│ │ ├── favicon.ico
│ │ ├── globals.css
│ │ ├── layout.tsx
│ │ └── page.tsx
│ └── 📁 components
│ ├── AnalysisResults.tsx
│ ├── ContextualAnalysis.tsx
│ ├── LiveMonitoring.tsx
│ ├── LoadingSpinner.tsx
│ ├── VideoPlayer.tsx
│ ├── VideoTimeline.tsx
│ └── VideoUpload.tsx
├── 📁 public
├── 📁 image/README
│ └── 1762719717264.png
├── 📁 .github/workflows
│ └── azure-static-web-apps-calm-hill-070f74e0f.yml
├── package.json
├── eslint.config.mjs
├── next.config.ts
├── tsconfig.json
├── postcss.config.mjs
├── .gitignore
└── README.md
npm run dev— Start local dev servernpm run build— Create production buildnpm start— Serve production build
- High-contrast mode: CSS adjusts borders/foreground in
globals.css - Reduced motion: Animations respect
prefers-reduced-motion - Responsive grid layouts and readable typography on small and large screens
- “Preview not supported for this format”: Use the provided “Convert for Preview” control; large files may take time.
- Analysis errors: Confirm
NEXT_PUBLIC_API_BASE_URLand that/analysisis reachable; backend must accept multipart video uploads.
- Any Next.js-compatible host (Vercel, Netlify, or custom).
- Ensure
NEXT_PUBLIC_API_BASE_URLpoints to your production backend. - Use
npm run buildthennpm startfor a Node-based deployment.
Violens Frontend focuses on clarity and actionable analysis in high-risk contexts. Contributions and improvements are welcome.
