How entibo/taipingu works
Project Type & Purpose
• This is a static single‐page web application (SPA) for a Japanese typing game.
• It ships as static assets (HTML, CSS, JS, JSON, fonts) and runs entirely in the browser.
• A small build pipeline (Makefiles, scripts) generates subsets of fonts and JSON sentence datasets from Tatoeba dumps.
High‐Level Components
A. Client (Browser)
• index.html: The shell that loads CSS and JS.
• index.css: Styles for layout, fonts, furigana, etc.
• index.js: Main application logic (UI, settings, game loop).
• romaji.js: Input‐mapping module that converts keyboard events into Japanese syllables.
• sentences/tatoeba/api.js: Client-side “API” module to fetch sentence JSON streams.
B. Static Data Store (Deployed)
• sentences/tatoeba/data: Thousands of JSON files, chunked and indexed by features (language, audio availability, readings).
• fonts (subsetted TTF/WOFF files): Two font styles, generated by fonts/Makefile.
C. External Services
• Tatoeba.org: Hosts audio recordings referenced by URL in sentence metadata.
D. Build & Generation Pipeline (Local Dev)
• sentences/tatoeba/Makefile + scripts/*.mjs:
• Fetch Tatoeba dump, filter Japanese sentences, generate chunked JSON & indices.
• fonts/Makefile: Subset Google Noto/Source Han fonts based on characters used in initial sentences.
Relationships & Data Flows
• Browser → Static Web Server: index.html, CSS, JS, fonts, JSON chunks are fetched over HTTP(S).
• index.js & api.js → sentences/tatoeba/data/*.json: fetch() calls return sentence objects.
• index.js → romaji.js: translates keypress events into kana/romaji comparison logic.
• Browser → Tatoeba.org: HTTP GET requests for audio URLs on demand.
• Developer (CLI) → Makefiles / scripts → fonts, sentences data: one‐time or periodic generation before deploy.
Architectural Patterns & Principles
• Client‐Side Rendering (CSR): All rendering and game logic runs in the browser.
• Static Site / Jamstack: Prebuilt assets served from a CDN or GitHub Pages.
• Modular JS: Separate modules for UI, input handling, data access.
• Chunked Data Loading: Sentence data is split into manageable JSON files to avoid huge single downloads.