Sudoku with Friends
A real-time multiplayer Sudoku game that allows players to solve puzzles collaboratively in shared rooms. Features live synchronization, player presence tracking, and a complete custom Sudoku engine.


Real-time Multiplayer
Live synchronization
No Registration
Instant play
PWA
Mobile-first design
Multiple Levels
Easy to inhuman
Tech Stack
Frontend
Backend & Database
Technical Implementation
1. Real-time Architecture
The project uses Firebase Realtime Database for seamless multiplayer synchronization. The architecture includes comprehensive input validation, automatic reconnection logic, and conflict resolution for concurrent player actions.
Key Real-time Features:
- • Live game state synchronization across all players
- • Player presence tracking with focus indicators
- • Automatic reconnection with retry logic
- • Real-time move validation and conflict resolution
2. Custom Sudoku Engine
Most Impressive Technical Achievement: 820-line custom Sudoku implementation built from scratch. The engine handles complete puzzle generation, multiple difficulty levels, and constraint satisfaction problem solving.
Difficulty Levels:
3. Advanced State Management
Built with React Context and custom providers, featuring an undo/redo system, notes mode for pencil marks, and comprehensive game validation.
4. Production-Ready Configuration
Includes security headers, performance optimizations, SWC minification, and Progressive Web App capabilities for mobile deployment.
Code Showcase
Custom Sudoku Engine Core
Here's a glimpse of the custom Sudoku generation algorithm:
// Core Sudoku generation algorithm
class SudokuGenerator {
private grid: number[][];
generatePuzzle(difficulty: Difficulty): number[][] {
// Start with a solved grid
this.grid = this.generateSolvedGrid();
// Remove numbers based on difficulty
const cellsToRemove = this.getCellsToRemove(difficulty);
this.removeCells(cellsToRemove);
return this.grid;
}
private generateSolvedGrid(): number[][] {
// Backtracking algorithm to create valid Sudoku
const grid = Array(9).fill(null).map(() => Array(9).fill(0));
this.solveGrid(grid);
return grid;
}
private solveGrid(grid: number[][]): boolean {
for (let row = 0; row < 9; row++) {
for (let col = 0; col < 9; col++) {
if (grid[row][col] === 0) {
const numbers = this.shuffleArray([1, 2, 3, 4, 5, 6, 7, 8, 9]);
for (const num of numbers) {
if (this.isValid(grid, row, col, num)) {
grid[row][col] = num;
if (this.solveGrid(grid)) return true;
grid[row][col] = 0;
}
}
return false;
}
}
}
return true;
}
}Real-time State Synchronization
Firebase Realtime Database integration for multiplayer:
// Real-time game state management
export const useGameState = () => {
const [gameState, setGameState] = useState<GameState | null>(null);
const [players, setPlayers] = useState<Player[]>([]);
useEffect(() => {
const gameRef = ref(database, `games/${roomId}`);
const playersRef = ref(database, `games/${roomId}/players`);
// Listen for game state changes
onValue(gameRef, (snapshot) => {
const data = snapshot.val();
if (data) {
setGameState(data);
}
});
// Listen for player presence
onValue(playersRef, (snapshot) => {
const playersData = snapshot.val();
if (playersData) {
const playersList = Object.values(playersData);
setPlayers(playersList);
}
});
return () => {
off(gameRef);
off(playersRef);
};
}, [roomId]);
const updateCell = useCallback(async (row: number, col: number, value: number) => {
try {
const updates: any = {};
updates[`games/${roomId}/grid/${row}/${col}`] = value;
updates[`games/${roomId}/lastMove`] = {
row,
col,
value,
playerId: currentPlayer.id,
timestamp: serverTimestamp()
};
await update(ref(database), updates);
} catch (error) {
console.error('Failed to update cell:', error);
}
}, [roomId, currentPlayer]);
return { gameState, players, updateCell };
};Mobile-First UI Component
Responsive Sudoku grid with touch interactions:
// Responsive Sudoku grid component
const SudokuGrid: React.FC<SudokuGridProps> = ({
grid,
selectedCell,
onCellSelect,
conflicts
}) => {
return (
<div className="grid grid-cols-9 gap-px bg-gray-300 rounded-lg p-1">
{grid.map((row, rowIndex) =>
row.map((cell, colIndex) => {
const isSelected = selectedCell?.row === rowIndex &&
selectedCell?.col === colIndex;
const hasConflict = conflicts.some(
c => c.row === rowIndex && c.col === colIndex
);
return (
<button
key={`${rowIndex}-${colIndex}`}
className={`
aspect-square text-lg font-semibold
transition-all duration-200
${isSelected ? 'bg-blue-500 text-white' : 'bg-white'}
${hasConflict ? 'bg-red-100 text-red-600' : ''}
hover:bg-blue-50 focus:outline-none focus:ring-2
focus:ring-blue-500 focus:ring-offset-2
`}
onClick={() => onCellSelect(rowIndex, colIndex)}
aria-label={`Cell ${rowIndex + 1}, ${colIndex + 1}`}
>
{cell || ''}
</button>
);
})
)}
</div>
);
};Problem Solving & Challenges
1. Real-time Synchronization
Challenge: Keeping game state consistent across multiple players without conflicts.
Solution: Firebase Realtime Database for atomic updates, input validation layer, optimistic updates with rollback capability, and connection retry logic with exponential backoff.
2. Mobile Touch Interface
Challenge: Creating an intuitive Sudoku interface for mobile devices.
Solution: Responsive 9x9 grid with proper touch targets, custom numpad component, visual feedback for selected cells and conflicts, and swipe gestures.
3. Game State Validation
Challenge: Ensuring game integrity and preventing cheating.
Solution: Comprehensive validation algorithms for rows, columns, and 3x3 boxes, with real-time conflict detection and user feedback.
Key Achievements
Technical Excellence
- • Custom algorithm implementation (820 lines)
- • Real-time architecture with Firebase
- • Full TypeScript implementation
- • Comprehensive code quality tools
- • Production-ready deployment
User Experience
- • Zero friction - no registration required
- • Cross-platform PWA support
- • Accessibility with ARIA labels
- • Smooth animations and modern UI
- • Fast loading and responsive design
Technical Metrics
Performance & Analytics
Performance Metrics
User Engagement
Skills Demonstrated
Frontend Development
- • Advanced React patterns (Context, Hooks)
- • TypeScript for large-scale applications
- • Modern CSS with Tailwind
- • Progressive Web App implementation
- • Component-driven architecture
Backend & Real-time
- • Firebase Realtime Database integration
- • Real-time state synchronization
- • Input validation and sanitization
- • Connection management and retry logic
- • API design and error handling
What I Learned
Technical Insights
- • Real-time Architecture: Firebase Realtime Database is excellent for rapid prototyping but requires careful state management for complex applications
- • Algorithm Design: Building a Sudoku solver from scratch taught me constraint satisfaction problems and backtracking algorithms
- • Mobile UX: Touch interfaces require different design patterns than desktop - larger touch targets and gesture support are crucial
- • Performance Optimization: React.memo and useCallback are essential for real-time applications with frequent re-renders
- • TypeScript: Strong typing prevented countless runtime errors and made the codebase more maintainable
Development Process
- • MVP Approach: Starting with a single-player version before adding multiplayer complexity was crucial
- • Testing Strategy: Unit tests for the Sudoku engine saved hours of debugging
- • User Feedback: Early user testing revealed that the mobile interface needed significant improvements
- • Deployment: Vercel's edge functions and automatic deployments streamlined the development workflow
- • Documentation: Good documentation is essential when working with complex algorithms
Future Enhancements
- Spectator Mode: Allow observers to watch games
- Tournament System: Organized competitions with brackets
- AI Hints: Smart hint system with difficulty adaptation
- Voice Chat: WebRTC integration for team communication
- Analytics Dashboard: Player statistics and game insights