Skip to content

Latest commit

 

History

146 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

    ____       ____    _ ____
   / __ \___  / / /_  (_) __ \____  _____
  / / / / _ \/ / __ \/ / / / / __ \/ ___/
 / /_/ /  __/ / / / / / /_/ / /_/ (__  )
/_____/\___/_/_/ /_/_/\____/ .___/____/
                          /_/
Typing SVG

Status Build License


Loading

> SYSTEM_OVERVIEW

DelhiOps is a full-stack, real-time urban operations dashboard for monitoring Delhi NCR's critical city infrastructure. Built with a cyberpunk-inspired command center UI, it aggregates data from multiple government APIs, IoT sensors, and intelligence feeds into a unified situational awareness platform.

┌─────────────────────────────────────────────────────────────────────┐
│                     OPERATIONAL MODULES                             │
├──────────────┬──────────────┬──────────────┬───────────────────────┤
│  AIR QUALITY │   TRAFFIC    │    CRIME     │     INCIDENTS         │
│  ██████████  │  ██████████  │  ██████████  │  ██████████           │
│  AQI Monitor │  Flow Ctrl   │  Intel Hub   │  Response Mgmt       │
│  6 Pollutants│  Google Maps │  Hotspot Map │  Live Timeline        │
│  Radar Chart │  Zone Anlys  │  Area Rank   │  Severity Grid        │
│  Human Viz   │  Signal Mon  │  Live Feed   │  Charts               │
├──────────────┴──────────────┴──────────────┴───────────────────────┤
│  CAMERAS: 200+ feeds  │  AI TERMINAL  │  REPORTS  │  ADMIN PANEL  │
└────────────────────────┴───────────────┴──────────┴───────────────┘

> FEATURE_MATRIX

// AIR QUALITY INTELLIGENCE

  • SVG Human Silhouette with breathing animation
  • Pollutant Radar Chart (PM2.5, PM10, O3, NO2, SO2, CO)
  • Real-time AQI Gauge with color-coded danger levels
  • Live Feed terminal with scrollable readings
  • Trend analysis with interactive charts
  • CPCB + OpenWeatherMap API integration

// TRAFFIC COMMAND

  • Google Maps live traffic overlay
  • Zone-wise congestion analysis
  • Busy corridor identification
  • Traffic signal monitoring
  • Road network visualization
  • Camera grid with live feeds

// CRIME DASHBOARD

  • Interactive hotspot heatmap
  • Crime type & severity breakdown
  • Area ranking by crime density
  • Live incident feed
  • Statistical overview cards
  • Report filing system

// INCIDENT RESPONSE

  • Real-time incident timeline
  • Severity-based grid display
  • Status tracking (Open/Responding/Resolved)
  • Statistical analysis charts
  • Priority-based alert system
  • WebSocket live updates

> ARCHITECTURE

                          ┌─────────────────────────┐
                          │      NGINX / TUNNEL      │
                          │   (ngrok / cloudflare)   │
                          └────────────┬────────────┘
                                       │
                    ┌──────────────────┴──────────────────┐
                    │                                      │
          ┌─────────▼─────────┐              ┌─────────────▼──────────┐
          │   VITE DEV SERVER  │              │   EXPRESS 5 API        │
          │   React 19 + TS    │◄────────────►│   Node.js Backend      │
          │   Port: 5173       │   REST API   │   Port: 3000           │
          │                    │   WebSocket  │                        │
          │  ┌──────────────┐  │              │  ┌──────────────────┐  │
          │  │ 11 Pages     │  │              │  │ 7 Controllers    │  │
          │  │ 58 Components│  │              │  │ 8 Route Files    │  │
          │  │ 5 Hooks      │  │              │  │ 6 Middlewares    │  │
          │  │ 2 Contexts   │  │              │  │ 17 Services      │  │
          │  └──────────────┘  │              │  └──────────────────┘  │
          └────────────────────┘              └───────┬───────┬────────┘
                                                      │       │
                                          ┌───────────▼┐  ┌───▼──────────┐
                                          │ PostgreSQL  │  │    Redis     │
                                          │  + PostGIS  │  │  L1/L2 Cache │
                                          │  7 Tables   │  │  Smart TTLs  │
                                          └─────────────┘  └──────────────┘
                                                      │
                                          ┌───────────▼────────────┐
                                          │   EXTERNAL APIs        │
                                          │  ├─ CPCB (AQI)        │
                                          │  ├─ OpenWeatherMap     │
                                          │  ├─ Google Routes      │
                                          │  ├─ TomTom Traffic     │
                                          │  └─ Google Gemini AI   │
                                          └────────────────────────┘

> TECH_STACK

FRONTEND ARSENAL

Core React 19 • TypeScript 5.9 • Vite 7 • React Router 7
Styling Tailwind CSS 4 • Glassmorphism • CSS Animations • Custom Theming
Data Viz Recharts 3 • SVG Gauges • Radar Charts • Sparklines
Maps Google Maps API • Custom SVG Maps • Hotspot Heatmaps
Real-time Socket.IO Client • WebSocket Events • Live Feeds
AI Google Generative AI (Gemini) • AI Terminal Interface

BACKEND ARSENAL

Runtime Node.js 18+ • Express 5 • Nodemon
Database PostgreSQL 16 + PostGIS • 7 Tables • Materialized Views
Cache Redis 7 • L1 In-Memory • L2 Distributed • Smart TTLs
Auth JWT • bcrypt • Role-Based Access (Admin/Operator/Viewer)
Security Helmet • CORS • Rate Limiting • Request Validation (Joi)
Resilience Circuit Breaker • Retry Logic • Graceful Degradation
Logging Winston • Request Correlation IDs • Structured JSON Logs
Docs OpenAPI/Swagger UI • API Documentation

> QUICK_START

Prerequisites

# Required services
> node --version    # v18+
> psql --version    # PostgreSQL 13+
> redis-cli ping    # PONG

Installation

# Clone the repository
git clone https://github.com/ayushap18/Delhiops.git
cd Delhiops

# Install dependencies
cd backend && npm install && cd ..
cd frontend && npm install && cd ..

# Configure environment
cp backend/.env.example backend/.env
cp frontend/.env.example frontend/.env
# Edit .env files with your API keys and database credentials

# Initialize database
cd backend
npm run db:init      # Create tables
npm run db:seed      # Seed sample data
npm run db:migrate   # Run migrations
cd ..

Launch

# Terminal 1 — Backend
cd backend && npm run dev

# Terminal 2 — Frontend
cd frontend && npm run dev
  ┌─────────────────────────────────────────────────┐
  │                                                   │
  │   > Frontend:  http://localhost:5173               │
  │   > Backend:   http://localhost:3000               │
  │   > API Docs:  http://localhost:3000/api/docs      │
  │                                                   │
  │   Default Login:                                   │
  │     Email:    admin@delhi-ops.gov.in               │
  │     Password: (check .env ADMIN_PASSWORD)          │
  │                                                   │
  └─────────────────────────────────────────────────┘

> EXTERNAL_API_SETUP

To enable real data feeds, configure these API keys in backend/.env:

API Purpose Get Key
CPCB Air Quality Index data data.gov.in
OpenWeatherMap AQI fallback + Weather openweathermap.org
Google Routes Live traffic data Google Cloud Console
TomTom Traffic fallback developer.tomtom.com
Google Maps Frontend map rendering Google Cloud Console
Google Gemini AI Terminal assistant Google AI Studio

Without API keys, the system runs on mock data generators with realistic Delhi NCR patterns.


> CACHING_STRATEGY

REQUEST → L1 (In-Memory) → L2 (Redis) → Database → External API
             2000 entries     TTL-based     PostGIS     Circuit Breaker
             instant          ~1ms          ~5-50ms     ~100-500ms

Cache TTLs:
  ├─ AQI Data ........... 5 min
  ├─ Traffic Data ....... 2 min  (rush-hour: 30s)
  ├─ Incidents .......... 1 min
  ├─ Crime Data ......... 15 min
  ├─ Camera Feeds ....... 30 min
  └─ System Metrics ..... 10 min

Special:
  ├─ Rush-hour preload .. 7:30 AM & 5:00 PM IST
  └─ Cache warming ...... On server startup

> DATABASE_SCHEMA

-- Core Tables
air_quality_readings   -- AQI + 6 pollutants + geolocation
traffic_data           -- Congestion levels + speed + timestamps
crime_reports          -- Type, severity, status, location
cameras                -- Feed URLs, status, geolocation
incidents              -- Priority, status, assignments
users                  -- Auth + roles (Admin/Operator/Viewer)
system_metrics         -- CPU, memory, uptime tracking

-- Optimization
+ PostGIS spatial indexes
+ Time-based partitioning
+ Materialized views for aggregations
+ Data retention policies (Hot/Warm/Cold)

> PROJECT_STRUCTURE

Delhiops/
├── frontend/                    # React 19 + TypeScript
│   ├── src/
│   │   ├── components/          # 58 reusable components
│   │   │   ├── aqi/             # AQI gauge, radar, human indicator
│   │   │   ├── traffic/         # Maps, signals, cameras
│   │   │   ├── crime/           # Hotspots, rankings, charts
│   │   │   ├── incidents/       # Timeline, severity grid
│   │   │   ├── dashboard/       # Stats grid, alerts feed
│   │   │   ├── layout/          # Sidebar, header, status bar
│   │   │   └── shared/          # Tables, dialogs, spinners
│   │   ├── pages/               # 11 route pages
│   │   ├── hooks/               # 5 custom hooks
│   │   ├── contexts/            # Auth + Socket providers
│   │   └── lib/                 # API client, utils
│   └── vite.config.ts
│
├── backend/                     # Node.js + Express 5
│   ├── src/
│   │   ├── api/
│   │   │   ├── controllers/     # 7 resource controllers
│   │   │   ├── routes/          # 8 route definitions
│   │   │   ├── middlewares/     # Auth, logging, validation
│   │   │   └── validators/      # Joi request schemas
│   │   ├── services/            # 17 business logic services
│   │   ├── integrations/        # External API clients
│   │   ├── config/              # Environment configuration
│   │   └── utils/               # Logger, errors, pagination
│   ├── database/                # Migrations & scripts
│   ├── test/                    # 6 test suites
│   ├── docs/                    # OpenAPI specification
│   └── Dockerfile
│
└── .gitignore

> API_ENDPOINTS

POST   /api/v1/auth/login          # Authenticate user
POST   /api/v1/auth/register       # Register new user
POST   /api/v1/auth/logout         # Invalidate session
POST   /api/v1/auth/refresh        # Refresh JWT token
GET    /api/v1/auth/me             # Current user profile

GET    /api/v1/aqi                 # List AQI readings
POST   /api/v1/aqi                 # Submit new reading

GET    /api/v1/traffic             # Traffic data feed
POST   /api/v1/traffic             # Submit traffic data

GET    /api/v1/crime               # Crime reports
POST   /api/v1/crime               # File crime report

GET    /api/v1/incidents           # Incident list
POST   /api/v1/incidents           # Create incident
PATCH  /api/v1/incidents/:id       # Update incident

GET    /api/v1/cameras             # Camera feeds
POST   /api/v1/cameras             # Register camera

GET    /api/v1/system/metrics      # System health
GET    /api/docs                   # Swagger UI

> REAL_TIME_EVENTS

// Socket.IO Events (WebSocket)
socket.on('incident:new')          // New incident reported
socket.on('incident:update')       // Status change
socket.on('aqi:reading')           // New AQI sensor data
socket.on('traffic:update')        // Traffic flow change
socket.on('camera:status')         // Camera online/offline
socket.on('alert:broadcast')       // System-wide alert

// Features
├── Redis-backed adapter for horizontal scaling
├── Per-message deflate compression
├── Event batching (500ms intervals)
├── Automatic reconnection (2min max)
└── Role-based event filtering

> SECURITY

┌─────────────────────────────────────────┐
│           SECURITY LAYERS               │
├─────────────────────────────────────────┤
│  Helmet.js ............. HTTP headers   │
│  CORS .................. Origin control │
│  JWT + Blacklist ....... Auth tokens    │
│  bcrypt ................ Password hash  │
│  Rate Limiter .......... DDoS protect   │
│  Joi Validation ........ Input sanitize │
│  Request IDs ........... Audit trail    │
│  Role-Based Access ..... Permission mgmt│
│  Token Blacklist ....... Logout enforce │
│  Circuit Breaker ....... API resilience │
└─────────────────────────────────────────┘

> SCREENSHOTS

Screenshots of the dashboard will be added here.


╔══════════════════════════════════════════════════════════════╗
║                                                              ║
║   [SYS] DelhiOps v1.0.0                                     ║
║   [INF] All modules operational                              ║
║   [INF] Monitoring Delhi NCR: 1,484 sq km                    ║
║   [INF] Population coverage: 32M+                            ║
║   [INF] System ready.                                        ║
║                                                              ║
║         Built with purpose. Deployed with precision.         ║
║                                                              ║
╚══════════════════════════════════════════════════════════════╝
EOF

Made with City

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages