Files
box-box/documentations/refactor/README.md

4.7 KiB

box-box Refactor Brief

Purpose

This directory captures the planning baseline for the next major evolution of box-box. The current project has a strong live timing core, especially through the official F1 live feed, but the rest of the app still behaves like an on-demand OpenF1 client. That makes historical and session data unreliable, especially during live-session API lockouts.

The refactor direction is to make the Web UI the primary product surface, make historical data local-first, and preserve the TUI live mode that already works well. These documents are intentionally strategic and research-ready. They are not implementation tickets yet.

Strategic Defaults

  • Frontend: React + TypeScript, built with Vite.
  • Backend: Go remains the application and API server.
  • Storage: SQLite becomes a real local domain database, not only an HTTP cache.
  • Historical ingestion: OpenF1 REST is the first ingestion/backfill source.
  • Live timing: official F1 SignalR remains the live source.
  • Ingestion model: explicit CLI backfill plus opportunistic small web fetches.
  • TUI: preserve the current live mode; new historical/analytics work focuses on the Web UI first.
  • Product stance: race-weekend first, local-first, no rushed implementation.
  • Live persistence: persist live SignalR events/snapshots as a separate append-only stream once the live bridge is extracted; do not merge them into post-session OpenF1 records without a reconciliation design.
  • Migration: keep the current raw HTTP cache behavior intact while introducing the new domain database incrementally.

Documents

External References

Current Repo Context

The existing application already has:

  • A Go OpenF1 client in internal/api.
  • A SQLite-backed raw HTTP cache and track outline persistence.
  • A Bubble Tea TUI in internal/ui.
  • A Go-served Web UI in internal/web.
  • A live SignalR bridge extracted into internal/live and reused by both TUI and Web mode through server-sent events.

The refactor should build on that progress instead of replacing it blindly. The goal is to separate source fetching, domain persistence, query/read models, and frontend experience so each layer can be improved without destabilizing the others.