Keep source files under 500 lines whenever practical. When a component, utility, or route grows beyond that size, prefer extracting cohesive composables, child components, or focused helper modules instead of continuing to add unrelated behavior to the same file.
When building, updating, or restarting background services or production servers:
- Always verify health: After restarting a service, perform an explicit runtime verification on
127.0.0.1(e.g.curl -s -i http://127.0.0.1:PORT/api/auth/sessionor health check) to confirm the service is bound, running, and returning HTTP 200 OK before declaring completion. - Keep services loopback-isolated: Always bind to
HOST=127.0.0.1so the service is only accessible internally via the Cloudflare Tunnel and never exposed directly on public network interfaces. - Warn before service disruption: Inform the user before terminating active backend or WebSocket processes that may disconnect their current session.
- Use systemd for service restart: On this environment, Bitveins runs as a systemd unit. Always use
sudo systemctl restart bitveins.serviceafter a build instead of killing and running standalonenodecommands in the background. - Wait for build completion before restarting: When running
pnpm buildor background compilation tasks, always await complete build termination before issuingsudo systemctl restart bitveins.service. Restarting during an active build overwrites.output/serverwhile files are being generated, causing incomplete route bundles (ERR_MODULE_NOT_FOUND) and breaking UI APIs.