mirror of
https://github.com/koala73/worldmonitor.git
synced 2026-04-25 17:14:57 +02:00
* feat(proto): generate unified worldmonitor.openapi.yaml bundle Adds a third protoc-gen-openapiv3 invocation that merges every service into a single docs/api/worldmonitor.openapi.yaml spanning all 68 RPCs, using the new bundle support shipped in sebuf 0.11.0 (SebastienMelki/sebuf#158). Per-service YAML/JSON files are untouched and continue to back the Mintlify docs in docs/docs.json. The bundle runs with strategy: all and bundle_only=true so only the aggregate file is emitted, avoiding duplicate-output conflicts with the existing per-service generator. Requires protoc-gen-openapiv3 >= v0.11.0 locally: go install github.com/SebastienMelki/sebuf/cmd/protoc-gen-openapiv3@v0.11.0 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * docs(proto): bump sebuf to v0.11.0 and document unified OpenAPI bundle - Makefile: SEBUF_VERSION v0.7.0 → v0.11.0 (required for bundle support). - proto/buf.gen.yaml: point bundle_server at https://api.worldmonitor.app. - CONTRIBUTING.md: new "OpenAPI Output" section covering per-service specs vs the unified worldmonitor.openapi.yaml bundle, plus a note that all three sebuf plugins must be installed from the pinned version. - AGENTS.md: clarify that `make generate` also produces the unified spec and requires sebuf v0.11.0. - CHANGELOG.md: Unreleased entry announcing the bundle and version bump. Also regenerates the bundle with the updated server URL. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * chore(codegen): regenerate TS client/server with sebuf v0.11.0 Mechanical output of the bumped protoc-gen-ts-client and protoc-gen-ts-server. Two behavioral improvements roll in from sebuf: - Proto enum fields now use the proper `*_UNSPECIFIED` sentinel in default-value checks instead of the empty string, so generated query-string serializers correctly omit enum params only when they actually equal the proto default. - `repeated string` query params now serialize via `forEach(v => params.append(...))` instead of being coerced through `String(req.field)`, matching the existing `parseStringArray()` contract on the server side. All files also drop the `// @ts-nocheck` header that earlier sebuf versions emitted — 0.11.0 output type-checks cleanly under our tsconfig. No hand edits. Reproduce with `make install-plugins && make generate`. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * fix(proto): bump sebuf v0.11.0 → v0.11.1, realign tests with repeated-param wire format - Bump SEBUF_VERSION to v0.11.1, pulling in the OpenAPI fix for repeated scalar query params (SebastienMelki/sebuf#161). `repeated string` fields now emit `type: array` + `items.type: string` + `style: form` + `explode: true` instead of `type: string`, so SDK generators consuming the unified bundle produce correct array clients. - Regenerate all 12 OpenAPI specs (unified bundle + Aviation, Economic, Infrastructure, Market, Trade per-service). TS client/server codegen is byte-identical to v0.11.0 — only the OpenAPI emitter was out of sync. - Update three tests that asserted the pre-v0.11 comma-joined wire format (`symbols=AAPL,MSFT`) to match the current repeated-param form (`symbols=AAPL&symbols=MSFT`) produced by `params.append(...)`: - tests/market-service-symbol-casing.test.mjs (2 cases: getAll) - tests/stock-analysis-history.test.mts - tests/stock-backtest.test.mts Locally: test:data 6619/6619 pass, typecheck clean, lint exit 0. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Apply suggestions from code review Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
8.1 KiB
8.1 KiB
AGENTS.md
Agent entry point for WorldMonitor. Read this first, then follow links for depth.
What This Project Is
Real-time global intelligence dashboard. TypeScript SPA (Vite + Preact) with 86 panel components, 60+ Vercel Edge API endpoints, a Tauri desktop app with Node.js sidecar, and a Railway relay service. Aggregates 30+ external data sources (geopolitics, military, finance, climate, cyber, maritime, aviation).
Repository Map
.
├── src/ # Browser SPA (TypeScript, class-based components)
│ ├── app/ # App orchestration (data-loader, refresh-scheduler, panel-layout)
│ ├── components/ # 86 UI panels + map components (Panel subclasses)
│ ├── config/ # Variant configs, panel/layer definitions, market symbols
│ ├── services/ # Business logic (120+ service files, organized by domain)
│ ├── types/ # TypeScript type definitions
│ ├── utils/ # Shared utilities (circuit-breaker, theme, URL state, DOM)
│ ├── workers/ # Web Workers (analysis, ML/ONNX, vector DB)
│ ├── generated/ # Proto-generated client/server stubs (DO NOT EDIT)
│ ├── locales/ # i18n translation files
│ └── App.ts # Main application entry
├── api/ # Vercel Edge Functions (plain JS, self-contained)
│ ├── _*.js # Shared helpers (CORS, rate-limit, API key, relay)
│ ├── health.js # Health check endpoint
│ ├── bootstrap.js # Bulk data hydration endpoint
│ └── <domain>/ # Domain-specific endpoints (aviation/, climate/, etc.)
├── server/ # Server-side shared code (used by Edge Functions)
│ ├── _shared/ # Redis, rate-limit, LLM, caching, response headers
│ ├── gateway.ts # Domain gateway factory (CORS, auth, cache tiers)
│ ├── router.ts # Route matching
│ └── worldmonitor/ # Domain handlers (mirrors proto service structure)
├── proto/ # Protobuf definitions (sebuf framework)
│ ├── buf.yaml # Buf configuration
│ └── worldmonitor/ # Service definitions with HTTP annotations
├── shared/ # Cross-platform data (JSON configs for markets, RSS domains)
├── scripts/ # Seed scripts, build helpers, data fetchers
├── src-tauri/ # Tauri desktop shell (Rust + Node.js sidecar)
│ └── sidecar/ # Node.js sidecar API server
├── tests/ # Unit/integration tests (node:test runner)
├── e2e/ # Playwright E2E specs
├── docs/ # Mintlify documentation site
├── docker/ # Docker build for Railway services
├── deploy/ # Deployment configs
└── blog-site/ # Static blog (built into public/blog/)
How to Run
npm install # Install deps (also runs blog-site postinstall)
npm run dev # Start Vite dev server (full variant)
npm run dev:tech # Start tech-only variant
npm run typecheck # tsc --noEmit (strict mode)
npm run typecheck:api # Typecheck API layer separately
npm run test:data # Run unit/integration tests
npm run test:sidecar # Run sidecar + API handler tests
npm run test:e2e # Run all Playwright E2E tests
make generate # Regenerate proto stubs + per-service & unified OpenAPI specs (requires buf + sebuf v0.11.0 plugins)
Architecture Rules
Dependency Direction
types -> config -> services -> components -> app -> App.ts
types/has zero internal importsconfig/imports only fromtypes/services/imports fromtypes/andconfig/components/imports from all aboveapp/orchestrates components and services
API Layer Constraints
api/*.jsare Vercel Edge Functions: self-contained JS only- They CANNOT import from
../src/or../server/(different runtime) - Only same-directory
_*.jshelpers and npm packages - Enforced by
tests/edge-functions.test.mjsand pre-push hook esbuild check
Server Layer
server/code is bundled INTO Edge Functions at deploy time via gatewayserver/_shared/contains Redis client, rate limiting, LLM helpersserver/worldmonitor/<domain>/has RPC handlers matching proto services- All handlers use
cachedFetchJson()for Redis caching with stampede protection
Proto Contract Flow
proto/ definitions -> buf generate -> src/generated/{client,server}/ -> handlers wire up
- GET fields need
(sebuf.http.query)annotation repeated stringfields needparseStringArray()in handlerint64maps tostringin TypeScript- CI checks proto freshness via
.github/workflows/proto-check.yml
Variant System
The app ships multiple variants with different panel/layer configurations:
full(default): All featurestech: Technology-focused subsetfinance: Financial markets focuscommodity: Commodity markets focushappy: Positive news only
Variant is set via VITE_VARIANT env var. Config lives in src/config/variants/.
Key Patterns
Adding a New API Endpoint
- Define proto message in
proto/worldmonitor/<domain>/ - Add RPC with
(sebuf.http.config)annotation - Run
make generate - Create handler in
server/worldmonitor/<domain>/ - Wire handler in domain's
handler.ts - Use
cachedFetchJson()for caching, include request params in cache key
Adding a New Panel
- Create
src/components/MyPanel.tsextendingPanel - Register in
src/config/panels.ts - Add to variant configs in
src/config/variants/ - Wire data loading in
src/app/data-loader.ts
Circuit Breakers
src/utils/circuit-breaker.tsfor client-side- Used in data loaders to prevent cascade failures
- Separate breaker per data domain
Caching
- Redis (Upstash) via
server/_shared/redis.ts cachedFetchJson()coalesces concurrent cache misses- Cache tiers: fast (5m), medium (10m), slow (30m), static (2h), daily (24h)
- Cache key MUST include request-varying params
Testing
- Unit/Integration:
tests/*.test.{mjs,mts}usingnode:testrunner - Sidecar tests:
api/*.test.mjs,src-tauri/sidecar/*.test.mjs - E2E:
e2e/*.spec.tsusing Playwright - Visual regression: Golden screenshot comparison per variant
CI Checks (GitHub Actions)
| Workflow | Trigger | What it checks |
|---|---|---|
typecheck.yml |
PR + push to main | tsc --noEmit for src and API |
lint.yml |
PR (markdown changes) | markdownlint-cli2 |
proto-check.yml |
PR (proto changes) | Generated code freshness |
build-desktop.yml |
Manual | Tauri desktop build |
test-linux-app.yml |
Manual | Linux AppImage smoke test |
Pre-Push Hook
Runs automatically before git push:
- TypeScript check (src + API)
- CJS syntax validation
- Edge function esbuild bundle check
- Edge function import guardrail test
- Markdown lint
- MDX lint (Mintlify compatibility)
- Version sync check
Deployment
- Web: Vercel (auto-deploy on push to main)
- Relay/Seeds: Railway (Docker, cron services)
- Desktop: Tauri builds via GitHub Actions
- Docs: Mintlify (proxied through Vercel at
/docs)
Critical Conventions
fetch.bind(globalThis)is BANNED. Use(...args) => globalThis.fetch(...args)instead- Edge Functions cannot use
node:http,node:https,node:zlib - Always include
User-Agentheader in server-side fetch calls - Yahoo Finance requests must be staggered (150ms delays)
- New data sources MUST have bootstrap hydration wired in
api/bootstrap.js - Redis seed scripts MUST write
seed-meta:<key>for health monitoring