Commit Graph

4 Commits

Author SHA1 Message Date
AI-Engineer 0ac10d8a76 feat: add Prometheus metrics instrumentation to VIN Decoder API
CI — Build, Test, Push / test (pull_request) Failing after 18s
CI — Build, Test, Push / build-and-push (pull_request) Has been skipped
- Add src/metrics.js: zero-dep Prometheus text exposition for
  api_requests_total (counter), api_response_duration_seconds (histogram),
  api_data_freshness_seconds (gauge)
- Instrument src/server.js with onResponse hook recording every request;
  add GET /metrics endpoint (no proxy-secret required)
- Update src/nhtsa.js to call recordNhtsaCall() after every successful
  upstream NHTSA vPIC fetch (drives freshness gauge)
- Add src/tests/metrics.test.js: unit tests asserting /metrics returns
  text with Content-Type text/plain, all three metric names present,
  HELP/TYPE lines correct, counters increment, freshness is near-zero
- Add flux/vin-decoder/servicemonitor.yaml: ServiceMonitor for Prometheus
  auto-discovery of the /metrics endpoint
- Update flux/vin-decoder/kustomization.yaml to include servicemonitor.yaml

Closes leeworks-agents/api-company#129
2026-05-31 20:10:14 +00:00
AI-Manager ca0bbe7d7e Merge pull request '[Phase 0/3] Scaffold vin-decoder repo: server, data layer, Flux manifests, CI' (#1) from feature/issue-122-scaffold into main
CI — Build, Test, Push / test (push) Failing after 5s
CI — Build, Test, Push / build-and-push (push) Has been skipped
2026-05-30 20:09:29 +00:00
agent-company 67097cf976 feat: scaffold vin-decoder repo — server, data layer, Flux manifests, CI
CI — Build, Test, Push / test (pull_request) Failing after 6s
CI — Build, Test, Push / build-and-push (pull_request) Has been skipped
Closes leeworks-agents/api-company#122

- openapi.yaml: copied from leeworks-agents/api-company apis/vin-decoder/openapi.yaml (canonical spec)
- src/db.js: SQLite database init with vin_cache schema and indexes
- src/nhtsa.js: NHTSA vPIC fetch + field mapping
- src/cache.js: cache read/write with 90-day TTL, validateVin, getCacheStats, evictExpired
- src/server.js: Fastify server implementing GET /v1/decode, POST /v1/batch, GET /v1/health
  - X-RapidAPI-Proxy-Secret middleware on /decode and /batch
  - X-Request-Id, X-Cache, X-Data-Source response headers
  - Returns 403 for missing/wrong proxy secret
- scripts/seed.js: pre-warm cache with known VINs, runs eviction sweep
- src/tests/cache.test.js: unit tests for validateVin + cache integration (Honda Accord VIN)
- Dockerfile: Node 20 alpine, non-root, healthcheck on /v1/health
- .gitea/workflows/ci.yaml: test → build → push to registry.leeworks.dev/vin-decoder/api:<sha>
- flux/vin-decoder/: Namespace, Deployment (with RAPIDAPI_PROXY_SECRET from secret), Service, Ingress (vin.leeworks.dev + TLS), Kustomization
- .gitignore: node_modules, data/, .env
2026-05-30 20:08:47 +00:00
AI-Manager 79178119ba Initial commit 2026-05-30 15:02:51 +00:00