Andhra Pradesh Government Hackathon Project - A comprehensive AI-powered surveillance and security monitoring system with real-time object detection, intelligent analytics, and advanced dashboard capabilities.
- π Overview
- β¨ Key Features
- ποΈ System Architecture
- π Quick Start
- π» Installation
- π§ Configuration
- π± Features Deep Dive
- π API Documentation
- π Security
- π Performance
- π€ Contributing
- π License
A-AI is a cutting-edge surveillance system developed for the Andhra Pradesh Government Hackathon. The project combines modern web technologies with advanced AI/ML capabilities to provide comprehensive security monitoring, real-time threat detection, and intelligent analytics.
- Public Safety Enhancement: Advanced surveillance with AI-powered threat detection
- Smart City Integration: Seamless integration with existing infrastructure
- Real-time Monitoring: Live camera feeds with instant alert systems
- Data-Driven Insights: Analytics and reporting for better decision making
- Scalable Architecture: Built to handle large-scale deployments
This project was developed as the frontend solution for the Andhra Pradesh Government Hackathon, focusing on:
- Government security infrastructure modernization
- AI-powered public safety systems
- Smart city surveillance solutions
- Real-time emergency response systems
- Multi-Camera Support: Manage unlimited IP cameras and CCTV systems
- Live Streaming: Real-time video feeds with HLS support
- Camera Health Monitoring: Automatic status tracking and maintenance alerts
- Geolocation Mapping: GPS-based camera positioning and coverage areas
- Resolution Management: Support for 4K, HD, and custom resolutions
graph TD
A[Camera Network] --> B[Stream Processing]
B --> C[AI Analysis Engine]
C --> D[Dashboard Display]
D --> E[Alert System]
E --> F[Notification Center]
- YOLO Object Detection: Real-time detection of people, vehicles, and objects
- Behavioral Analysis: Suspicious activity detection and pattern recognition
- Facial Recognition: Person identification and tracking
- Vehicle Recognition: License plate reading and vehicle classification
- Crowd Analysis: Density monitoring and crowd behavior analysis
- Real-time Notifications: Instant alerts for security threats
- Multi-channel Alerts: Email, SMS, and in-app notifications
- Custom Rules Engine: Configure alert triggers and conditions
- Priority Classification: Critical, high, medium, and low priority alerts
- Historical Tracking: Complete audit trail of all security events
- Real-time Metrics: Live system health and performance indicators
- Interactive Maps: Geographic visualization of camera networks
- Analytics Charts: Historical data visualization and trends
- System Health: Server, storage, and network monitoring
- User Management: Role-based access control and permissions
- User Management: Admin, operator, and viewer roles
- Camera Configuration: Remote camera setup and management
- Storage Management: Automatic retention policies and backup systems
- Rules Engine: Custom detection rules and alert configurations
- System Settings: Global configuration and preferences
graph TB
subgraph "Frontend (Next.js)"
A[Dashboard UI]
B[Camera Management]
C[AI Assistant]
D[Settings Panel]
end
subgraph "Backend (Python)"
E[FastAPI Server]
F[YOLO AI Engine]
G[Stream Processor]
H[Database Layer]
end
subgraph "Infrastructure"
I[Camera Network]
J[Storage System]
K[Alert Services]
end
A --> E
B --> E
C --> F
E --> G
F --> H
G --> I
H --> J
E --> K
| Technology | Version | Purpose |
|---|---|---|
| Next.js | 13.5.1 | React framework with SSR |
| TypeScript | 5.2.2 | Type-safe development |
| Tailwind CSS | 3.3.3 | Utility-first styling |
| Framer Motion | 12.8.2 | Smooth animations |
| Radix UI | Latest | Accessible UI components |
| Socket.io | 4.8.1 | Real-time communication |
| HLS.js | 1.6.2 | Video streaming support |
- Python 3.8+: Core backend language
- FastAPI: High-performance web framework
- YOLO v5/v8: Object detection and AI analysis
- OpenCV: Computer vision processing
- PostgreSQL: Primary database
- Redis: Caching and session management
- WebRTC: Real-time video streaming
- Node.js 18.0.0 or higher
- Python 3.8 or higher
- Git for version control
- PostgreSQL 12 or higher
- Redis 6.0 or higher
git clone https://github.com/rudra-sah00/A-AI.git
cd A-AI# Install dependencies
npm install
# Set up environment variables
cp .env.example .env.local
# Start development server
npm run dev# Navigate to backend directory (if separate)
cd backend
# Create virtual environment
python -m venv venv
# Activate virtual environment
# On Windows:
venv\Scripts\activate
# On macOS/Linux:
source venv/bin/activate
# Install Python dependencies
pip install -r requirements.txt
# Start backend server
python main.py- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
| Component | Minimum | Recommended |
|---|---|---|
| RAM | 8 GB | 16 GB+ |
| Storage | 50 GB | 100 GB+ SSD |
| CPU | 4 cores | 8 cores+ |
| GPU | Not required | NVIDIA GPU for AI acceleration |
# Install Node.js (Download from nodejs.org)
# Install Python (Download from python.org)
# Install Git (Download from git-scm.com)
# Clone and setup
git clone https://github.com/rudra-sah00/A-AI.git
cd A-AI
npm install
npm run dev# Install Homebrew (if not installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
# Install dependencies
brew install node python git postgresql redis
# Clone and setup
git clone https://github.com/rudra-sah00/A-AI.git
cd A-AI
npm install
npm run dev# Update system
sudo apt update && sudo apt upgrade -y
# Install Node.js
curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs
# Install Python and dependencies
sudo apt install python3 python3-pip git postgresql redis-server
# Clone and setup
git clone https://github.com/rudra-sah00/A-AI.git
cd A-AI
npm install
npm run dev# Using Docker Compose
docker-compose up -d
# Or build individually
docker build -t a-ai-frontend .
docker build -t a-ai-backend ./backend# Install Vercel CLI
npm i -g vercel
# Deploy
vercel --prod# Install Heroku CLI
# Create Heroku app
heroku create a-ai-backend
# Deploy
git subtree push --prefix backend heroku mainDetailed deployment guides available in /docs/deployment/
Create a .env.local file in the root directory:
# API Configuration
NEXT_PUBLIC_API_URL=http://localhost:8000
NEXT_PUBLIC_WS_URL=ws://localhost:8000
# Authentication
NEXTAUTH_SECRET=your-secret-key
NEXTAUTH_URL=http://localhost:3000
# Database
DATABASE_URL=postgresql://username:password@localhost:5432/a_ai_db
# Redis
REDIS_URL=redis://localhost:6379
# AI/ML Configuration
YOLO_MODEL_PATH=/models/yolov8n.pt
AI_CONFIDENCE_THRESHOLD=0.5
# Storage
STORAGE_PATH=/var/storage/a-ai
MAX_STORAGE_SIZE=100GB
# Notifications
EMAIL_SERVICE_API_KEY=your-email-api-key
SMS_SERVICE_API_KEY=your-sms-api-keyEdit backend/config.py:
# Server Configuration
HOST = "0.0.0.0"
PORT = 8000
DEBUG = False
# AI Model Configuration
YOLO_MODEL = "yolov8n.pt"
CONFIDENCE_THRESHOLD = 0.5
NMS_THRESHOLD = 0.4
# Database Configuration
DATABASE_URL = "postgresql://user:pass@localhost/a_ai"
# Camera Configuration
MAX_CAMERAS = 100
STREAM_TIMEOUT = 30
# Storage Configuration
RETENTION_DAYS = 30
MAX_STORAGE_GB = 500The camera management system provides comprehensive control over your surveillance network:
- Auto-Discovery: Automatically detect IP cameras on the network
- Manual Configuration: Add cameras with custom settings
- Health Monitoring: Real-time status tracking and diagnostics
- Group Management: Organize cameras by location or function
- Remote Control: PTZ control for supported cameras
- IP Cameras (RTSP/HTTP)
- USB Webcams
- ONVIF-compliant devices
- Custom RTMP streams
- Mobile camera apps
// Camera configuration example
interface Camera {
id: string;
name: string;
location: string;
streamUrl: string;
status: 'online' | 'offline';
aiFeatures: string[];
coordinates?: {
lat: number;
lng: number;
};
}The AI Assistant provides natural language interaction with your surveillance system:
- Visual Analysis: "What do you see in Camera 1?"
- Object Detection: "Count the people in the parking lot"
- Behavior Analysis: "Detect suspicious activities"
- Historical Queries: "Show me events from yesterday"
- Predictive Insights: "Analyze traffic patterns"
User: "Show me all cameras that detected vehicles in the last hour"
AI: "I found 3 cameras that detected vehicles:
- Parking Lot Camera: 15 vehicles detected
- Main Gate: 8 vehicles detected
- Loading Dock: 3 vehicles detected"
User: "Are there any security concerns in Building A?"
AI: "Currently monitoring Building A cameras. No immediate security
concerns detected. All access points are secure and no
unauthorized persons detected in restricted areas."
Comprehensive alert management with intelligent prioritization:
- Security Alerts: Unauthorized access, suspicious behavior
- Safety Alerts: Emergency situations, accidents
- System Alerts: Camera failures, network issues
- Maintenance Alerts: Scheduled maintenance, equipment issues
- In-App Notifications: Real-time dashboard alerts
- Email Notifications: Detailed email reports
- SMS Alerts: Critical alerts via text message
- Mobile Push: Mobile app notifications
- Webhook Integration: Custom third-party integrations
interface Rule {
id: string;
name: string;
description: string;
trigger: {
cameras: string[];
objects: string[];
timeRange?: string;
conditions: string[];
};
actions: {
notification: boolean;
email: boolean;
sms: boolean;
webhook?: string;
};
priority: 'low' | 'medium' | 'high' | 'critical';
}Real-time system health monitoring with predictive analytics:
- Camera Health: Online/offline status, stream quality
- Server Performance: CPU, memory, disk usage
- Network Status: Bandwidth utilization, latency
- Storage Management: Available space, retention policies
- AI Performance: Processing speed, accuracy metrics
interface HealthStatus {
cameras: {
total: number;
online: number;
offline: number;
onlinePercentage: number;
};
servers: {
cpu: { usage: number; status: string };
memory: { usagePercentage: number; status: string };
database: { responseTime: number; status: string };
};
storage: {
primary: { usedPercentage: number; status: string };
backup: { usedPercentage: number; status: string };
};
}- Role-Based Access: Admin, Operator, Viewer permissions
- Custom Permissions: Granular access control
- Session Management: Secure authentication and logout
- Activity Logging: Complete audit trail
- General Settings: Timezone, date format, system name
- Camera Settings: Default configurations, stream quality
- Storage Settings: Retention policies, backup schedules
- AI Settings: Model selection, confidence thresholds
- Detection Rules: Custom object detection rules
- Alert Rules: Notification triggers and conditions
- Automation Rules: Automated responses to events
- Schedule Rules: Time-based rule activation
# Login
POST /api/auth/login
Content-Type: application/json
{
"username": "admin",
"password": "admin"
}
# Logout
POST /api/auth/logout
Authorization: Bearer <token># Get all cameras
GET /api/cameras
Authorization: Bearer <token>
# Add new camera
POST /api/cameras
Content-Type: application/json
{
"name": "Front Gate Camera",
"location": "Main Entrance",
"streamUrl": "rtsp://camera-ip:554/stream",
"aiFeatures": ["person_detection", "vehicle_detection"]
}
# Update camera
PUT /api/cameras/{camera_id}
Content-Type: application/json
# Delete camera
DELETE /api/cameras/{camera_id}
Authorization: Bearer <token># Submit query
POST /api/v1/contextual/query
Content-Type: application/json
{
"camera_id": "camera-123",
"query": "What do you see in this camera?"
}
# Response format
{
"success": true,
"response": "I can see 3 people walking in the hallway...",
"camera_id": "camera-123",
"camera_name": "Hallway Camera",
"timestamp": "2024-01-15T10:30:00Z",
"model": "yolov8n"
}# Get system health
GET /api/health
Authorization: Bearer <token>
# Get camera health
GET /api/health/cameras
Authorization: Bearer <token>
# Get server metrics
GET /api/health/servers
Authorization: Bearer <token># Get notifications
GET /api/notifications
Authorization: Bearer <token>
# Mark as read
PUT /api/notifications/{notification_id}/read
Authorization: Bearer <token>
# Get notification settings
GET /api/notifications/settings
Authorization: Bearer <token>- JWT-based Authentication: Secure token-based auth
- Role-Based Access Control: Granular permissions
- Session Management: Secure session handling
- Password Policies: Strong password requirements
- Multi-Factor Authentication: Optional 2FA support
- Encryption in Transit: TLS 1.3 for all communications
- Encryption at Rest: AES-256 for stored data
- Secure Storage: Encrypted video and image storage
- Data Anonymization: Privacy-preserving analytics
- GDPR Compliance: Data protection regulations
- API Rate Limiting: DDoS protection
- CORS Configuration: Cross-origin security
- Input Validation: Prevent injection attacks
- Security Headers: HSTS, CSP, and more
- Network Isolation: Secure network segmentation
# Environment Security
# Use strong secrets
NEXTAUTH_SECRET=$(openssl rand -base64 32)
# Database Security
# Use connection pooling and SSL
DATABASE_URL="postgresql://user:pass@localhost:5432/db?sslmode=require"
# API Security
# Implement rate limiting
RATE_LIMIT_REQUESTS=100
RATE_LIMIT_WINDOW=900
# File Security
# Restrict file permissions
chmod 600 .env.local
chmod 755 uploads/- First Contentful Paint: < 1.5s
- Largest Contentful Paint: < 2.5s
- Time to Interactive: < 3.0s
- Cumulative Layout Shift: < 0.1
- Bundle Size: < 250KB gzipped
- API Response Time: < 200ms average
- Database Query Time: < 50ms average
- Video Processing: Real-time (30 FPS)
- AI Inference Time: < 100ms per frame
- Concurrent Users: 1000+ supported
- Horizontal Scaling: Load balancer support
- Database Scaling: Read replicas and sharding
- CDN Integration: Global content delivery
- Caching Strategy: Redis and application-level caching
- Queue Management: Background job processing
// Frontend Optimizations
// Code splitting and lazy loading
const CameraManager = lazy(() => import('./CameraManager'));
// Image optimization
import Image from 'next/image';
// API optimization with React Query
const { data: cameras } = useQuery('cameras', fetchCameras, {
staleTime: 5 * 60 * 1000, // 5 minutes
cacheTime: 10 * 60 * 1000, // 10 minutes
});# Backend Optimizations
# Async processing
import asyncio
from fastapi import BackgroundTasks
# Database connection pooling
from sqlalchemy.pool import QueuePool
# Caching with Redis
import redis
cache = redis.Redis(host='localhost', port=6379, db=0)# Frontend Testing
npm run test # Unit tests with Jest
npm run test:e2e # End-to-end tests with Playwright
npm run test:coverage # Coverage reports
# Backend Testing
pytest # Python unit tests
pytest --cov # Coverage reports
pytest -k integration # Integration teststests/
βββ frontend/
β βββ components/
β βββ pages/
β βββ hooks/
β βββ utils/
βββ backend/
β βββ unit/
β βββ integration/
β βββ fixtures/
βββ e2e/
βββ auth.spec.ts
βββ cameras.spec.ts
βββ dashboard.spec.ts
# docker-compose.prod.yml
version: '3.8'
services:
frontend:
build: .
ports:
- "3000:3000"
environment:
- NODE_ENV=production
depends_on:
- backend
backend:
build: ./backend
ports:
- "8000:8000"
environment:
- ENVIRONMENT=production
depends_on:
- db
- redis
db:
image: postgres:14
environment:
POSTGRES_DB: a_ai_production
POSTGRES_USER: a_ai_user
POSTGRES_PASSWORD: secure_password
volumes:
- postgres_data:/var/lib/postgresql/data
redis:
image: redis:7-alpine
volumes:
postgres_data:# k8s-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: a-ai-frontend
spec:
replicas: 3
selector:
matchLabels:
app: a-ai-frontend
template:
metadata:
labels:
app: a-ai-frontend
spec:
containers:
- name: frontend
image: a-ai-frontend:latest
ports:
- containerPort: 3000
env:
- name: NODE_ENV
value: production# .github/workflows/deploy.yml
name: Deploy to Production
on:
push:
branches: [main]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '18'
- name: Install dependencies
run: npm ci
- name: Run tests
run: npm test
- name: Build application
run: npm run build
deploy:
needs: test
runs-on: ubuntu-latest
steps:
- name: Deploy to production
run: echo "Deploying to production..."We welcome contributions to the A-AI project! Here's how you can help:
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes
- Add tests for new functionality
- Ensure tests pass:
npm test - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
- Follow the existing code style
- Write tests for new features
- Update documentation as needed
- Use descriptive commit messages
- Keep pull requests focused and small
# Frontend
npm run lint # ESLint
npm run format # Prettier
# Backend
black . # Python formatting
flake8 . # Python linting
mypy . # Type checkingWhen reporting issues, please include:
- Clear description of the problem
- Steps to reproduce
- Expected vs actual behavior
- Environment details
- Screenshots if applicable
This project is licensed under the MIT License - see the LICENSE file for details.
MIT License
Copyright (c) 2024 A-AI Development Team
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
- Andhra Pradesh Government for organizing the hackathon
- Next.js Team for the amazing React framework
- Ultralytics for the YOLO AI models
- Vercel for deployment platform
- Radix UI for accessible components
- Tailwind CSS for utility-first styling
- GitHub Issues: Report bugs and feature requests
- Documentation: Full documentation
- Email: [email protected]
- LinkedIn: Rudra Sah
Built with β€οΈ for the Andhra Pradesh Government Hackathon
β Star this project β’ π Report Bug β’ β¨ Request Feature