How packetwarden/wetnav works
Project Type and Purpose
• This is a Next.js–based full-stack (build-time) application with a React frontend that delivers a static-style UI for security analysts to look up Windows Security and Sysmon events.
• It has no live database or external API at runtime; instead it ships pre-processed JSON data baked in at build time.
File Structure
• Top-level config files (next.config.mjs, tsconfig.json, tailwind.config.ts) define the build and styling environment.
• The process_stix.py script lives at root and is used offline to convert the MITRE STIX bundle into a clean JSON file (src/data/mitre_processed/techniques.json).
• src/data contains raw event JSON plus TypeScript mapping files (categories.ts, mitre.ts, scenarios.ts).
• src/app/page.tsx orchestrates server-side data loading and merging logic during Next.js’s build/SSR phase.
• src/components holds the React UI elements (search bar, event list, detail view, MITRE tabs).
• There is no separate “database” layer; all data lives in JSON files under src/data.
Key Insights from README
• Data sources are: Microsoft docs–derived JSON, manual TS mapping files, and a processed STIX JSON (from the Python script).
• Build logic merges these data sets into a unified “EventDetail” object per event, which is passed as props to the React components.
• The live site is deployed on Vercel and served as a static/SSR hybrid with client-side search interactivity.
Main Components
a. Data Sources Layer
• Raw Event JSON (sysmon_events.json, windows_events.json)
• Manual TS Mappings (categories.ts, mitre.ts, scenarios.ts)
• MITRE STIX Processor (process_stix.py) → techniques.json
b. Build/Server Layer (Next.js)
• next.config.mjs, tailwind.config.ts
• src/app/page.tsx: loads and merges all data at build/SSR time
c. Frontend Layer
• React Components in src/components (Header, Footer, EventCard, EventDetailView, MitreTabs, etc.)
• Client-side search/filter logic in EventSearchClient.tsx
• Styling with Tailwind CSS
d. Deployment Layer
• Vercel hosting (CDN, static assets)
Relationships and Data Flows
• The Python script ingests the official STIX bundle and outputs techniques.json.
• At build/SSR time, Next.js reads the raw event JSON + TS mappings + techniques.json → merges into enriched event objects.
• The merged data is serialized into the HTML/JS payload and sent to the client.
• The React components render the UI and implement client-side filtering/search.
• User actions (search, filter, select) drive in-browser state changes; no further server calls occur.
Architectural Patterns and Principles
• ETL Pipeline Pattern: offline Python script + build‐time merge
• Unidirectional Data Flow: data moves raw→merged→props→UI
• Component-Based UI: each view element is a reusable React component
• Static/SSR Hybrid: Next.js generates HTML at build/SSG or on request, then hydrates to a SPA