A complete web application for managing snooker club operations including table management, player sessions, payments, canteen orders, loans, and comprehensive reporting.
- 13 Table Management: Different types (standard, main, room) with real-time status tracking
- Session Management: Timer-based sessions with automatic pricing calculation
- Player Management: Add, track, and move players between tables
- Payment Processing: Support for cash, online, and mixed payment methods
- Canteen Integration: Add food/drink orders directly to table sessions
- Loan Management: Track customer loans with partial repayment support
- Real-time Dashboard: Live table status with elapsed timers
- Comprehensive Reports: Daily, table-wise, and player-centric analytics
- Manager Accounts: Create and manage staff accounts
- Business Rules Configuration: Adjust pricing, discounts, and game rules
- System Statistics: Performance metrics and revenue tracking
- Google Sheets Integration: Automatic data backup and sync
- CSV Export: Download reports for external analysis
- Real-time Updates: Live timer updates and status changes
- Mobile Responsive: Optimized for tablet and phone use by managers
- Role-based Access: Different permissions for admin and managers
- Data Security: Encrypted passwords and secure authentication
- Audit Trail: Complete tracking of all transactions and changes
- Node.js 18+ installed
- SQLite3 (included in dependencies)
- Modern web browser
- Clone and Install Dependencies
git clone <repository-url>
cd js-snooker-club-manager
npm install- Environment Configuration
Create a
.envfile in the root directory:
PORT=3001
JWT_SECRET=your_jwt_secret_key_here
NODE_ENV=development- Start Development Servers
npm run devThis starts both the frontend (port 5173) and backend (port 3001) simultaneously.
- Access the Application
- Frontend: http://localhost:5173
- Backend API: http://localhost:3001/api
- Build the Application
npm run build- Production Environment Variables
PORT=3001
JWT_SECRET=your_strong_jwt_secret
NODE_ENV=production
DATABASE_URL=your_production_database_url (optional for PostgreSQL)- Start Production Server
npm run server:startSQLite (Default)
- Database file created automatically at
server/database/snooker_club.db - Perfect for development and small deployments
PostgreSQL (Production)
- Update connection settings in
server/database/init.js - Provide
DATABASE_URLenvironment variable - Run database migrations manually
Admin Account:
- Email: admin@snookerclub.com
- Password: admin123
Manager Account:
- Email: manager@snookerclub.com
- Password: manager123
Important: Change these default passwords immediately after first login!
POST /api/auth/login
GET /api/auth/verify
GET /api/tables # Get all tables
GET /api/tables/:id # Get table details
POST /api/tables/:id/start-session # Start new session
POST /api/sessions/:id/end # End session with payment
POST /api/sessions/:id/next-game # Start next game
POST /api/sessions/:id/add-player # Add player to session
POST /api/sessions/:id/move-players # Move players to another table
POST /api/canteen/session/:sessionId # Add canteen item
GET /api/canteen/session/:sessionId # Get session items
DELETE /api/canteen/:id # Remove canteen item
GET /api/loans # Get all loans
POST /api/loans # Create new loan
POST /api/loans/:id/payment # Add loan payment
GET /api/loans/:id/history # Get loan payment history
GET /api/reports/daily # Daily report
GET /api/reports/daily/export # Export daily CSV
GET /api/reports/manager/:id # Manager performance
GET /api/reports/player/:id # Player activity
GET /api/reports/trends # Revenue trends
GET /api/admin/managers # Get all managers
POST /api/admin/managers # Create manager
PUT /api/admin/managers/:id # Update manager
DELETE /api/admin/managers/:id # Delete manager
GET /api/admin/settings # Get system settings
POST /api/admin/settings # Update settings
GET /api/admin/stats # System statistics
- Standard Tables (1-10): Rs 150 per game
- Main Tables (11-12): Rs 250 per game
- Room Table (13): Rs 500 per hour
- Century Games: 2x multiplier on base price
- Single: Regular snooker game
- Double: Two-player team format
- Century: Premium game type with multiplier
- Hourly: Time-based billing for room bookings
- Cash: Traditional cash payment
- Online: Bank transfer with account and transaction tracking
- Mixed: Combination of cash and online payment
- Automatic loan creation for underpayments
- Partial repayment tracking
- Interest-free (configurable)
- Customer-wise loan summaries
Enable automatic data backup to Google Sheets:
-
Create Google Service Account
- Go to Google Cloud Console
- Create new project or use existing
- Enable Google Sheets API
- Create service account and download JSON key
-
Configure in Admin Panel
- Navigate to Admin > Settings
- Enable Google Sheets Sync
- Enter your Google Sheets ID
- Paste the service account JSON
-
Sheet Structure
- Sessions tab: All game sessions
- Canteen tab: Food/drink orders
- Loans tab: Loan records and payments
- Managers tab: Staff performance data
Run the test suite:
npm testTests cover:
- API endpoint functionality
- Authentication and authorization
- Business logic validation
- Database operations
- Error handling
├── server/
│ ├── database/
│ │ ├── init.js # Database setup and seeding
│ │ └── snooker_club.db # SQLite database file
│ ├── middleware/
│ │ └── auth.js # Authentication middleware
│ ├── routes/ # API route handlers
│ │ ├── auth.js # Authentication routes
│ │ ├── tables.js # Table management
│ │ ├── sessions.js # Session operations
│ │ ├── players.js # Player management
│ │ ├── canteen.js # Canteen orders
│ │ ├── loans.js # Loan system
│ │ ├── reports.js # Analytics and reports
│ │ └── admin.js # Admin panel functionality
│ └── index.js # Express server setup
├── src/
│ ├── components/ # React components
│ │ ├── Auth/ # Login components
│ │ ├── Dashboard/ # Main dashboard and table cards
│ │ ├── Reports/ # Analytics and reporting
│ │ ├── Loans/ # Loan management interface
│ │ ├── Admin/ # Admin panel components
│ │ └── Layout/ # Header and navigation
│ ├── contexts/
│ │ └── AuthContext.tsx # Authentication context
│ └── App.tsx # Main application component
└── package.json # Dependencies and scripts
Database Connection Errors
- Ensure SQLite file has write permissions
- Check database file location and path
- Verify database initialization completed
Authentication Failures
- Verify JWT secret is set in environment
- Check token expiration (24 hours default)
- Clear browser localStorage if needed
Port Conflicts
- Frontend default: 5173
- Backend default: 3001
- Change ports in vite.config.ts and server/index.js
Google Sheets Sync Issues
- Verify service account has sheet access
- Check JSON format in settings
- Ensure Google Sheets API is enabled
- Restart server after database schema changes
- Clear browser cache for frontend updates
- Monitor database size and optimize queries
- Use appropriate table indexes for large datasets
- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Create GitHub issues for bugs
- Check documentation for common solutions
- Review API endpoints for integration help
Built with ❤️ for snooker club management