A full-stack sports betting web application built with React, Node.js, Express, and MongoDB. This application provides a foundation for building a sports betting platform with real-time features, user authentication, and socket-based communication.
This project follows a modern full-stack architecture:
- Frontend: React 18 with React Router for client-side routing
- Backend: Node.js with Express.js server
- Database: MongoDB with Mongoose ODM
- Authentication: Google OAuth 2.0 integration
- Real-time Communication: Socket.io for live updates
- Build Tool: Webpack with Babel for transpilation
- User Authentication: Google OAuth 2.0 login/logout
- Real-time Updates: Socket.io integration for live data
- Session Management: Express sessions for user persistence
- Responsive Design: Modern CSS with utility classes
- Development Tools: Hot reloading with Webpack Dev Server
- API Integration: RESTful API endpoints with proper error handling
blueprint-sportsbetting/
├── client/ # Frontend React application
│ ├── dist/ # Built/compiled files
│ └── src/
│ ├── components/ # React components
│ │ ├── App.js # Main app component
│ │ └── pages/ # Page components
│ │ ├── Skeleton.js # Main landing page
│ │ └── NotFound.js # 404 page
│ ├── client-socket.js # Socket.io client setup
│ ├── utilities.js # API helper functions
│ └── utilities.css # Utility CSS classes
├── server/ # Backend Express server
│ ├── models/ # Mongoose data models
│ │ └── user.js # User schema
│ ├── api.js # API routes
│ ├── auth.js # Authentication logic
│ ├── server-socket.js # Socket.io server setup
│ ├── server.js # Main server file
│ └── validator.js # Setup validation
├── package.json # Dependencies and scripts
└── webpack.config.js # Webpack configuration
- Node.js 18.x or higher
- MongoDB Atlas account (or local MongoDB)
- Google Cloud Console project for OAuth
-
Clone the repository
git clone <repository-url> cd blueprint-sportsbetting
-
Install dependencies
npm install
-
Environment Configuration
Create a
.envfile in the root directory:MONGO_SRV=your_mongodb_connection_string SESSION_SECRET=your_session_secret_key
-
Configure Google OAuth
Update the Google Client ID in:
client/src/components/pages/Skeleton.js(line 8)server/auth.js(line 7)
-
Database Configuration
Update the MongoDB connection in
server/server.js:- Replace
mongoConnectionURLwith your MongoDB Atlas connection string - Update
databaseNameto your preferred database name
- Replace
-
Development Mode (with hot reloading)
# Terminal 1: Start the backend server npm start # Terminal 2: Start the frontend with hot reloading npm run hotloader
-
Production Build
npm run build
-
Access the Application
- Development: http://localhost:5050
- Backend API: http://localhost:3000
npm start- Start the backend server with nodemonnpm run hotloader- Start webpack dev server with hot reloadingnpm run build- Build the production bundle
POST /api/login- User login with Google OAuthPOST /api/logout- User logoutGET /api/whoami- Get current user informationPOST /api/initsocket- Initialize socket connection for user
- Connection management for real-time features
- User-to-socket mapping for targeted updates
{
name: String, // User's display name
googleid: String // Google OAuth subject ID
}- Google OAuth 2.0 authentication
- Session-based user management
- JWT token verification
- Secure socket connections
- Input validation and sanitization
- React Router: Client-side routing
- Google OAuth: Seamless login/logout
- Socket.io Client: Real-time communication
- Utility Functions: API request helpers
- Responsive Design: Mobile-friendly interface
- Authentication: Update Google Client IDs in both frontend and backend
- Database: Configure MongoDB connection string
- API Routes: Add your custom endpoints in
server/api.js - Frontend Components: Build your betting interface in
client/src/components/
The application includes a complete Socket.io setup for real-time features:
- User connection management
- Automatic cleanup on disconnect
- Support for targeted user messaging
- Backend: Add routes in
server/api.js - Frontend: Create components in
client/src/components/ - Database: Define schemas in
server/models/ - Real-time: Use socket events in
server/server-socket.js
This project is licensed under the ISC License - see the LICENSE file for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request