A thrilling horror-themed escape room game built with React and Node.js, featuring 10 challenging levels across three difficulty tiers. Players navigate through dark, atmospheric puzzles while racing against time to complete each challenge.
- Features
- Tech Stack
- Prerequisites
- Installation
- Configuration
- Running the Application
- Project Structure
- Game Levels
- API Documentation
- Authentication Flow
- Key Features Implementation
- Contributing
- Future Enhancements
- Acknowledgments
- 10 Unique Levels: Progressively challenging puzzles across Easy, Medium, and Hard difficulties
- Attempt System: Limited attempts per level with retry options (score penalty)
- Score Tracking: Real-time score updates with global leaderboard
- Timer System: Track your completion time across all levels
- Level Progress: Auto-save and resume functionality
- Dark Theme: Immersive horror-themed UI with glassmorphism effects
- User Authentication: Secure JWT-based login/signup system
- Session Management: Persistent sessions with cookie-based authentication
- Profile Management: Track your stats and achievements
- Progress Tracking: Save and resume your game at any time
- Responsive Design: Seamless experience across all devices
- Smooth Animations: Framer Motion powered transitions
- Beautiful UI: Modern design with Tailwind CSS
- Toast Notifications: Real-time feedback with Sonner
- Interactive Elements: Engaging hover effects and micro-animations
- Framework: React 19.1.0
- Build Tool: Vite 6.3.5
- Styling: Tailwind CSS 4.1.8
- Animations: Framer Motion 12.23.6
- Routing: React Router DOM 7.6.2
- State Management: Zustand 5.0.5
- HTTP Client: Axios 1.9.0 with interceptors
- Form Validation: Zod 3.25.67
- Notifications: Sonner 2.0.5
- Icons: Lucide React 0.525.0
- Runtime: Node.js with Express 5.1.0
- Database: MongoDB with Mongoose 8.15.1
- Authentication: JWT (jsonwebtoken 9.0.2)
- Password Hashing: bcryptjs 3.0.2
- Environment Config: dotenv 16.5.0
- CORS: cors 2.8.5
- Validation: Zod 3.25.67
Before you begin, ensure you have the following installed:
- Node.js (v16.x or higher)
- npm or yarn
- MongoDB (local or MongoDB Atlas)
- Git
```bash git clone https://github.com/yourusername/web-escape.git cd web-escape ```
```bash cd Web-Escape npm install ```
```bash cd ../Web-Escape-Backend npm install ```
- Create Environment File (Optional)
cd Web-Escape
cp .env.example .env- Configure API URL (in
.env)
# Default: http://localhost:3000
VITE_API_URL=http://localhost:3000
Note: If you don't create a
.envfile, the app will default to
http://localhost:3000
- Create Environment File
cd Web-Escape-Backend
cp .env.example .env- Configure Environment Variables (in
.env)
# MongoDB Connection
MONGO_URL=mongodb://localhost:27017/web-escape
# or use MongoDB Atlas
# MONGO_URL=mongodb+srv://username:password@cluster.mongodb.net/web-escape
# JWT Secret (use a strong random string)
SECRET_KEY=your-super-secret-jwt-key-change-this
# Server Port (optional, defaults to 3000)
PORT=3000
# If using local MongoDB
mongodcd Web-Escape-Backend
npm run devThe backend will run on
http://localhost:3000
cd Web-Escape
npm run devThe frontend will run on
http://localhost:5173
cd Web-Escape
npm run build
npm run previewcd Web-Escape-Backend
npm startWeb-Escape/
โโโ public/ # Static assets
โ โโโ sprites/ # Game sprites
โ โโโ sounds/ # Audio files
โโโ src/
โ โโโ api/ # API configuration
โ โ โโโ axios.js # Axios interceptors
โ โโโ assets/ # Images and media
โ โโโ components/ # Reusable components
โ โ โโโ Auth/ # Login/Signup components
โ โ โโโ Dashboard.jsx
โ โ โโโ GameMenu.jsx
โ โ โโโ LevelCompleteScreen.jsx
โ โ โโโ LevelRouter.jsx
โ โ โโโ Navbar.jsx
โ โ โโโ Particle.jsx
โ โ โโโ Score.jsx
โ โ โโโ Timer.jsx
โ โโโ hooks/ # Custom React hooks
โ โ โโโ useAttempt.js
โ โโโ pages/ # Page components
โ โ โโโ Dashboard.jsx
โ โ โโโ Gameover.jsx
โ โ โโโ Home.jsx
โ โ โโโ Leaderboard.jsx
โ โโโ rooms/ # Game level components
โ โ โโโ easy/ # 3 easy levels
โ โ โ โโโ FindObjectGame.jsx
โ โ โ โโโ MatchOuest.jsx
โ โ โ โโโ ShadowShape.jsx
โ โ โโโ medium/ # 4 medium levels
โ โ โ โโโ GuessTheLiar.jsx
โ โ โ โโโ MazeEscape.jsx
โ โ โ โโโ OutputPredictor.jsx
โ โ โ โโโ PatternBreaker.jsx
โ โ โโโ hard/ # 3 hard levels
โ โ โโโ FinalEscape.jsx
โ โ โโโ FlappyBird.jsx
โ โ โโโ WordleClone.jsx
โ โโโ state/ # State management
โ โ โโโ gameStore.js # Zustand store
โ โโโ utils/ # Utility functions
โ โ โโโ Apicall.js # API endpoints
โ โโโ App.jsx # Main app component
โ โโโ main.jsx # App entry point
โโโ package.json
Web-Escape-Backend/
โโโ controllers/ # Route controllers
โ โโโ authController.js
โ โโโ gameController.js
โ โโโ levelController.js
โโโ middleware/ # Express middleware
โ โโโ isAuthenticated.js
โโโ models/ # Mongoose models
โ โโโ Level.js
โ โโโ Progress.js
โ โโโ User.js
โโโ routes/ # API routes
โ โโโ authRoutes.js
โ โโโ gameRoutes.js
โ โโโ levelRoutes.js
โโโ uploads/ # Uploaded game assets
โโโ utils/ # Utility functions
โ โโโ database.js # MongoDB connection
โ โโโ generateToken.js # JWT helpers
โโโ validators/ # Input validation
โ โโโ authValidator.js
โโโ server.js # Server entry point
โโโ package.json
- Shadow Shape - Identify shapes from shadows
- Match Quest - Memory card matching game
- Find Object - Hidden object finder
- Guess the Liar - Logic and deduction puzzle
- Maze Escape - Navigate through a wall maze
- Output Predictor - Predict code output
- Pattern Breaker - Solve pattern sequences
- Wordle Clone - Word guessing game (6 attempts)
- Flappy Bird - Skill-based flying game (score 20+)
- Final Escape - Pac-Man style maze with enemies
``` Development: http://localhost:3000/api/v1 ```
```http POST /user/register Content-Type: application/json
{ "username": "string", "email": "string", "password": "string" } ```
```http POST /user/login Content-Type: application/json
{ "email": "string", "password": "string" } ```
```http GET /game/progress Authorization: Bearer {token} ```
```http POST /game/progress/reset Authorization: Bearer {token} ```
```http GET /game/progress/getTime Authorization: Bearer {token} ```
```http PATCH /game/progress/time Authorization: Bearer {token} Content-Type: application/json
{ "timer": number } ```
```http GET /level/:levelNumber Authorization: Bearer {token} ```
```http POST /level/:levelNumber/submit Authorization: Bearer {token} Content-Type: application/json
{ "answer": "string" } ```
```http POST /game/level/:levelNumber/attempt-used Authorization: Bearer {token} ```
```http POST /game/level/:levelNumber/retry Authorization: Bearer {token} ```
- User registers/logs in
- Backend generates JWT token
- Token stored in localStorage (frontend)
- Axios interceptor automatically adds token to all requests
- Backend middleware validates token
- Protected routes accessible with valid token
The app uses Axios interceptors for centralized API management:
```javascript // Automatic token injection api.interceptors.request.use((config) => { const token = localStorage.getItem("token"); if (token) { config.headers.Authorization = `Bearer ${token}`; } return config; });
// Global error handling api.interceptors.response.use( (response) => response, (error) => { if (error.response?.status === 401) { // Handle unauthorized access } return Promise.reject(error); } ); ```
Uses Zustand for lightweight, efficient state management:
```javascript const useGameStore = create((set) => ({ currentLevel: 1, score: 0, completedLevels: [], updateScore: (points) => set((state) => ({ score: state.score + points })), // ... more actions })); ```
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (`git checkout -b feature/AmazingFeature`)
- Commit your changes (`git commit -m 'Add some AmazingFeature'`)
- Push to the branch (`git push origin feature/AmazingFeature`)
- Open a Pull Request
- Use ESLint for code linting
- Follow React best practices
- Write meaningful commit messages
- Add comments for complex logic
- Test your changes before submitting
- Multiplayer mode
- More levels and difficulty tiers
- Achievement system
- Social features (share scores)
- Mobile app version
- Sound effects and background music
- Accessibility improvements
- Dark/Light theme toggle
- Inspired by classic escape room games
- Built with modern web technologies
- Thanks to all contributors