A full-stack secret number guessing game built with MongoDB, Express.js, React, and Node.js, featuring user authentication and game statistics tracking.
- User Authentication: Secure registration and login system
- Game Statistics: Track games played, won, and best scores
- Responsive Design: Works on desktop and mobile devices
- Multi-language Support: Portuguese and English
- Real-time Updates: Game stats update automatically
- Credits Modal: Acknowledge contributors
- Node.js - Runtime environment
- Express.js - Web framework
- MongoDB - Database
- Mongoose - ODM for MongoDB
- JWT - Authentication
- bcryptjs - Password hashing
- React - UI library
- React Router - Navigation
- Axios - HTTP client
- React Toastify - Notifications
- Context API - State management
- Node.js (v14 or higher)
- MongoDB (local or cloud)
- npm or yarn
git clone <your-repo-url>
cd SecretGameNumber# Install backend dependencies
npm run install-server
# Install frontend dependencies
npm run install-client
# Or install all at once
npm run install-all# Copy environment example
cp .env.example .env
# Edit .env with your MongoDB URI and JWT secretOption 1: Quick Start (Recommended)
npm startOption 2: Development Mode
# Development mode (runs both backend and frontend)
npm run dev
# Or run separately
npm run server # Backend on port 8000
npm run client # Frontend on port 3000🎮 No MongoDB? No Problem! The app will automatically detect if MongoDB is not available and allow users to play as guests. All game functionality works without a database - you just won't have user accounts or persistent statistics.
Create a .env file in the root directory:
# Database (Optional - leave empty to run without database features)
MONGODB_URI=mongodb://localhost:27017/secretgame
# JWT Secret (Required only if using authentication)
JWT_SECRET=your_jwt_secret_key_here
# Server Configuration
PORT=8000
NODE_ENV=developmentNote: MongoDB is optional! If you don't have MongoDB installed, the app will still work - users can play as guests without authentication features.
POST /api/v1/users/register- Register new userPOST /api/v1/users/login- Login userGET /api/v1/users/profile- Get user profile (protected)PUT /api/v1/users/game-stats- Update game statistics (protected)
GET /api/v1/health- API health check
- Register/Login: Create an account or sign in
- Guess the Number: Try to guess the secret number between 1-10
- Get Hints: The game will tell you if your guess is too high or low
- Track Progress: Your game statistics are automatically saved
- Compete: Try to beat your best score (fewest attempts)
SecretGameNumber/
├── backend/
│ ├── controllers/
│ ├── middleware/
│ ├── models/
│ ├── routes/
│ └── server.js
├── frontend/
│ ├── public/
│ ├── src/
│ │ ├── components/
│ │ ├── context/
│ │ ├── App.js
│ │ └── index.js
│ └── package.json
├── .env.example
├── .gitignore
├── package.json
└── README-MERN.md
- Fork the repository
- Create a feature branch (
git checkout -b feat/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feat/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Adalberto Brant - Project Maintainer
- Open Source Community - Contributors
- Hacktoberfest 2025 - Participants
-
MongoDB Connection Error
- Ensure MongoDB is running
- Check your MONGODB_URI in .env
-
Port Already in Use
- Change PORT in .env file
- Kill existing processes on ports 3000/8000
-
JWT Token Issues
- Clear localStorage in browser
- Ensure JWT_SECRET is set in .env
- Use
npm run devfor hot reloading - Check browser console for frontend errors
- Check terminal for backend errors
- Use MongoDB Compass to inspect database
- Set environment variables
- Deploy backend code
- Update frontend API base URL
- Build the React app (
npm run build) - Deploy the build folder
- Set up redirects for React Router
Made with ❤️ by the open source community