How nethajinirmal13/worldmonitor works
Purpose and Entry Points
World Monitor is a TypeScript situational-awareness dashboard combining geospatial intelligence, news, market, infrastructure, and AI analysis. It produces World, Tech, and Finance variants from one codebase, deployable as a Vite SPA/PWA, Vercel API deployment, or Tauri desktop application.
Browser startup flows through index.html, src/main.ts, and src/App.ts. Variant-specific composition is configured under src/config/variants/base.ts, src/config/variants/tech.ts, and src/config/variants/finance.ts.
Frontend Intelligence Workspace
The application is centered on a MapLibre/deck.gl map plus independently polling panels. Map interactions, overlays, clusters, popups, and country navigation are implemented in src/components/MapContainer.ts, src/components/DeckGLMap.ts, and src/components/CountryBriefPage.ts.
Panels consume normalized service outputs and static domain data rather than directly owning most upstream integration. Feature selection, panel visibility, feed sets, and map layers vary by build/runtime variant through src/config/panels.ts, src/config/feeds.ts, and src/config/variant.ts.
Client Data and Analysis Pipeline
Domain services are grouped by vertical (src/services/conflict/index.ts, src/services/market/index.ts, src/services/intelligence/index.ts) and combine API data with browser-resident analysis. The central fusion layer is src/services/signal-aggregator.ts; downstream correlation and convergence logic live in src/services/correlation.ts and src/services/geo-convergence.ts.
News follows an immediate-render then enrichment model: ingestion and clustering use src/services/live-news.ts, src/services/clustering.ts, and src/services/entity-extraction.ts. Browser workers provide asynchronous ML/analysis without blocking rendering: src/workers/analysis.worker.ts, src/workers/ml.worker.ts, and src/services/ml-worker.ts.
Contract-First RPC Boundary
New API functionality is defined as Proto services, then generated into typed client/server bindings and OpenAPI artifacts. Contracts are under proto/worldmonitor/*/v1/service.proto; representative RPC definitions include proto/worldmonitor/intelligence/v1/classify_event.proto and proto/worldmonitor/market/v1/list_market_quotes.proto.
Generated browser clients reside in src/generated/client/worldmonitor/, while server interfaces are in src/generated/server/worldmonitor/. The Edge gateway entry point, api/[domain]/v1/[rpc].ts, dispatches requests to the common router in server/router.ts and domain handlers such as server/worldmonitor/intelligence/v1/handler.ts.
Backend Adapters, Resilience, and Security
The backend normalizes external providers into RPC responses. Domain operations are implemented as focused handlers, e.g. server/worldmonitor/conflict/v1/list-acled-events.ts, server/worldmonitor/maritime/v1/get-vessel-snapshot.ts, and server/worldmonitor/infrastructure/v1/get-cable-health.ts.
Caching and resilience are shared concerns: Redis access is centralized in server/_shared/redis.ts, while API error translation and CORS are bounded by server/error-mapper.ts and server/cors.ts. Legacy Vercel functions coexist for specialized/proxy behavior, notably api/rss-proxy.js, api/youtube/embed.js, and api/story.js. Edge access is additionally screened by middleware.ts.
Deployment Topology and External Services
The primary hosted runtime is Vercel: static SPA plus Edge endpoints configured by vercel.json. Upstash Redis supports shared caching/deduplication. Upstreams span RSS, geopolitical, market, aviation, maritime, AI, and mapping providers; provider calls are deliberately isolated behind server handlers so browser clients do not receive most credentials.
Railway is an optional relay runtime launched via scripts/ais-relay.cjs, supporting persistent AIS/WebSocket traffic and alternate-origin proxying for blocked upstreams. Nginx compression/proxy deployment support is in deploy/nginx/brotli-api-proxy.conf.
Desktop and Local-First Runtime
Tauri packages the same frontend for macOS, Windows, and Linux. Native startup, keychain/session-token handling, and desktop commands originate in src-tauri/src/main.rs; product variants are described by src-tauri/tauri.conf.json, src-tauri/tauri.tech.conf.json, and src-tauri/tauri.finance.conf.json.
The desktop process starts a local Node sidecar at src-tauri/sidecar/local-api-server.mjs. Frontend requests route through src/services/tauri-bridge.ts; the sidecar executes local handlers first, applies local authentication/compression, and can fall back to the cloud API. This establishes the main trust boundary: OS-managed desktop secrets and localhost API execution versus hosted Vercel services.
Main entry points: index.ts Domain services · App.ts Variant application shell · handler.ts Domain handlers · MapContainer.ts Map and country workspace
Components 22
Browser workspace
- SPA bootstrap
src/main.ts - Variant application shell
src/App.ts - Build variants · Selects World, Tech, and Finance composition.
src/config/variants/base.ts - Map and country workspace · Renders map layers, interactions, clusters, and country views.
src/components/MapContainer.ts - Panels, feeds, and layers
src/config/panels.ts - Domain services · Normalizes vertical conflict, market, and intelligence data.
src/services/intelligence/index.ts - News ingestion and enrichment · Immediate rendering followed by clustering and entity enrichment.
src/services/live-news.ts - Signal fusion and correlation · Aggregates signals and derives correlation and geo-convergence.
src/services/signal-aggregator.ts - Browser analysis workers · Runs ML and analysis off the rendering thread.
src/workers/analysis.worker.ts
RPC contracts
- Proto RPC definitions
proto/worldmonitor/intelligence/v1/classify_event.proto - Generated browser clients
Hosted API
- Edge RPC gateway · Routes domain/RPC requests into the common server router.
api/[domain]/v1/[rpc].ts - Common RPC router
server/router.ts - Domain handlers · Normalizes upstream domain operations into RPC responses.
server/worldmonitor/intelligence/v1/handler.ts - Shared Redis cache · Supports caching and deduplication.
server/_shared/redis.ts - Specialized legacy functions · Provides RSS, embed, and story proxy behavior.
api/rss-proxy.js
Desktop runtime
- Tauri native host · Owns native startup, keychain/session tokens, and commands.
src-tauri/src/main.rs - Desktop request bridge
src/services/tauri-bridge.ts - Local API sidecar · Runs local handlers and falls back to the cloud API.
src-tauri/sidecar/local-api-server.mjs
Deployment & upstreams
- Vercel hosted runtime
vercel.json - External data providers · Credentials remain behind server-side adapters.
- Optional AIS relay · Handles AIS/WebSocket traffic and alternate-origin proxying.
scripts/ais-relay.cjs
Connections 25
- SPA bootstrap → Variant application shell: mounts
- Variant application shell → Build variants: selects
- Variant application shell → Map and country workspace: composes
- Build variants → Panels, feeds, and layers: configures
- Panels, feeds, and layers → Map and country workspace: controls
- Map and country workspace → Domain services: polls data
- Domain services → News ingestion and enrichment: uses news
- Domain services → Signal fusion and correlation: feeds signals
- News ingestion and enrichment → Signal fusion and correlation: enriches
- Signal fusion and correlation → Browser analysis workers: offloads analysis
- Domain services → Generated browser clients: calls
- Proto RPC definitions → Generated browser clients: generates
- Generated browser clients → Edge RPC gateway: typed RPC
- Edge RPC gateway → Common RPC router: dispatches
- Common RPC router → Domain handlers: routes domain calls
- Domain handlers → Shared Redis cache: caches and deduplicates
- Domain handlers → External data providers: adapts
- Specialized legacy functions → External data providers: proxies
- Vercel hosted runtime → Edge RPC gateway: hosts
- Tauri native host → Variant application shell: packages frontend
- Tauri native host → Local API sidecar: starts
- Domain services → Desktop request bridge: desktop transport
- Desktop request bridge → Local API sidecar: localhost requests
- Local API sidecar → Domain handlers: local-first / cloud fallback
- Optional AIS relay → External data providers: relays persistent traffic