This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
# Development
npm run dev # Start backend (8080) + frontend concurrently
npm run dev:backend # Start Express server only
npm run dev:frontend # Start Vite dev server only
# Build
npm run build # Build production frontend + generate SRI hashes
npm run build:no-sri # Build without SRI generation
# Production
npm start # Run production server (NODE_ENV=production)
# CSS optimization
npm run analyze-css # Analyze unused CSS
npm run optimize-css # Apply CSS purging┌─────────────┐ ┌─────────────┐ ┌──────────────┐
│ Browser │────▶│ Express │────▶│ Gemini API │
│ (React) │◀────│ Server │◀────│ (Google) │
└─────────────┘ └─────────────┘ └──────────────┘
Frontend Backend AI Service
│
▼
┌──────────────┐
│ WinDBG Server│
│ (Optional) │
└──────────────┘
server.js- Express backend with security middleware, session management, rate limiting, Gemini API proxy, and WinDBG proxyservices/geminiProxy.ts- Client-side service that routes API calls through backend with session cookiesservices/windbgService.ts- Client-side WinDBG integration (upload, poll, download via backend proxy)utils/sessionManager.ts- Client-side session initialization and error handlingserverConfig.js- Security configuration constants
- User uploads .dmp/.zip files
- Files categorized as 'minidump' (<5MB) or 'kernel' (≥5MB)
- Primary path (WinDBG): If
WINDBG_API_KEYis configured:- Client uploads file to backend → backend proxies to WinDBG server
- Backend polls WinDBG status until complete
- Backend downloads analysis and returns to client
- AI interprets WinDBG output for user-friendly report
- Fallback path: If WinDBG unavailable or fails:
- Client extracts ASCII/UTF-16LE strings and hex dumps locally
- Client sends request with session cookies
- Backend validates session, rate limits, and prompt content
- Backend proxies to Gemini API with server-side API key
- AI analysis returned to client
- Content Security Policy - Script validation, no unsafe-eval
- Subresource Integrity - SHA-384 hashes for all assets via
generate-sri.js - Prompt Validation - BSOD keyword requirements, abuse pattern blocking
- Session Management - XXHash session IDs, HttpOnly/Secure/SameSite cookies
- Rate Limiting - 50 requests/hour, 100K tokens/hour per session
- Cloudflare Turnstile - Bot protection on session creation
| Variable | Purpose | Required |
|---|---|---|
GEMINI_API_KEY |
Gemini AI API access | Yes |
TURNSTILE_SECRET_KEY |
Cloudflare verification | Production |
SESSION_SECRET |
Session security | Production |
WINDBG_API_KEY |
WinDBG server API access | No (falls back to local parsing) |
For local development, set in .env.local or export directly.
Pushes to main automatically deploy to Cloud Run. Secrets managed via Google Secret Manager.
# Manual deploy
./deploy-with-secret.sh
# Update secrets
./setup-all-secrets.sh
./update-turnstile-secret.sh- Add route in
server.js - Apply
requireSessionmiddleware for protected routes - Update client in
services/geminiProxy.ts
- CSP hashes: Run
node scripts/hash-inline-scripts.js - SRI hashes: Auto-generated during
npm run build - Rate limits: Update in
serverConfig.jsandserver.jsconstants
When users see session errors:
- Check
handleSessionError()inutils/sessionManager.tshandles the error code - Check cookie attributes are consistent across endpoints