How swarnim-sawane/har-file-analyser works
Purpose and Entry Points
HAR File Analyzer is an internal diagnostic system for browser HAR files and console logs. It surfaces request failures, performance issues, request flows, sanitization, comparisons, and optional AI summaries. Browser startup is src/main.tsx into src/App.tsx; the API starts at backend/src/server.ts; asynchronous processing starts at backend/src/worker.ts. backend/src/combinedRuntime.ts supports a combined API/worker runtime.
Frontend Analysis Workspace
The React/Vite frontend owns interactive file selection, progressive results, filtering, details, visualizations, and AI surfaces. src/hooks/useHarData.ts and src/hooks/useConsoleLogData.ts coordinate retrieval and UI state; src/services/apiClient.ts and src/services/websocketClient.ts establish backend REST and Socket.IO boundaries. Primary result surfaces are organized in src/components/HarTabContent.tsx, src/components/ConsoleLogTabContent.tsx, and src/components/AiInsightsSurface.tsx.
Upload and Event Flow
The browser uploads HAR/log files in validated chunks through src/services/chunkedUploader.ts and upload components such as src/components/UnifiedUploader.tsx. Backend upload endpoints in backend/src/routes/uploadRoutes.ts validate, assemble, and persist source artifacts through backend/src/services/artifactStore.ts, then enqueue processing. Upload status/progress crosses the API-worker boundary through Redis/BullMQ and Socket.IO, with backend socket support in backend/src/utils/socketHelper.ts.
Background Parsing and Persistence
The worker consumes queued upload jobs and turns source artifacts into queryable records. backend/src/workers/harProcessor.ts processes HAR content, backend/src/workers/logProcessor.ts handles console logs, and backend/src/workers/harEntryStorage.ts persists large HAR entry sets. PostgreSQL access and migrations are centralized in backend/src/persistence/postgresStore.ts and backend/src/persistence/postgresMigrations.ts; Redis queue connection/names are defined by backend/src/config/bullmqConfig.ts and backend/src/config/queueNames.ts.
Query, Automation, and OpenAPI Boundary
Express routes expose upload state, paged/searchable analysis data, sanitization, AI, operations, and stable automation endpoints. Core route groups are backend/src/routes/harRoutes.ts, backend/src/routes/consoleLogRoutes.ts, and backend/src/routes/automationRoutes.ts. backend/src/openapiSpec.ts publishes the OpenAPI contract for internal/OCI clients. The frontend does not need raw full-file parsing for normal hosted workflows; it consumes persisted API results and progressive previews.
Deterministic and AI Insight Pipeline
Client-side analyzers support local display and investigation logic, including src/utils/harAnalyzer.ts, src/utils/consoleLogAnalyzer.ts, and src/utils/requestFlowAnalyzer.ts. Backend automation builds bounded HAR evidence in backend/src/services/harAutomationService.ts; AI routes invoke configured OpenAI-compatible endpoints via backend/src/routes/aiRoutes.ts and track usage through backend/src/services/aiUsageService.ts. AI is optional: deterministic evidence/fallbacks remain authoritative when provider configuration or output is unavailable.
Runtime, Deployment, and Operational Boundaries
Node.js 22 hosts React/Vite development plus separate Express API and BullMQ worker processes. PostgreSQL stores metadata, parsed entries, and AI usage; Redis provides queues, progress, pub/sub, and worker coordination; artifact storage is local filesystem or OCI Object Storage. Local dependencies run via backend/docker-compose.yml. Hosted builds split application and worker images under deploy/hosted/Dockerfile.combined and deploy/hosted/Dockerfile.worker; the current VM process model is documented in VM_RUNBOOK.md. Readiness, operational status, error handling, and retention are represented by backend/src/routes/opsRoutes.ts, backend/src/middleware/errorHandler.ts, and backend/src/services/retentionCleanupService.ts.
Main entry points: server.ts Express API · useHarData.ts Analysis state hooks · uploadRoutes.ts Upload endpoints · postgresStore.ts PostgreSQL records
Components 19
Browser workspace
- React application · Interactive analysis workspace.
src/App.tsx - Analysis state hooks · Coordinate HAR and console result state.
src/hooks/useHarData.ts - API client
src/services/apiClient.ts - Socket client
src/services/websocketClient.ts - Chunked uploader · Validates and sends file chunks.
src/services/chunkedUploader.ts - Result and AI surfaces · HAR, console, and AI result views.
src/components/HarTabContent.tsx
API and realtime
- Express API · REST, Socket.IO, and route host.
backend/src/server.ts - Upload endpoints
backend/src/routes/uploadRoutes.ts - Analysis and automation API · HAR, console, and stable automation endpoints.
backend/src/routes/harRoutes.ts - Socket progress gateway
backend/src/utils/socketHelper.ts - OpenAPI contract
backend/src/openapiSpec.ts
Background processing
- BullMQ worker runtime · Consumes asynchronous upload jobs.
backend/src/worker.ts - HAR and log processors · Parse source artifacts into records.
backend/src/workers/harProcessor.ts
Analysis and AI
- HAR evidence builder · Builds bounded deterministic evidence.
backend/src/services/harAutomationService.ts - Optional AI insights · Uses configured OpenAI-compatible providers with usage tracking.
backend/src/routes/aiRoutes.ts
Storage and operations
- Artifact store · Local filesystem or OCI Object Storage.
backend/src/services/artifactStore.ts - PostgreSQL records · Metadata, parsed entries, and AI usage.
backend/src/persistence/postgresStore.ts - Redis and BullMQ · Jobs, progress, and worker coordination.
backend/src/config/bullmqConfig.ts - Operations and retention · Readiness, status, errors, and cleanup.
backend/src/routes/opsRoutes.ts
Connections 25
- React application → Analysis state hooks: drives state
- React application → Chunked uploader: selects files
- Analysis state hooks → API client: queries results
- Analysis state hooks → Socket client: subscribes progress
- Analysis state hooks → Result and AI surfaces: renders
- Chunked uploader → Upload endpoints: uploads chunks
- API client → Express API: REST
- Socket client → Socket progress gateway: Socket.IO
- Express API → Upload endpoints: hosts
- Express API → Analysis and automation API: hosts
- Express API → Optional AI insights: hosts
- Express API → OpenAPI contract: publishes
- Upload endpoints → Artifact store: persists sources
- Upload endpoints → Redis and BullMQ: enqueues job
- BullMQ worker runtime → Redis and BullMQ: consumes jobs
- BullMQ worker runtime → HAR and log processors: runs
- HAR and log processors → Artifact store: reads sources
- HAR and log processors → PostgreSQL records: persists records
- Redis and BullMQ → Socket progress gateway: progress events
- Analysis and automation API → PostgreSQL records: queries records
- Analysis and automation API → HAR evidence builder: builds evidence
- Optional AI insights → HAR evidence builder: uses evidence
- Optional AI insights → PostgreSQL records: tracks usage
- Operations and retention → PostgreSQL records: checks and cleans
- Operations and retention → Artifact store: retention cleanup