Concept
Infrastructure (I/O)
Everything that talks to the outside world.
src/infrastructure/ holds anything that touches the network, the platform
clock, the file system, or the asset pipeline.
What ships
Ticker(timing.ts) — GSAP-synced game time scheduling.NetworkManager— spin requests.MockNetworkManagerfor dev; your RGS transport for prod.AssetLoader— Pixi bundle loader facade.Analytics— pluggable analytics transport.
Rules
- Called by
flow/(phases orchestrate it) andpresenters/(they need the ticker). - Never depends on
state/orview/— those should run without it. - Keep transport-specific code in one file per service. Two RGS providers = two implementations of
NetworkManager, picked incomposition.ts.
Why a layer, not scattered
Keeping I/O in one folder means swapping a transport is a one-file change. It also gives you a clear place to add cross-cutting concerns: retry policy, request tracing, rate limiting, offline fallback.