How hiroto-shida/rubikstation works
Project Type and Purpose
• This is a client‐only, single‐page application (SPA) built with React + TypeScript and Vite.
High-Level Architectural Overview
• Static Hosting Layer (e.g. GitHub Pages, Netlify)
• Serves index.html, /public assets, and the built files under docs/
• PWA Infrastructure
• manifest.webmanifest, service worker (sw.js + workbox), registerSW.js for offline support and “install app”
• Browser (Client)
• React Application (built by Vite)
• React Router (pages under src/pages)
• State Management (stores + context provider)
• Components (UI parts, procedures, timer, scramble, model, record & chart)
• Persistence Layer (cookies via src/tools/getBooleanCookies)
Main Components and Their Relationships
• Hosting & CDN
→ Service Worker caches assets → Browser
• React App (entry: main.tsx)
→ App.css + index.css
→ TimerStateProvider wraps everything
→ Router switches between pages (Index, Procedure, RubicModel, Help, Release, NotFound)
• Pages
• Index: combines scramble display (src/components/scramble), timer (src/components/timer), and record graph (src/components/record/Chart)
• Procedure: displays step-by-step solution components (src/components/procedure/Step1–Step7, StyledRubicModel, etc.)
• RubicModel: interactive cube model (src/components/rubicModel/*)
• Help & Release: static content pages
• Components communicate via:
• Props and presenters/containers
• Shared hooks (useCubePosition, useRotateCube, useKeyEvent, etc.)
• Global state stores (inspectionStore, modalOpenStore, procedureDrawerOpenStore)
Architectural Patterns & Design Principles
• Container–Presenter pattern for all UI components
• Unidirectional data flow with React Context + lightweight stores
• Hook abstraction for cross-cutting concerns (resize, touch, key events)
• PWA caching strategy with Workbox
Step-by-Step Creation Process
– Static Hosting (top)
– PWA Layer
– Client App (center)
– Persistence (bottom)
2. Inside Client App, nest:
– Around it, group Pages. Inside each Page, show key child components (Index has Timer, Scramble, Chart).
3. Service Worker to Client App for fetch and cache.
Final Touches
• Arrowheads indicate direction of data or control flow.
• Non-obvious interactions (e.g. “useKeyEvent hook listens for spacebar to start the timer”).