A real-time multiplayer Tic Tac Toe game with automatic player matching and modern UI.
Tic Tac Toe Online is a full-stack web application that allows players to enjoy the classic game of Tic Tac Toe in real-time with opponents from anywhere in the world. The project solves the challenge of finding opponents for casual gaming by implementing automatic matchmaking and real-time gameplay.
- Frontend: React, TypeScript, Vite
- Backend: Node.js, Express, Socket.io
- Database: Supabase
- Authentication: Supabase Auth
- Styling: Plain CSS with component-based architecture
- Modern, minimalistic UI with subtle gradient colors
- Dark/light mode toggle with theme persistence
- Responsive design for all devices (desktop, tablet, mobile)
- Animated game elements for a dynamic feel
- Real-time multiplayer matches via WebSockets
- Automatic player matching system
- Turn-based gameplay with clear indicators
- Win/draw detection and game state management
- User authentication with Supabase
- Profile page for personal stats and settings
- Protected routes for authenticated users
- Guest play option without registration
- Real-time communication with Socket.io
- Persistent game stats (for authenticated users)
- Route protection and navigation guards
- Structured component hierarchy
- Node.js (version 14 or higher)
- npm or pnpm
- Supabase account (for database and authentication)
-
Supabase Configuration:
- Create a project on Supabase
- Note your project URL and anon key for environment variables
-
Environment Variables:
- Client variables:
VITE_SERVER_URL=http://localhost:3000 VITE_SUPABASE_URL=your_supabase_url VITE_SUPABASE_KEY=your_supabase_anon_key - Server variables:
PORT=3000 SUPABASE_URL=your_supabase_url SUPABASE_KEY=your_supabase_anon_key CLIENT_URL=http://localhost:5174
- Client variables:
-
Clone the repository:
git clone https://github.com/abhishekpawan/TicTacToe.git cd TicTacToe -
Install all dependencies with a single command:
npm run install:all # or using pnpm pnpm install && cd client && pnpm install && cd ../server && pnpm install
-
Set up environment variables:
- Copy
.env.exampleto.envin both client and server directories - Update with your Supabase credentials
- Copy
Start both client and server concurrently:
npm run dev
# or using pnpm
pnpm run devOr run them individually:
# Client only
npm run client
# Server only
npm run server- Client: http://localhost:5174
- Server: http://localhost:3000
- API: http://localhost:3000/api
- Check the Network tab in browser DevTools to debug Socket.io connections
- Use React DevTools to inspect component hierarchy and state
- Server logs will show socket connections and game events
- Modify the
.envfiles for different configurations
- Navigate to the application in your browser
- Sign in or continue as a guest
- Click "Find a Match" to start matchmaking
- Wait for an opponent to be paired with you
- Take turns making moves on the board
- The game will automatically detect wins or draws
- Play again or find a new match after the game ends
Main game board showing X and O marks with current player indicator
Matchmaking interface with waiting animation
- Create an account to track your stats
- View your profile to see your win/loss record
- Toggle between dark and light mode in the settings
POST /api/auth/register- Register a new userPOST /api/auth/login- Login existing userGET /api/auth/profile- Get user profile
GET /api/game/stats- Get player statisticsGET /api/game/history- Get game history
find-match- Start matchmakingcancel-matchmaking- Cancel matchmakingmake-move- Make a move on the boardgame-update- Receive game state updatesgame-over- Game conclusion notification
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Socket.io for real-time communication
- Supabase for backend services
- React and Vite for frontend development
- All contributors and players!