How sudokuru/frontend works
Project type and purpose
• This is a cross-platform frontend-only application (“Frontend” repo) built with React Native Web & TypeScript.
• It provides a world-class Sudoku UI (play, learn, statistics, drills) that runs in a browser (Web), in Expo (Android), and in a Tauri wrapper (Windows, Linux).
File structure
• Top‐level directories:
• .github/ → CI/CD workflows, composite GitHub Actions (Cloudflare deploy, set changelog).
• docs/ → design docs, API docs, screenshots.
• e2e/web/ → Playwright end-to-end tests (components, pages, specs, test data).
• sudokuru/ → actual application code:
– app/ → React application:
• Pages/ (React pages)
• Components/ (UI components by feature: SudokuBoard, Home, Profile, etc.)
• Contexts/ (React Contexts for state)
• Api/ (service layer wrapping AsyncStorage/LocalStorage)
• Data/ (bundled puzzles TS files)
• Functions/ (helpers, local DB wrappers, util functions)
• Navigation/ (DrawerNavigator)
– src-tauri/ → Rust backend for desktop via Tauri (file main.rs, build.rs, Cargo.toml).
– public/, app.config.ts, eas.json → Expo & static assets.
• Configuration files: package.json, tsconfig.json, babel.config.js, Prettier, ESLint, Playwright config.
README insights
• Confirms this is the primary UI module for an open-source Sudoku platform.
• Describes features (play, lessons, stats, hints, drills).
• Explains code structure (app folder breakdown).
• Details supported platforms and testing strategy (Playwright).
Main components & their interactions
a. Frontend UI Layer
• Pages (e.g. HomePage, PlayPage, SudokuPage) host Components.
• Components (buttons, boards, modals) consume state via Contexts.
b. State & Services
• Context Providers (InitializeContext, PreferencesContext) manage global state.
• Api layer (app/Api/*.ts) abstracts AsyncStorage/LocalStorage to read/write user preferences, profile, statistics.
c. Data sources
• Bundled puzzles in TS files (app/Data/puzzles).
• LocalDatabase wrapper (Functions/LocalDatabase) for optional more complex storage.
• NPM Sudokuru Clearinghouse library for generating puzzles & hints.
d. Platform runtimes
• Web: React Native Web running in browser.
• Mobile: Expo Go client or standalone APK (Android).
• Desktop: Tauri combining the same web bundle in a WebView with a Rust backend for OS integration.
e. CI/CD & Testing
• GitHub Actions pipeline builds, runs tests, deploys web via Cloudflare composite action.
• Playwright E2E tests (e2e/web) run against the running web instance.
Architectural patterns & design principles
• Component‐based (React) with clear separation of pages vs. reusable components.
• State management via React Context (no heavy Redux).
• Service abstraction layer (Api) isolates storage implementation.
• Single codebase targets multiple platforms via React Native Web + Expo + Tauri.
1) User Devices/Environments (Browser, Expo, Desktop)
2) Platform Runtimes (Webpack/static hosting, Expo runtime, Tauri + Rust)
3) UI Layer (Pages, Components, Styling)
4) State/Service Layer (Contexts, Api, Functions)
5) Data Layer (Puzzles files, AsyncStorage/LocalStorage, LocalDatabase, external npm modules)
• Rectangles (blue) for UI components and pages.
• Rectangles (green) for Contexts & service modules.
• UI → Contexts (state reads)
• UI → Api → Storage (reads/writes)
• UI → Data/puzzles (reads)
• Api → Storage (reads/writes)
• UI → npm module (hint/puzzle generation)
• CI/CD → builds & deploys Web bundle to CDN, packages mobile & desktop apps
• Playwright tests → Web instance
Essential elements
• Clear labels on each component block (e.g. “PlayPage.tsx”, “PreferencesContext.ts”).
• A boxed grouping for CI/CD outside the runtime, showing pipelines and Playwright.