Skip to content

Hardcoded Values

Bryan Chen edited this page Apr 16, 2026 · 1 revision

Hardcoded Values and Keys

This page documents hardcoded constants that contributors are likely to touch.

Update this page whenever you change a constant that affects routing, persistence, analytics, or simulation behavior.

App Routing and Analytics

Defined in src/App.tsx.

  • GA_MEASUREMENT_ID = 'G-5XJFVLZQ0Z'
    • Controls Google Analytics target property.
    • If changed, validate page view events after consent.
  • GA_SCRIPT_ID = 'google-analytics-gtag'
    • DOM id used to avoid duplicate script injection.
  • COOKIE_CONSENT_KEY = 'physicssims-cookie-consent'
    • localStorage key for consent state (allow or deny).
  • FORMSPREE_ENDPOINT = import.meta.env.VITE_FORMSPREE_ENDPOINT
    • Environment-driven endpoint for contact submissions.
  • APP_ROUTES array
    • Main route map for all simulation and utility pages.
    • Keep in sync with KNOWN_SIM_PATHS when simulation routes change.

Admin and Persistence

Defined in src/config/internalAdmin.ts.

  • ADMIN_SESSION_KEY = 'physicssims-admin-session'
    • sessionStorage key for authenticated admin role.
  • ADMIN_CONTROLS_KEY = 'physicssims-admin-controls'
    • localStorage key for full admin control state.
  • ANALYTICS_EVENTS_KEY = 'physicssims-analytics-events'
    • localStorage key for internal analytics log.
  • DEFAULT_FEATURED_SIM_PATH = '/kinematics-2d'
    • Default featured sim route for home content overrides.
  • KNOWN_SIM_PATHS
    • Canonical list used by publish visibility controls.
    • Must include each route that should be toggleable in admin.
  • isInternalEnvironment() hostname allowlist
    • Allows internal admin on localhost, 127.0.0.1, ::1, *.internal, *.local, or env VITE_INTERNAL_ADMIN_ENABLED=true.

Collider Simulation Defaults

Defined in src/lib/collider/constants.ts.

  • DEFAULT_CONTROLS
    • Default startup values for beam energy, magnetic field, particle type, bunch count, collisions flag, and visual sensitivity controls.
  • MIN_CONTROLS and MAX_CONTROLS
    • Slider/control bounds for collider controls.
    • Keep these aligned with UI control ranges.
  • DETECTOR_POINTS
    • Hardcoded detector ids, names, and ring positions.
    • Used for detector hit and event visualization.
  • ACCELERATION_SECTORS
    • Hardcoded RF sector arcs in normalized ring coordinates.
  • PARTICLE_COLORS
    • Visual palette for each particle mode.
  • MAX_LOGS = 8
    • Limits retained collider event log entries.

Collider Runtime Timing

Defined in src/hooks/useColliderSimulation.ts.

  • SNAPSHOT_INTERVAL_MS = 120
    • UI snapshot update cadence from runtime state.
    • Lower values increase UI refresh frequency and can increase render cost.
  • dt clamp in animation frame loop (0.001 to 0.04 seconds)
    • Stabilizes simulation on slow or variable frame timing.

Deploy Base Path

Defined in vite.config.ts.

  • base: '/PhysicsSims/'
    • Required for GitHub Pages project-site hosting under repository path.
    • If repository name changes, update this and deployment docs.

Change Policy

Before merging a PR that changes hardcoded values:

  1. Confirm behavior in local dev.
  2. Verify any dependent list is updated (for example routes and known sim paths).
  3. Update this page with new values and rationale.

PhysicsSims Docs

Start Here

Contributor References

Quick Contributor Flow

  1. Read Development Setup
  2. Check Hardcoded Values and Keys
  3. Make changes and verify locally
  4. Update docs in Simulation Catalog or other affected pages
  5. Follow PR checklist in Contributing

Clone this wiki locally