| # | Feature | Description |
|---|---|---|
| π | Live Attack Globe | Three.js WebGL globe with real-time animated attack arcs β DDoS (red), Malware (amber), Brute-Force (cyan) |
| π | Threat Scanner | Scan files with ClamAV, URLs with URLScan.io, hashes with VirusTotal β D3.js radar chart analysis |
| πΊοΈ | Infrastructure Heatmap | D3.js force-directed graph of your servers/APIs/DBs colored by live risk score |
| π‘ | Live Threat Feed | Terminal-style real-time event stream via Redis pub/sub + Socket.io with sound alerts |
| π« | API Abuse Detector | Auto-detects API floods & brute-force attacks, blocks IPs, AbuseIPDB lookup + D3 charts |
| β οΈ | Incident Command Center | SOC-style incident queue with Gemini AI summaries and DETECTED β RESOLVED workflow |
| Layer | Technology |
|---|---|
| Frontend | Next.js 14 (App Router) + TailwindCSS + Framer Motion |
| 3D / Charts | Three.js (WebGL globe) + D3.js (force graph, radar, timeline) |
| Backend | Node.js + Express + TypeScript |
| Database | PostgreSQL 16 via Prisma ORM |
| Cache + Realtime | Redis pub/sub β Socket.io WebSockets |
| File Scanning | ClamAV (Dockerized) |
| Threat Intel | VirusTotal API v3 + AbuseIPDB + URLScan.io |
| AI | Google Gemini (incident summarization) |
| Observability | Prometheus metrics + Grafana dashboards |
| Containers | Docker Compose (8 services) |
Before you start, make sure you have these installed on your machine:
| Service | Where to Get It | Free Limit | Used For |
|---|---|---|---|
| VirusTotal | virustotal.com/gui/my-apikey | 500 req/day | Hash & URL malware lookup |
| AbuseIPDB | abuseipdb.com/register β API | 1,000 req/day | IP reputation scoring |
| URLScan.io | urlscan.io/user/signup β API Keys | 100 scans/day | URL screenshot + verdict |
| Google Gemini | aistudio.google.com/apikey | Free tier | AI incident summaries |
git clone https://github.com/vignesh2027/backend-optimization.git
cd backend-optimization
Copy the example env file:
cp .env.example .env
Now open .env in any text editor and fill in your API keys:
# Open with nano (terminal)
nano .env
# Or open with VS Code
code .env
Your .env file should look like this:
# ββ Database ββββββββββββββββββββββββββββββββββ
POSTGRES_USER=dbt
POSTGRES_PASSWORD=dbtpass
POSTGRES_DB=detectthreat
DATABASE_URL=postgresql://dbt:dbtpass@localhost:5432/detectthreat
# ββ Redis βββββββββββββββββββββββββββββββββββββ
REDIS_PASSWORD=redispass
REDIS_URL=redis://:redispass@localhost:6379
# ββ API Keys (paste yours here) βββββββββββββββ
VIRUSTOTAL_API_KEY=your_virustotal_key_here
ABUSEIPDB_API_KEY=your_abuseipdb_key_here
URLSCAN_API_KEY=your_urlscan_key_here
GEMINI_API_KEY=your_gemini_key_here
# ββ App βββββββββββββββββββββββββββββββββββββββ
NEXT_PUBLIC_API_URL=http://localhost:4000
NEXT_PUBLIC_WS_URL=ws://localhost:4000
PORT=4000
NODE_ENV=production
β οΈ Never commit your
.envfile to GitHub. Itβs already in.gitignoreso youβre safe.
docker compose up -d
This single command starts 8 containers:
| Container | What It Does | Port |
|---|---|---|
dbt-frontend |
Next.js cyberpunk UI | 3000 |
dbt-backend |
Express API + WebSocket | 4000 |
dbt-postgres |
PostgreSQL database | 5432 |
dbt-redis |
Redis pub/sub + cache | 6379 |
dbt-clamav |
Antivirus file scanner | 3310 |
dbt-prometheus |
Metrics collection | 9090 |
dbt-grafana |
Metrics dashboards | 3001 |
β³ First run takes 5β10 minutes β Docker needs to download and build all images. Subsequent starts take under 30 seconds.
Check that everything is running:
docker compose ps
You should see all containers showing Up or Up (healthy):
NAME STATUS
dbt-backend Up
dbt-clamav Up (healthy)
dbt-frontend Up
dbt-grafana Up
dbt-postgres Up (healthy)
dbt-prometheus Up
dbt-redis Up (healthy)
β οΈ If the backend shows
Restarting, wait 30 seconds and check again. It waits for PostgreSQL and Redis to be ready first.
Run this once to create all the database tables:
docker compose exec backend npx prisma db push
You should see:
β Your database is now in sync with your Prisma schema.
Seed the Incident Command Center with 3 realistic demo incidents:
curl -X POST http://localhost:4000/api/incidents/seed
| Service | URL | Login |
|---|---|---|
| π‘οΈ Main Platform | http://localhost:3000 | β |
| βοΈ Backend API | http://localhost:4000 | β |
| π Grafana Dashboards | http://localhost:3001 | admin / admin123 |
| π Prometheus Metrics | http://localhost:9090 | β |
http://localhost:3000http://localhost:3000/scannerhttp://localhost:3000/infrastructurehttp://localhost:3000/feedhttp://localhost:3000/abusehttp://localhost:3000/incidents# Stop all containers (keeps your data)
docker compose down
# Stop AND delete all data (fresh start)
docker compose down -v
docker compose logs backend --tail=30
Usually means database tables arenβt created yet. Run:
docker compose exec backend npx prisma db push
The backend might not have finished starting. Check:
docker compose logs backend --tail=20
Look for: [Server] Running on port 4000
Another app is using a port. Stop it or change the port in docker-compose.yml.
Already handled β ClamAV runs via Rosetta emulation (platform: linux/amd64).
docker compose down -v
docker compose build --no-cache
docker compose up -d
detect-backend-threat/
βββ π³ docker-compose.yml # All 8 services
βββ π .env.example # Copy this to .env
β
βββ π₯οΈ frontend/ # Next.js 14 App Router
β βββ app/
β β βββ page.tsx # π Attack Globe
β β βββ scanner/page.tsx # π Threat Scanner
β β βββ infrastructure/page.tsx # πΊοΈ Infra Heatmap
β β βββ feed/page.tsx # π‘ Live Feed
β β βββ abuse/page.tsx # π« Abuse Detector
β β βββ incidents/page.tsx # β οΈ Incident Center
β βββ components/
β βββ AttackGlobe.tsx # Three.js WebGL globe
β βββ InfraGraph.tsx # D3 force graph
β βββ ThreatRadar.tsx # D3 radar chart
β βββ Sidebar.tsx # Navigation
β
βββ βοΈ backend/ # Node.js + Express
β βββ src/
β β βββ index.ts # Server entry + Prometheus
β β βββ routes/ # scan, incidents, abuse, infra
β β βββ services/ # virustotal, urlscan, abuseipdb, gemini, clamav
β β βββ middleware/ # requestLogger, ipBlock
β β βββ websocket/ # Socket.io + Redis pub/sub
β βββ prisma/schema.prisma # DB schema
β
βββ π prometheus/prometheus.yml # Metrics scrape config
βββ π grafana/provisioning/ # Auto-provisioned dashboards
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/scan/file |
ClamAV file scan (multipart) |
POST |
/api/scan/url |
URLScan.io URL scan |
POST |
/api/scan/hash |
VirusTotal hash lookup |
GET |
/api/scan/history |
Recent scan results |
GET |
/api/incidents |
All incidents (priority sorted) |
POST |
/api/incidents |
Create new incident |
PATCH |
/api/incidents/:id/status |
Update incident status |
POST |
/api/incidents/:id/summarize |
Generate Gemini AI summary |
POST |
/api/incidents/seed |
Load demo incidents |
GET |
/api/abuse/stats |
Request rate stats + top IPs |
POST |
/api/abuse/check-ip |
AbuseIPDB IP lookup |
GET |
/api/abuse/blocked |
List blocked IPs |
DELETE |
/api/abuse/blocked/:ip |
Unblock an IP |
GET |
/api/infrastructure/topology |
Force graph node/link data |
GET |
/metrics |
Prometheus metrics endpoint |
GET |
/health |
Health check |
The platform uses a cyberpunk dark theme:
| Token | Color | Usage |
|---|---|---|
| Background | #0a0a0f |
Page base |
| Panel | #0d0d1a |
Glass panels |
| Neon Cyan | #00f5ff |
Primary accent, borders |
| Neon Green | #39ff14 |
Safe/clean/online |
| Threat Red | #ff2d55 |
Critical threats, DDoS |
| Threat Amber | #ff9500 |
Malware, warnings |
| Font | JetBrains Mono | All text |
CSS effects: glassmorphism panels, CRT scanline animation, neon glow shadows, animated attack arcs.
git checkout -b feature/your-featuregit commit -m 'feat: add your feature'git push origin feature/your-featureMIT License β free to use, modify, and distribute.