How abhinandan2699/nestnavigate works
1. High-level shape
- This is a React 18 + Vite + TypeScript game app with a clear split between UI/state orchestration and a Phaser 3 canvas layer.
- React owns the game state and screen transitions; Phaser is used for the animated/visual playfield only.
2. App flow / screen boundaries
- The main user journey is organized into three screens under src/screens:
- StartScreen for the intro / entry point
- GameScreen for the live bidding loop
- ResultScreen for the post-game outcome and scoring
- App.tsx is the top-level router-like switch that decides which screen is active.
3. Central game orchestration
- src/hooks/useGameEngine.ts is the core stateful subsystem.
- It likely coordinates:
- round progression
- timer expiration
- player actions like raise/hold/walk away/waive coverage
- rival behavior
- end-of-game resolution
- This hook is the main boundary between user input and game rules.
4. React UI components
- BidPanel.tsx is the action surface for the player’s bidding decisions.
- Timer.tsx presents the round countdown pressure.
- RivalFeed.tsx displays opponent activity/taunts and likely mirrors engine events.
- ScoreSummary.tsx renders the final outcome and financial lesson after the reveal.
- PhaserCanvas.tsx is the bridge component that mounts the Phaser instance inside the React layout.
5. Phaser subsystem
- The Phaser code lives under src/phaser.
- game.ts is the Phaser bootstrap/config entry.
- scenes/BiddingScene.ts is the primary scene for in-round visual feedback.
- Per the README, Phaser renders the neighborhood/house visuals, timer bar, and feedback effects, while React remains the source of truth for gameplay state.
6. React ↔ Phaser integration
- The architecture uses a shared event-driven bridge rather than sharing DOM/canvas state directly.
- React state changes are emitted into the Phaser scene, and the scene reacts visually.
- This keeps rendering concerns isolated from game logic and avoids Phaser becoming the state owner.
7. Domain logic
- src/utils/rivals.ts encodes opponent behavior, especially each rival’s aggression profile.
- src/utils/scoring.ts handles the financial outcome rules: appraisal comparison, bid result, and whether the player can actually close after waiving the gap.
- These utilities are pure rule engines and are important boundaries for the game’s lesson.
8. Shared types and configuration
- src/types.ts defines the core domain models used across screens, hooks, and game logic.
- src/config.ts likely centralizes tunable values such as starting price, bid increment, timing, or rival parameters.
- This keeps the rules consistent across UI and engine layers.
9. Data flow through the game
- Player input starts in BidPanel.
- useGameEngine applies the rules, updates state, and triggers round/rival/timer changes.
- RivalFeed, Timer, and the Phaser scene all consume that same evolving state in different forms.
- When the game ends, ResultScreen uses scoring output to show whether the player merely won the bid or actually can close the deal.
10. Repository-level emphasis
- The architecture is intentionally simple: no external backend, no persistent store, no complex global state library.
- The important boundaries are:
- screen composition
- game engine vs presentation
- React state vs Phaser rendering
- pure scoring/rival logic vs interactive gameplay
Main entry points: useGameEngine.ts Game Engine · GameScreen.tsx Game · App.tsx App · ResultScreen.tsx Result
Components 16
React UI
Top-level screens and presentation components
- App · Top-level screen switch for the game flow
src/App.tsx - Start · Intro and entry point
src/screens/StartScreen.tsx - Game · Active bidding play screen
src/screens/GameScreen.tsx - Result · Post-game outcome and scoring screen
src/screens/ResultScreen.tsx - Bid Panel · Player action surface for bidding decisions
src/components/BidPanel.tsx - Timer · Round countdown and pressure indicator
src/components/Timer.tsx - Rival Feed · Opponent activity and taunts view
src/components/RivalFeed.tsx - Score Summary · Final outcome and financial lesson display
src/components/ScoreSummary.tsx - Canvas Bridge · Mounts the Phaser instance inside React
src/components/PhaserCanvas.tsx
Game Engine
State orchestration and round flow
- Game Engine · Core orchestration for rounds, actions, rivals, and end state
src/hooks/useGameEngine.ts
Phaser Layer
Canvas rendering and scene bootstrap
- Phaser Boot · Phaser game configuration and startup
src/phaser/game.ts - Bidding Scene · Primary in-round visual feedback scene
src/phaser/scenes/BiddingScene.ts
Domain Rules
Shared types, config, scoring, and rival logic
Connections 18
- App → Start: entry · Routes to the intro screen
- App → Game: play · Routes into the live game screen
- App → Result: results · Routes to the outcome screen
- Game → Game Engine: state · Game screen consumes the core engine state
- Game → Bid Panel: actions · Player decisions originate here
- Game → Timer: countdown · Shows remaining round time
- Game → Rival Feed: events · Displays rival and engine events
- Game → Canvas Bridge: visuals · Embeds the canvas playfield
- Result → Score Summary: summary · Shows final scoring and outcome
- Bid Panel → Game Engine: input · Player actions are applied by the engine
- Game Engine → Types: models · Uses shared game domain types
- Game Engine → Config: tuning · Reads gameplay constants
- Game Engine → Rivals: opponents · Uses rival behavior rules
- Game Engine → Scoring: outcome · Computes bid and closing results
- Canvas Bridge → Phaser Boot: boot · Creates and mounts the Phaser instance
- Phaser Boot → Bidding Scene: scene · Starts the main bidding scene
- Game Engine → Canvas Bridge: events · Emits state changes for visual updates
- Game Engine → Result: finish · Feeds end-of-game result state