An interactive web game where kids help a friendly ghost "debug" haunted code to save the digital world. Each bug represents a coding concept (loops, conditions, logic puzzles) with spooky animations as rewards.
This is a submission for Kiroween Hackathon https://kiroween.devpost.com/
Target Audience: Kids learning coding concepts
Technology Stack:
- Frontend: Vite + React + TypeScript
- Infrastructure: AWS CDK (S3, CloudFront, API Gateway, Lambda)
- AI Services: Amazon Polly for voice
- Animation: Framer Motion
Development Philosophy: This is a hackathon project focused on core functionality and user experience. Code is clean and understandable but doesn't need to be production-grade.
- Node.js 20.x or later
- npm or yarn
# Install dependencies
npm install
# Start development server
npm run dev
# Build for production
npm run build
# Run tests
npm testThe app will be available at http://localhost:5173
ghost-in-the-code/
├── src/
│ ├── components/ # React components
│ │ ├── GameBoard.tsx # Main game layout
│ │ ├── CodeEditor.tsx # Interactive code editor
│ │ ├── GhostCharacter.tsx # Animated ghost helper
│ │ ├── BadgeCollection.tsx # Badge system
│ │ ├── ProgressTracker.tsx # Challenge progress
│ │ └── ...
│ ├── engine/ # Game logic and state management
│ │ ├── gameReducer.ts # State management
│ │ ├── gameActions.ts # Action creators
│ │ ├── useBadgeSystem.ts # Badge logic
│ │ └── persistence.ts # LocalStorage handling
│ ├── data/ # Challenge data
│ │ ├── challenges/ # JSON challenge files
│ │ │ ├── loops.json
│ │ │ ├── conditionals.json
│ │ │ └── logic.json
│ │ ├── badges.ts # Badge definitions
│ │ └── challengeLoader.ts
│ ├── animations/ # Success animations
│ │ └── SuccessAnimations.tsx
│ ├── index.css # Global styles & utility classes
│ └── App.tsx # Main app component
├── infrastructure/ # AWS CDK deployment
│ ├── lambda/ # Lambda functions
│ │ └── polly/ # Text-to-speech (TypeScript)
│ └── lib/ # CDK stack definitions
├── public/ # Static assets
│ └── badges/ # Badge icon SVGs
└── README.md # This file
- 14 Challenges across 3 concept types:
- Loops (4 challenges): Learn repetition and iteration
- Conditionals (5 challenges): Master decision-making
- Logic Puzzles (5 challenges): Solve tricky problems
- Syntax-highlighted code display
- Editable buggy lines
- Real-time validation
- Visual feedback on success/failure
- 8 Badges to earn:
- Concept Mastery: Loop Master, Conditional Champion, Logic Legend
- Achievement: First Bug Fixed, Hint-Free Hero, Persistent Ghost Helper
- Special: Perfect Start, Ghost Whisperer
- Unlock animations and certificate generation
- Progress tracking and statistics
Magical Halloween-themed celebrations using Framer Motion:
- CodeHeal: Green healing wave across fixed code
- TerminalGlow: Pulsing glow with corner emojis
- ParticleBurst: Curved, floating emoji particles across screen
- GhostCelebrate: Bouncing, rotating ghost character
- All animations respect
prefers-reduced-motion
- Pre-challenge introductions for each concept type
- Post-challenge learning summaries
- Age-appropriate explanations
- Hint system with 3 levels per challenge
- Challenge completion tracking
- Concept mastery percentages
- Hint usage statistics
- Time spent tracking
- Progress summary with all stats
- Game state saved to localStorage
- Resume from where you left off
- Player name persistence
- Badge and progress data
--color-primary: #A3FF00; /* Lime green */
--color-secondary: #00D9FF; /* Cyan */
--color-accent: #FF9500; /* Orange */
--color-purple: #6B46C1; /* Purple */
--color-dark-bg: #1A1F2E; /* Dark blue */
--color-darker-bg: #2D1B4E; /* Darker purple */- Headers: Jolly Lodger (spooky, playful)
- Body: Avenir (clean, readable)
- Responsive font sizing with
clamp()
.icon-button- Consistent icon buttons with hover effects.modal-overlay- Standard modal backdrop.modal-container- Modal content wrapper.h1-style,.h2-style,.h3-style- Heading styles for non-heading elements
# Run all tests
npm test
# Run tests in watch mode
npm run test:watch
# Run tests with coverage
npm run test:coverageTest coverage includes:
- Badge earning logic
- Challenge validation
- State management
- Data loading
The ghost speaks! AWS Polly provides text-to-speech with emotion support.
-
Deploy infrastructure:
cd infrastructure npm run deploy:full -
Configure environment:
cp .env.example .env # Edit .env and add your API endpoint from deployment output -
Run the app:
npm run dev
- ✅ Ghost speaks automatically when messages appear
- ✅ Ghost speaks when clicked with random messages
- ✅ Three emotion modes: neutral, excited, encouraging
- ✅ Audio cached in S3 for performance
- ✅ Volume control (0-100%) in settings
- ✅ Enable/disable voice in settings
- Ghost Voice Toggle: Enable/disable all voice narration
- Volume Slider: Adjust playback volume (default: 80%)
- Settings persist across sessions in localStorage
Change voice in infrastructure/lib/ghost-in-the-code-stack.ts:
environment: {
VOICE_ID: 'Matthew', // Joanna, Matthew, Salli, Kendra, Joey, Justin, etc.
}Adjust emotions in infrastructure/lambda/polly/index.ts:
- Excited: Fast rate + 10% higher pitch
- Encouraging: 5% higher pitch
- Neutral: Normal speech
"API endpoint not configured"
- Ensure
.envfile exists in project root - Restart dev server after creating
.env
No sound
- Check browser console for errors
- Verify API endpoint URL ends with
/ - Check browser autoplay policies
- Polly: ~$4 per 1 million characters
- S3 Storage: Minimal (audio files cached)
- API Gateway: ~$3.50 per million requests
- Lambda: Minimal (fast execution)
Audio caching significantly reduces costs.
The game can be deployed to AWS using CDK:
cd infrastructure
# Install dependencies
npm install
# Deploy everything (builds Vite app + deploys CDK)
npm run deploy:full
# Or use deployment scripts
# Windows:
.\deploy.ps1
# Linux/Mac:
chmod +x deploy.sh
./deploy.shInfrastructure includes:
- S3 bucket for static hosting
- CloudFront CDN for global delivery
- API Gateway for voice services
- Lambda functions (TypeScript, auto-compiled):
- Polly function for text-to-speech with SSML support
- S3 bucket for audio caching with public read access
No Docker required - uses local bundling and esbuild for Lambda functions.
For automated deployments via GitHub Actions:
-
Create OIDC Identity Provider in AWS:
- Go to IAM → Identity providers → Add provider
- Provider URL:
https://token.actions.githubusercontent.com - Audience:
sts.amazonaws.com
-
Create IAM Role:
- Select "Web identity"
- Add condition for your repo:
repo:YOUR_USERNAME/ghost-in-the-code:* - Attach
PowerUserAccesspolicy - Name:
GitHubActionsRole
-
Add GitHub Secrets:
AWS_ROLE_ARN: Your role ARNAWS_ACCOUNT_ID: Your AWS account ID
-
Local Development:
aws configure # Or set AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY in .env
- Endpoint:
POST /voice - Request:
{ text: string, emotion?: 'neutral' | 'excited' | 'encouraging' } - Response:
{ audioUrl: string, cached: boolean, text: string } - Uses SSML for prosody control (rate, pitch)
- Caches audio files in S3 (1-year TTL)
- Standard engine for SSML support
- Total Challenges: 14
- Loops: 4 challenges
- Conditionals: 5 challenges
- Logic: 5 challenges
- Total Badges: 8
- Concept Mastery: 3 badges
- Achievement: 3 badges
- Special: 2 badges
- Concept mastery calculated based on:
- Hints used (15 points penalty each)
- Extra attempts (10 points penalty each)
- Base score: 100 points per challenge
- React Context + useReducer for global state
- LocalStorage persistence with versioning
- Automatic save on state changes
- JSON-based challenge data
- Validation on load
- Type-safe with TypeScript interfaces
- Framer Motion for smooth animations
- GPU-accelerated transforms
- Accessibility-first (reduced motion support)
- Curved particle paths for magical effect
- Mobile-first approach
- Breakpoints: 480px, 768px, 1024px, 1440px
- Touch-friendly (44px minimum targets)
- Flexible layouts with CSS Grid/Flexbox
- Strict mode enabled
- Proper interfaces for all data structures
- Type guards for runtime checking
- Avoid
any- useunknownor proper types
- Use utility classes from
index.css - Follow DRY principles
- Component-scoped CSS modules
- Consistent naming conventions
- WCAG AAA contrast ratios
- Keyboard navigation support
- Focus indicators (3px yellow outline)
- Screen reader friendly
- Reduced motion support
- Badge icons use emoji placeholders (SVGs planned)
- No sound effects yet
- Print feature removed (download feature also removed)
- Custom SVG badge icons
- Sound effects for animations
- Social sharing of badges
- More challenge types
- Multiplayer mode
This is a hackathon project. Repository is public - keep credentials and sensitive data out of code.
This is a hackathon project focused on rapid development. Code should:
- Work and demonstrate the concept well
- Be clean and understandable
- Follow TypeScript best practices
- Include basic error handling
- Have clear but concise documentation
Built with:
- React + TypeScript + Vite
- Framer Motion for animations
- AWS CDK for infrastructure
- Amazon Polly for voice synthesis
Happy Debugging! 👻✨