A real-time polling system built with Express.js backend and React frontend, featuring Socket.IO for real-time communication and React Query for efficient API management.
- ✅ Create new polls with configurable time limits
- ✅ View live polling results in real-time
- ✅ Manage connected students (kick students)
- ✅ View past poll results
- ✅ Built-in chat system
- ✅ Join sessions with unique names (per browser tab)
- ✅ Answer polls with countdown timer
- ✅ View live results after answering
- ✅ Automatic timeout handling (60 seconds default)
- ✅ Built-in chat system
- ✅ Real-time updates using Socket.IO
- ✅ React Query for efficient API management
- ✅ Redux for state management
- ✅ Responsive design
- ✅ Modern UI with animations
polling-system/
├── backend/ # Express.js backend
│ ├── package.json
│ └── server.js # Main server file
├── frontend/ # React frontend
│ ├── public/
│ │ └── index.html
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── hooks/ # React Query hooks
│ │ ├── services/ # API and Socket services
│ │ ├── store/ # Redux store and slices
│ │ ├── App.js
│ │ └── index.js
│ └── package.json
└── README.md
- Node.js (v14 or higher)
- npm or yarn
- Navigate to the backend directory:
cd backend- Install dependencies:
npm install- Start the development server:
npm run devThe backend will run on http://localhost:5000
- Navigate to the frontend directory:
cd frontend- Install dependencies:
npm install- Start the development server:
npm startThe frontend will run on http://localhost:3000
-
Open the application in your browser at
http://localhost:3000 -
Choose your role:
- Teacher: Can create polls and manage the session
- Student: Can join and answer polls
-
For Students:
- Enter your name (unique per browser tab)
- Wait for the teacher to start a poll
- Answer within the time limit
- View live results
-
For Teachers:
- Create polls with questions and options
- Set time limits (10-300 seconds)
- View live results as students answer
- Manage connected students
- Use the chat system
GET /api/polls- Get all pollsGET /api/current-poll- Get current active pollGET /api/students- Get connected studentsGET /api/chat-messages- Get chat messagesPOST /api/end-poll- End current pollPOST /api/kick-student/:id- Kick a student
join_as_student- Student joins sessioncreate_poll- Teacher creates new pollsubmit_answer- Student submits answersend_chat_message- Send chat message
- Express.js - Web framework
- Socket.IO - Real-time communication
- CORS - Cross-origin resource sharing
- UUID - Unique identifier generation
- React - UI library
- Redux Toolkit - State management
- React Query - Server state management
- Socket.IO Client - Real-time communication
- React Router - Client-side routing
- The server uses nodemon for automatic restarts
- Socket.IO handles real-time events
- In-memory storage (can be extended with database)
- React Query handles API calls and caching
- Redux manages client-side state
- Socket.IO client connects to backend
- Responsive design with CSS Grid and Flexbox
-
Set environment variables:
PORT- Server port (default: 5000)NODE_ENV- Environment (production/development)
-
Install dependencies and start:
npm install
npm start- Build the application:
npm run build- Serve the build folder using a static server
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request