Skip to content

rohitgami11/LivePollingSystem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

6 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Live Polling System

A real-time interactive polling system designed for educational environments, enabling teachers to create live polls and students to participate in real-time. Built with modern web technologies for seamless classroom engagement.

πŸš€ Features

For Teachers

  • Real-time Poll Creation: Create polls with multiple choice questions and set custom durations
  • Live Results: View student responses in real-time with visual progress bars
  • Participant Management: See all connected students and manage participation
  • Chat Integration: Built-in chat system for classroom communication
  • Student Management: Ability to remove disruptive students from the session
  • Poll History: Access and review past polls with detailed analytics

For Students

  • Easy Participation: Simple name entry and one-click poll participation
  • Real-time Updates: See live poll results and countdown timers
  • Instant Feedback: View correct answers and performance immediately
  • Chat Access: Communicate with teacher and classmates
  • Session Persistence: Rejoin sessions seamlessly if disconnected

Technical Features

  • Real-time Communication: WebSocket-based live updates using Socket.IO
  • Responsive Design: Modern UI built with React and TailwindCSS
  • Data Persistence: MongoDB integration for poll history and analytics
  • Cross-platform: Works on desktop, tablet, and mobile devices
  • Scalable Architecture: Modular backend with RESTful API endpoints

πŸ—οΈ Architecture

Backend (lpsbackend/)

  • Node.js with Express.js framework
  • Socket.IO for real-time bidirectional communication
  • MongoDB with Mongoose ODM for data persistence
  • CORS enabled for cross-origin requests
  • Environment-based configuration with dotenv

Frontend (lpsfrontend/)

  • React 19 with modern hooks and functional components
  • React Router for client-side navigation
  • TailwindCSS for responsive and modern styling
  • Socket.IO Client for real-time communication
  • Axios for HTTP API calls
  • Vite for fast development and building

πŸ“ Project Structure

LivePollingSystem/
β”œβ”€β”€ lpsbackend/                 # Backend server
β”‚   β”œβ”€β”€ index.js               # Main server entry point
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   └── Poll.js           # MongoDB Poll schema
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   └── history.js        # Poll history API endpoints
β”‚   β”œβ”€β”€ socket/
β”‚   β”‚   └── pollSocket.js     # Socket.IO event handlers
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   └── database.js       # MongoDB connection utility
β”‚   └── package.json
β”œβ”€β”€ lpsfrontend/               # Frontend React application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/       # Reusable UI components
β”‚   β”‚   β”‚   β”œβ”€β”€ ActivePoll.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ ChatPopup.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ PollForm.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ PollResult.jsx
β”‚   β”‚   β”‚   └── ...
β”‚   β”‚   β”œβ”€β”€ pages/           # Main application pages
β”‚   β”‚   β”‚   β”œβ”€β”€ RoleSelector.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ TeacherPage.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ StudentPage.jsx
β”‚   β”‚   β”‚   └── PollHistory.jsx
β”‚   β”‚   β”œβ”€β”€ utils/           # Utility functions
β”‚   β”‚   β”‚   β”œβ”€β”€ api.js       # Axios API configuration
β”‚   β”‚   β”‚   └── socket.js    # Socket.IO client setup
β”‚   β”‚   β”œβ”€β”€ App.jsx          # Main application component
β”‚   β”‚   └── main.jsx         # Application entry point
β”‚   └── package.json
└── README.md

πŸ› οΈ Installation & Setup

Prerequisites

  • Node.js (v18 or higher)
  • MongoDB (local installation or MongoDB Atlas)
  • npm or yarn package manager

Backend Setup

  1. Navigate to backend directory:

    cd lpsbackend
  2. Install dependencies:

    npm install
  3. Create environment file:

    # Create .env file in lpsbackend/
    MONGODB_URI=mongodb://localhost:27017/live-polling-system
    PORT=8000
  4. Start the server:

    npm start

Frontend Setup

  1. Navigate to frontend directory:

    cd lpsfrontend
  2. Install dependencies:

    npm install
  3. Create environment file:

    # Create .env file in lpsfrontend/
    VITE_BACKEND_URI=http://localhost:8000
  4. Start the development server:

    npm run dev

πŸš€ Usage

Starting a Session

  1. Teacher Setup:

    • Open the application in your browser
    • Select "Teacher" role
    • Wait for students to join
  2. Student Setup:

    • Open the application in your browser
    • Select "Student" role
    • Enter your name to join the session

Creating and Running Polls

  1. Teacher creates a poll:

    • Click "Create New Poll"
    • Enter the question
    • Add multiple choice options
    • Mark correct answers (optional)
    • Set poll duration
    • Click "Start Poll"
  2. Students participate:

    • See the poll question and options
    • Select an answer within the time limit
    • View real-time results
  3. Results and Analytics:

    • View live response counts
    • See correct answer indicators
    • Access detailed poll history

πŸ”§ Configuration

Environment Variables

Backend (.env):

MONGODB_URI=mongodb://localhost:27017/live-polling-system
PORT=8000
NODE_ENV=development

Frontend (.env):

VITE_BACKEND_URI=http://localhost:8000

MongoDB Schema

The Poll model includes:

  • Question text
  • Multiple choice options with correct answer flags
  • Student responses with timestamps
  • Poll duration and end times
  • Creation and completion timestamps

πŸ“‘ API Endpoints

REST API

  • GET /history - Retrieve poll history
  • POST /history - Save completed poll

Socket.IO Events

  • join - Student/teacher joins session
  • create_poll - Teacher creates new poll
  • submit_answer - Student submits answer
  • poll_started - Broadcast poll to all participants
  • poll_ended - Broadcast poll results
  • chat_message - Real-time chat messages
  • kick_student - Teacher removes student

🎨 UI Components

Core Components

  • RoleSelector: Initial role selection interface
  • TeacherPage: Main teacher dashboard with poll controls
  • StudentPage: Student interface for poll participation
  • ActivePoll: Real-time poll display with countdown
  • PollResult: Results visualization with progress bars
  • ChatPopup: Real-time chat interface
  • PollHistory: Historical poll data and analytics

πŸ”’ Security Features

  • Input Validation: Server-side validation for all inputs
  • Duplicate Prevention: Prevents multiple answers from same student
  • Session Management: Tracks connected participants
  • Error Handling: Graceful error handling and user feedback

πŸš€ Deployment

Backend Deployment

  1. Set up MongoDB (local or cloud)
  2. Configure environment variables
  3. Deploy to your preferred hosting service (Heroku, AWS, etc.)

Frontend Deployment

  1. Build the production version: npm run build
  2. Deploy the dist folder to your hosting service
  3. Configure environment variables for production

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

πŸ†˜ Support

For issues and questions:

  1. Check the existing issues
  2. Create a new issue with detailed description
  3. Include error logs and steps to reproduce

Built with ❀️ for modern education

About

A real-time live polling system for educational environments, enabling teachers to create interactive polls and students to participate instantly. Built with React 19, Node.js, and Socket.IO, featuring live results, chat functionality, student management, and poll history. Perfect for classroom engagement and remote learning.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages