A modern, full-stack multiplayer Snake game with real-time leaderboards and spectator mode. Built with React, TypeScript, and FastAPI.
- Walls Mode: Classic snake gameplay with collision boundaries
- Pass-Through Mode: Snake can wrap around screen edges
- 🎯 Real-time multiplayer leaderboards
- 👥 User authentication and profiles
- 👀 Watch other players in real-time
- 📊 Score tracking and rankings
- 🎨 Modern, responsive UI with dark mode
- 🔄 Live game state updates
- Framework: React 18 with TypeScript
- Build Tool: Vite
- UI Library: shadcn/ui + Radix UI
- Styling: Tailwind CSS
- State Management: React Hooks
- Routing: React Router
- HTTP Client: Fetch API
- Testing: Vitest
- Framework: FastAPI (Python 3.13)
- Database: PostgreSQL (Production) / SQLite (Development)
- ORM: SQLAlchemy with async support
- Authentication: JWT tokens
- Testing: pytest + pytest-asyncio
- Package Manager: uv
- Containerization: Docker + Docker Compose
- Web Server: Nginx (production)
- CI/CD: GitHub Actions
- Deployment: Render
- Database: Render PostgreSQL
play-with-friends-stream/
├── frontend/ # React frontend application
│ ├── src/
│ │ ├── components/ # Reusable UI components
│ │ ├── hooks/ # Custom React hooks
│ │ ├── pages/ # Page components
│ │ ├── services/ # API services
│ │ ├── types/ # TypeScript type definitions
│ │ └── lib/ # Utility functions
│ ├── public/ # Static assets
│ └── package.json
│
├── backend/ # FastAPI backend application
│ ├── app/
│ │ ├── main.py # Application entry point
│ │ ├── models.py # Database models
│ │ ├── db.py # Database configuration
│ │ └── routers/ # API endpoints
│ │ ├── auth.py # Authentication routes
│ │ ├── leaderboard.py
│ │ └── players.py
│ ├── tests/ # Unit tests
│ ├── tests_integration/ # Integration tests
│ ├── Makefile # Development commands
│ └── pyproject.toml # Python dependencies
│
├── .github/
│ └── workflows/
│ └── ci.yml # CI/CD pipeline
├── docker-compose.yml # Local development setup
├── Dockerfile # Multi-stage production build
└── render.yaml # Render deployment config
- Node.js 20+ and npm
- Python 3.13+
- uv (Python package manager)
- Docker and Docker Compose (optional, for containerized development)
cd frontend
npm install
npm run devThe frontend will be available at http://localhost:5173
cd backend
uv sync
make devThe backend API will be available at http://localhost:8000
- API Documentation:
http://localhost:8000/docs
Run both frontend and backend with a single command:
docker-compose upServices:
- Frontend:
http://localhost:3000 - Backend:
http://localhost:8000 - PostgreSQL:
localhost:5432
cd frontend
npm test # Run tests once
npm test -- --watch # Run tests in watch modeTest Coverage: 37 tests across API services and game hooks
cd backend
# Run all tests
make test
# Run only unit tests
make test-unit
# Run only integration tests
make test-integrationTest Coverage:
- Unit tests: 4 tests
- Integration tests: 1 test
- Total: 5 tests
The project uses GitHub Actions for continuous deployment:
- Push to main branch triggers the CI/CD pipeline
- Three test jobs run in parallel:
- Frontend tests (37 tests)
- Backend unit tests (4 tests)
- Backend integration tests (1 test)
- Deploy to Render (only if all tests pass)
Follow the detailed guide in DEPLOYMENT.md
Key steps:
- Create Render Web Service
- Set up PostgreSQL database
- Configure environment variables
- Connect GitHub repository
- Deploy!
DATABASE_URL=postgresql+asyncpg://user:pass@host/db
SECRET_KEY=your-secret-key-here
ACCESS_TOKEN_EXPIRE_MINUTES=30POST /api/auth/signup- Register new userPOST /api/auth/login- Login userPOST /api/auth/logout- Logout userGET /api/auth/me- Get current user
GET /api/leaderboard?mode=walls|pass-through- Get leaderboardPOST /api/leaderboard- Submit score
GET /api/active-players- Get all active playersGET /api/active-players/{id}- Get specific player
npm run dev # Start dev server
npm run build # Build for production
npm run preview # Preview production build
npm test # Run tests
npm run lint # Run ESLintmake install # Install dependencies
make dev # Start dev server with auto-reload
make start # Start production server
make test # Run all tests
make test-unit # Run unit tests only
make test-integration # Run integration tests only
make clean # Remove cache filesdocker-compose up # Start all services
docker-compose up -d # Start in detached mode
docker-compose down # Stop all services
docker-compose logs -f # View logs- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- All PRs must pass CI tests
- Code must follow existing style guidelines
- Update tests for new features
- Update documentation as needed
This project is licensed under the MIT License.
For issues and questions:
- Open an issue on GitHub
- Check existing documentation in
/docs - Review the DEPLOYMENT.md guide
Made with ❤️ using React, TypeScript, and FastAPI