TheDiggerMan is an incremental clicker game where players dig deep into the earth to discover ores and build their mining operation. Built for Reddit's Devvit platform using Kiro IDE, it features progressive upgrades, automated mining, and competitive leaderboards.
Players click to mine ores, upgrade their tools for better earnings, purchase auto-diggers for passive income, and compete on global leaderboards. The game includes multiple biomes, various ore types, and an achievement system.
TheDiggerMan is built on Reddit's Devvit platform, which allows developers to create interactive web applications that run inside Reddit posts. Players access the game directly through Reddit's interface.
- React 19 - Modern UI framework with hooks
- TypeScript 5.8 - Type-safe development
- Vite - Lightning-fast build tool and dev server
- Tailwind CSS - Utility-first styling framework
- Custom CSS - Game-specific animations and effects
- Express.js - Serverless HTTP framework
- Node.js 22 - JavaScript runtime
- Redis - High-performance data storage
- Devvit APIs - Reddit integration and authentication
- Vite - Handles both client and server compilation
- TypeScript Project References - Modular compilation
- ESLint + Prettier - Code quality and formatting
- Devvit CLI - Deployment and testing tools
TheDiggerMan/
├── src/
│ ├── client/ # React frontend (game UI)
│ │ ├── App.tsx # Main game component & state management
│ │ ├── gameData.ts # Game configuration (ores, tools, biomes)
│ │ ├── achievements.ts # Achievement definitions & logic
│ │ ├── apiClient.ts # Server communication layer
│ │ ├── Character.tsx # Animated player sprite
│ │ ├── Modal.tsx # Reusable modal component
│ │ ├── AchievementsModal.tsx
│ │ ├── AchievementToast.tsx
│ │ ├── styles.css # Game styling & animations
│ │ └── public/ # Static assets
│ │ ├── ores/ # Ore sprite images
│ │ ├── smash-tools/ # Tool sprite sheets
│ │ ├── auto-diggers/ # Auto-digger images
│ │ └── sounds/ # Audio files
│ ├── server/ # Express backend
│ │ ├── index.ts # API routes & Redis operations
│ │ └── core/post.ts # Post creation utilities
│ └── shared/ # Shared TypeScript types
├── assets/ # App-level assets (icons, splash)
├── devvit.json # Devvit configuration
└── package.json # Dependencies & build scripts
All game state is managed in React using hooks:
interface GameState {
depth: number; // Current dig depth
money: number; // Total money earned
totalClicks: number; // Lifetime clicks
currentTool: string; // Active tool ID
oreInventory: { [key: string]: number }; // Ore collection
autoDiggers: { [key: string]: number }; // Auto-digger counts
discoveredOres: Set<string>; // Unlocked ore types
discoveredBiomes: Set<number>; // Unlocked biomes
unlockedAchievements: Set<string>; // Achievement progress
playerName: string; // Reddit username
}Game data persists in Redis with post-scoped keys:
gameState:{postId}:{userId} # Individual player progress
leaderboard:{postId}:money # Money leaderboard (sorted set)
leaderboard:{postId}:depth # Depth leaderboard (sorted set)
leaderboard:{postId}:name # Username reservations (hash)
stats:{postId}:globalClicks # Global click counter
The server exposes RESTful endpoints:
GET /api/init- Load game state, leaderboards, player standingPOST /api/save- Save game state, update leaderboardsPOST /api/reset- Delete player's save dataPOST /internal/on-app-install- Auto-create post on app installPOST /internal/menu/post-create- Manual post creation
- Sound Pooling: Pre-create 10 audio instances per sound type to prevent lag during rapid clicking
- Particle Limits: Cap active particles (30 sparks, 40 falling ores) to maintain 60fps
- Mobile Detection: Disable heavy effects on touch devices
- React Optimizations:
useMemofor expensive calculations (biome detection, tool filtering)useCallbackfor stable function referencesuseReffor interval callbacks to prevent re-renders
- Debounced Saves: Auto-save every 30 seconds to reduce server load
- Redis Optimization: Batch leaderboard updates in single transactions
- Efficient Queries: Use Redis sorted sets for O(log N) leaderboard operations
- JSON Serialization: Store entire game state as single JSON blob
- Serverless Architecture: Stateless request handling for scalability
-
Fast UI Development
npm run dev:vite # Localhost:7474 for rapid iteration -
Full-Stack Development
npm run dev # Client + Server + Devvit playtest -
Production Build
npm run build # Compile client and server -
Deployment
npm run deploy # Upload to Reddit npm run launch # Build + Deploy + Publish
Devvit automatically creates test subreddits (e.g., r/the_diggerman_dev) where developers can test the full game experience with Reddit integration, including:
- User authentication via Reddit accounts
- Real Redis data persistence
- Leaderboard functionality
- Post creation and management
- TypeScript: Strict type checking across all files
- ESLint: Code linting with React and TypeScript rules
- Prettier: Consistent code formatting
- Project References: Modular TypeScript compilation
- Node.js 22+
- Reddit Developer account
- Git
-
Clone and install
git clone <repository-url> cd TheDiggerMan npm install
-
Login to Reddit
npm run login
-
Start development
npm run dev
-
Open playtest URL (provided in terminal output)
| Command | Purpose |
|---|---|
npm run dev |
Full development (client + server + Devvit) |
npm run dev:vite |
Fast UI development (localhost:7474) |
npm run build |
Production build |
npm run check |
Type check + lint + format |
npm run deploy |
Upload to Reddit |
npm run launch |
Build + deploy + publish |
TheDiggerMan is built with Kiro IDE and modern web technologies, optimized for Reddit's Devvit platform. The codebase demonstrates clean architecture patterns and performance optimizations for browser-based games.