Update project overview to describe region tree refactor, document data pipeline scripts, clarify project structure, and align with current practices.
6.2 KiB
Project Structure
Root Directory
CLAUDE.md- Project instructions and guidelines for Claude Codecomponents.json- shadcn/ui configurationpackage.json- Dependencies and scriptsnext.config.mjs- Next.js configurationeslint.config.mjs- ESLint configurationpostcss.config.mjs- PostCSS configurationjsconfig.json- JavaScript project configurationvitest.config.mjs/vitest.integration.config.mjs- The two test lanesdocker-compose.yml- Local Redis + SRH for the integration laneREADME.md- Public-facing project readme
Source Code (src/)
App Router (src/app/)
Next.js 15 App Router structure:
Pages
page.js- Homepage: region picker and leaderboard modallayout.js- Root layout componentglobals.css- Global stylesfavicon.ico- Site favicon
Game Pages
game/page.js- Main game interfacedebug/page.js- Development debugging toolsdebug/coverage/page.js- Panorama coverage map, per regiondebug/coverage/CoverageMap.js- Leaflet layer for that page
API Routes (src/app/api/)
new-game/route.js- Creates new game sessions with Redis storageguess/route.js- Processes guess submissions, scores, and fans outleaderboard/route.js- Leaderboard data management with Redisskip/route.js- Skip current round functionalitydebug/mapillary/route.js- Mapillary API debugging and testingdebug/pano/route.js- Resolve one panorama id to an imagedebug/region-coverage/route.js- A region's outline and panorama points
React Components (src/app/components/)
GameClient.js- Main game client componentLeafletMap.js- Interactive map for guess placementPanoramaViewer.js- 360 degree street view displayRegionPicker.js- Homepage province accordion, one row per playable regionRegionSelect.js- Level buttons plus a grouped select, used where a single region has to be chosen from 67LeaderboardList.js- Ranked rows for one boardUsernameModal.js- Username input modalDonateQRModal.js- Donation QR code modalThemeToggle.js- Light/dark switch
Reusable Components (src/components/)
shadcn/ui Components (src/components/ui/)
Only the primitives the app actually renders are vendored in. Add others with the shadcn CLI when a screen needs them, rather than keeping unused ones around.
accordion.jsx- Collapsible sections (province expansion)alert.jsx- Alert notificationsbadge.jsx- Badge componentsbutton.jsx- Button variantscard.jsx- Card layoutsdialog.jsx- Modal dialogsinput.jsx- Input fieldslabel.jsx- Form labelsselect.jsx- Grouped select (region picker)skeleton.jsx- Loading skeletonstabs.jsx- Tab navigation
Generated Data (src/data/)
All three directories are build output. Do not hand-edit; see Rebuilding the generated region data in development.md.
regions/index.js- The 67-node tree: code, name, parent, level, children, center, bbox, and coverage flagsregions/counts.js- Per-region panorama and cell tallies. The one panorama-derived file a client component may import - it carries counts only, never a coordinateboundaries/<province>/*.json- Simplified outlines, one file per region, behind a generatedboundaries/index.jsbarrelpanos/<province>.json- Panorama ids, coordinates, and district assignment, behind a generatedpanos/index.jsbarrel. Server-side only - roughly 28MB of exact answers
Utility Libraries (src/lib/)
utils.js- Utility functions includingcn()for class name mergingregions.js- Client-safe region tree traversal. Imports nothing fromdata/panos/orpano-index.js;tests/regions.test.jsenforces thatpano-index.js- Server-side only. Picks a panorama for a region and reports which district it landed inregion-request.js- Resolves and validates a region code from a requestgame.js- Scoring, distance, formatting, username storageleaderboard.js- Leaderboard operations, including the district to province to country fan-outmapillary.js- Mapillary lookup by image idsession.js- Redis-based session management with 30-min expiryupstash.js- Upstash Redis REST client adapter with multi-tenant key prefixtheme.js,use-count-up.js- Theme persistence and a count-up hook
Build Scripts (scripts/)
Each carries a header comment with its flags and its cost.
build-region-boundaries.mjs- OSM/Nominatim to boundaries and the region treebuild-pano-index.mjs- Mapillary z14 tiles to a per-province panorama indexassign-pano-districts.mjs- Clips and partitions panoramas by districtmigrate-leaderboards.mjs- Backfills the two boards whose code changedbuild-check.mjs- Production build into.next-checklib/assign-districts.mjs- District assignment shared by the two pano scriptslib/leaderboard-migration.mjs- Copy, verify, regression-check and restore
Tests (tests/)
Vitest, mostly one file per src/lib/ module, plus a route test for
new-game, guess, and debug/region-coverage. The skip, leaderboard,
debug/mapillary, and debug/pano routes have no dedicated test file; their
underlying src/lib/ logic (leaderboard.js, mapillary.js) is still
covered. fake-upstash-redis.js, mock-upstash.js, redis-harness.js and
wait-for-srh.js are the shared harness that lets the same files run against
either the in-memory fake or a real Redis.
Nothing here exercises the React components: there is no component-test
dependency, so GameClient.js, RegionPicker.js, RegionSelect.js and the
coverage page are covered by manual testing only.
Documentation (/docs/)
project-overview.md- Project overview, administrative basis, coverage notefeatures.md- Detailed game features documentationtech-stack.md- Technology stack and dependenciesdevelopment.md- Development guidelines, commands, and build sequencegame-flow.md- Complete gameplay flow documentationproject-structure.md- This file - project organization
Planning (/plans/)
- Project planning documents and implementation plans
Public Assets (public/)
zlp.jpg- Donation QR code image- Static assets served directly by Next.js