How kr3t3n/crosscribb works
Project type and purpose
• This is a client-side, single-page Progressive Web App (PWA) built in React + TypeScript.
• Its purpose is to provide an offline-capable scoring companion for Cribbage and Cross-Crib games, with real-time score tracking, history, stats, and theming.
File structure
• Top level:
• src/ – application code
• src/components/ – small, reusable UI pieces (Header, Footer, ScoreBoard, RoundHistory, etc.)
• src/pages/ – route-level views (Landing, GamePage, Contact, Privacy, Terms)
• src/contexts/ – React Context providers (ThemeContext for dark/light, plus potentially a GameContext)
• src/utils/ – pure business-logic functions (scoring.ts, stats.ts)
• src/types/ – TypeScript type definitions for game models
• Config/build: Vite (vite.config.ts), Tailwind (tailwind.config.js), ESLint, TS configs, Netlify deployment via static export
README for architectural insights
• State management via React Context + Local Storage
• PWA capabilities (service-worker, manifest) for offline support
• The build & deployment pipeline: Vite → optimized static assets → Netlify CDN
1. User & Browser (client)
2. PWA Shell (service-worker, manifest)
3. React SPA (App.tsx / React Router)
4. Pages (LandingPage, GamePage, etc.)
5. UI Components (Header, ScoreBoard, RoundScoring, GameStats, ThemeToggle…)
6. Context Layer (ThemeContext, GameContext)
7. Business Logic / Utils (scoring.ts, stats.ts)
8. Local Storage (persistent game state)
9. Build & Deployment (Vite bundler, Tailwind processing, Netlify hosting)
• User → Browser → PWA Shell
• PWA Shell → React SPA root
• React Router → Page components
• Pages & Components ↔ Context (read/write state)
• Components → Utils (compute scores, stats)
• Context & Utils ↔ Local Storage (persist, rehydrate)
• Source code → Vite → Bundled assets → Netlify (CI/CD)
c. Architectural patterns & principles:
• Single-Page Application (SPA) with client-side routing
• Component composition & separation of concerns (small UI units vs page-level containers)
• Context API for global cross-cutting concerns (theme, game state)
• Clear boundary between UI, state management, business logic, and storage
• PWA pattern for offline first
d. Key technologies & frameworks:
• React 18 + TypeScript
• React Context API
• Vite (ESM build tool)
• Tailwind CSS for utility-first styling
• Local Storage Web API
• Netlify static hosting & CDN