Phase 1: data pipeline (Postgres+Redis with in-memory fallback, mock telemetry publisher, WebSocket fan-out, hub /debug page)
CI / Lint, typecheck, test, build (pull_request) Failing after 10s

- packages/db: postgres.js + ioredis wrapper, StateStore interface with
  InMemory + Postgres implementations, schema migration runner
- apps/api: refactored to use @kerbal-rt/db; live WebSocket hub subscribes
  to store changes and broadcasts to all clients
- apps/tools/mock-telemetry: Node script that generates realistic KSP
  state and POSTs to /api/v1/ingest at 1Hz (uses same keplerian math
  as the live-map renderer)
- apps/hub: new /debug page that connects to /api/v1/live and shows
  the live state
- ksp/README.md: documents Phase 1c (real kRPC bridge) and the two
  implementation options
- Tests: 17 total (5 kepler math, 5 db store, 5 API health/state,
  2 API WebSocket fan-out)

End-to-end verified: mock publisher → API → hub /debug page,
11 snapshots/5s over WebSocket, vessels advancing in mean anomaly.
This commit is contained in:
Mavis
2026-06-02 18:54:46 +00:00
parent 938ba042b3
commit a457b9d96f
28 changed files with 2165 additions and 98 deletions
+34 -7
View File
@@ -3,8 +3,10 @@
A real-time web mirror of a no-warp Kerbal Space Program multiplayer server:
mission hub + 3D live solar system map.
> **Status: Phase 0 (skeleton)** — monorepo scaffolded, all three apps build,
> data pipeline / real KSP bridge lands in Phase 1.
> **Status: Phase 1 — data pipeline working end-to-end.**
> Mock telemetry publisher drives the API, the API stores snapshots, the
> hub debug page and the live map both consume the WebSocket. Real KSP
> bridge (Phase 1c) is documented and ready to plug in once you have KSP.
See [`kerbalrealtime-clone-plan.md`](./kerbalrealtime-clone-plan.md) for the
full implementation plan.
@@ -28,14 +30,17 @@ full implementation plan.
```
.
├── apps/
│ ├── hub/ # Next.js — marketing + calendar + media
│ ├── hub/ # Next.js — marketing + calendar + media + /debug
│ ├── live-map/ # Vite + Three.js — 3D solar system viewer
── api/ # Hono — REST + WS gateway
── api/ # Hono — REST + WS gateway
│ └── tools/
│ └── mock-telemetry/ # Node script that drives the pipeline with fake KSP state
├── packages/
│ ├── shared-types/ # TS types + Zod schemas for every API boundary
│ ├── orbital-math/ # Pure keplerian propagation, occultation, transfers
│ ├── db/ # Postgres+Timescale+Redis wrapper, StateStore interface
│ └── ui/ # Shared React components (Pill, Card, …)
├── ksp/ # KSP-side mods (Phase 1+)
├── ksp/ # KSP-side bridge (Phase 1c) — see ./ksp/README.md
├── infra/ # docker-compose, nginx, grafana, init SQL
└── scripts/ # dev.sh and friends
```
@@ -99,14 +104,36 @@ push / PR to `main`. See `.github/workflows/ci.yml`.
See [`kerbalrealtime-clone-plan.md`](./kerbalrealtime-clone-plan.md) for the
roadmap. Quick map:
- [x] **Phase 0** — monorepo, skeletons, docker-compose, CI _(this commit)_
- [ ] **Phase 1**KSP telemetry bridge + ingest pipeline (Postgres + Redis)
- [x] **Phase 0** — monorepo, skeletons, docker-compose, CI
- [x] **Phase 1a**persistence layer (Postgres+Timescale+Redis) with in-memory fallback
- [x] **Phase 1b** — mock telemetry publisher + WebSocket fan-out + hub /debug page
- [ ] **Phase 1c** — real kRPC bridge (see [`ksp/README.md`](./ksp/README.md))
- [ ] **Phase 2** — Live map 3D scene (time controls, focus, eclipses, overpass)
- [ ] **Phase 3** — Mission calendar, media, crew, YouTube/Twitch embeds
- [ ] **Phase 4** — Spacenomicon tools (delta-v, transfer calculator, etc.)
- [ ] **Phase 5** — Admin panel + polish
- [ ] **Phase 6** — Production deploy
## Verifying the Phase 1 pipeline
```bash
# Terminal 1: API
cd apps/api && PORT=4000 USE_IN_MEMORY=1 pnpm start
# Terminal 2: mock publisher
cd apps/tools/mock-telemetry && MOCK_API_URL=http://localhost:4000 pnpm start
# Terminal 3: hub
cd apps/hub && PORT=3000 pnpm start
# → open http://localhost:3000/debug to see the live state
```
For the WebSocket version, open the hub `/debug` page or use [wscat](https://github.com/websockets/wscat):
```bash
npx wscat -c ws://localhost:4000/api/v1/live
```
## License
This project is unaffiliated with Kerbal Space Program, Intercept Games, or