Skip to content

Latest commit

 

History

History
481 lines (387 loc) · 14.1 KB

File metadata and controls

481 lines (387 loc) · 14.1 KB

📊 Project Summary - Online Quiz System

🎯 Project Information

Project Title: Online Quiz System (Multi-Client Real-Time Quiz Game)
Course: Network Programming Module
Technology Stack: Java 17, Spring Boot, HTML/CSS, Maven
Team Size: 5 Members
Concepts Demonstrated: 5 Core Network Programming Concepts


📋 Project Overview

A comprehensive network programming application that demonstrates practical implementation of TCP sockets, multithreading, synchronization, UDP broadcasting, and client-server communication through an interactive quiz game.

Key Features

✅ Multi-client support (up to 10 concurrent players)
✅ Real-time question delivery and answer submission
✅ Thread-safe score management
✅ UDP broadcast of final results
✅ Web-based monitoring dashboard
✅ RESTful API for status and leaderboard


🏗️ System Architecture

┌─────────────────────────────────────────────────────────────────┐
│                        SPRING BOOT SERVER                        │
│  ┌──────────────┐  ┌──────────────┐  ┌──────────────┐          │
│  │  Web Server  │  │  TCP Server  │  │ UDP Broadcaster│         │
│  │  (Port 8080) │  │  (Port 5000) │  │  (Port 5001)  │         │
│  └──────┬───────┘  └──────┬───────┘  └──────┬────────┘         │
│         │                  │                  │                  │
│  ┌──────▼──────────────────▼──────────────────▼────────┐        │
│  │              QUIZ SERVICE (Synchronized)             │        │
│  │  • Player Management  • Score Tracking  • Questions  │        │
│  └──────────────────────────────────────────────────────┘        │
└─────────────────────────────────────────────────────────────────┘
                             │
        ┌────────────────────┼────────────────────┐
        │                    │                    │
   ┌────▼────┐          ┌────▼────┐         ┌────▼────┐
   │ Client 1│          │ Client 2│         │ Client 3│
   │  (TCP)  │          │  (TCP)  │         │  (TCP)  │
   │  (UDP)  │          │  (UDP)  │         │  (UDP)  │
   └─────────┘          └─────────┘         └─────────┘

🌐 Network Concepts Implementation

1. TCP Socket Programming ✅

Files: QuizServer.java, QuizClient.java

  • Server socket listens on port 5000
  • Clients connect via TCP for reliable communication
  • Bidirectional data exchange for questions and answers

2. Multithreading ✅

Files: ClientHandler.java, QuizServer.java

  • Thread pool with 10 worker threads
  • Each client connection handled by separate thread
  • Concurrent processing of multiple clients

3. Synchronization ✅

Files: QuizService.java, Player.java

  • Synchronized methods for player management
  • Synchronized blocks for score updates
  • Thread-safe collections (ConcurrentHashMap)
  • Prevents race conditions

4. UDP Broadcasting ✅

Files: UDPBroadcaster.java, UDPResultsListener.java

  • Broadcasts final results to all clients
  • Uses datagram sockets on port 5001
  • One-to-many communication

5. Client-Server Communication ✅

Files: All components

  • JSON-based message protocol
  • Request-response pattern
  • Structured message types (JOIN, QUESTION, ANSWER, etc.)

📁 Project Structure

MCQ spring/
│
├── 📄 pom.xml                                    # Maven configuration
├── 📄 README.md                                  # Complete documentation
├── 📄 SETUP_GUIDE.md                             # Installation guide
├── 📄 NETWORK_CONCEPTS.md                        # Concept explanations
├── 📄 QUICK_START.md                             # Quick reference
├── 📄 PROJECT_SUMMARY.md                         # This file
├── 📄 .gitignore                                 # Git ignore rules
├── 🔧 run-server.bat                             # Server launcher
├── 🔧 run-client.bat                             # Client launcher
│
└── src/main/
    ├── java/com/quiz/
    │   │
    │   ├── 📦 QuizApplication.java               # Spring Boot main
    │   │
    │   ├── 📂 model/
    │   │   ├── Question.java                     # Question model
    │   │   ├── Player.java                       # Player model (synchronized)
    │   │   └── QuizMessage.java                  # Message protocol
    │   │
    │   ├── 📂 service/
    │   │   └── QuizService.java                  # Quiz logic + synchronization
    │   │
    │   ├── 📂 server/
    │   │   ├── QuizServer.java                   # TCP server + multithreading
    │   │   ├── ClientHandler.java                # Thread per client
    │   │   └── UDPBroadcaster.java               # UDP broadcasting
    │   │
    │   ├── 📂 client/
    │   │   ├── QuizClient.java                   # Client application
    │   │   └── UDPResultsListener.java           # UDP receiver
    │   │
    │   └── 📂 controller/
    │       └── QuizController.java               # REST API
    │
    └── resources/
        ├── application.properties                # Configuration
        └── static/
            ├── index.html                        # Web UI
            ├── styles.css                        # Styling
            └── script.js                         # Frontend logic

🎮 Application Flow

1. Server Startup

1. Spring Boot application starts
2. TCP server socket binds to port 5000
3. Thread pool created (10 threads)
4. UDP broadcaster initialized
5. Web server starts on port 8080
6. Server waits for client connections

2. Client Connection

1. Client connects via TCP socket
2. Server accepts connection
3. New ClientHandler thread created
4. Client sends player name
5. Server adds player (synchronized)
6. Client waits for quiz start

3. Quiz Execution

1. Server detects 2+ players
2. Quiz starts automatically
3. For each question:
   a. Server broadcasts question (TCP)
   b. Clients receive and display
   c. Clients submit answers (TCP)
   d. Server checks answers (synchronized)
   e. Server updates scores (synchronized)
   f. Server sends score updates (TCP)
4. Quiz ends after all questions

4. Results Broadcasting

1. Server calculates final leaderboard
2. Server sends results via TCP to each client
3. Server broadcasts results via UDP to all
4. Clients display final results
5. Clients receive UDP broadcast
6. Connections close

👥 Team Roles & Responsibilities

Member Role Concept Files Responsibilities
Member 1 Server Developer TCP Socket QuizServer.java Create quiz server, accept connections
Member 2 Manager Multithreading ClientHandler.java Handle multiple clients concurrently
Member 3 Client Developer Client-Server QuizClient.java Develop client app, receive quiz data
Member 4 Score Manager Synchronization QuizService.java Manage player scores safely
Member 5 Broadcaster UDP Datagram UDPBroadcaster.java Broadcast final results

📊 Technical Specifications

Server Specifications

  • Platform: Spring Boot 3.1.5
  • Java Version: 17
  • TCP Port: 5000
  • UDP Port: 5001
  • HTTP Port: 8080
  • Max Clients: 10 (configurable)
  • Thread Pool: Fixed size (10 threads)

Client Specifications

  • Platform: Java Console Application
  • Java Version: 17
  • Connection: TCP Socket
  • UDP Listener: Port 5001
  • Protocol: JSON messages

Network Protocol

{
  "type": "QUESTION|ANSWER|SCORE_UPDATE|QUIZ_END|JOIN|WAITING|ERROR",
  "content": "Message content",
  "data": { /* Additional data */ }
}

🔧 Configuration

Application Properties

# HTTP Server
server.port=8080

# TCP Socket Server
quiz.server.tcp.port=5000

# UDP Broadcast
quiz.server.udp.port=5001

# Concurrency
quiz.server.max.clients=10

Questions Database

  • 5 multiple-choice questions
  • 4 options per question
  • 10 points per correct answer
  • Questions hardcoded in QuizService.java

🧪 Testing Scenarios

Test 1: Basic Functionality

  • Start server
  • Connect 2 clients
  • Complete quiz
  • Verify results

Test 2: Concurrent Clients

  • Start server
  • Connect 5+ clients simultaneously
  • Verify all receive questions
  • Check score synchronization

Test 3: Network Concepts

  • TCP: Monitor connection establishment
  • Multithreading: Check thread creation in logs
  • Synchronization: Verify score consistency
  • UDP: Confirm broadcast reception
  • Client-Server: Observe message exchange

📈 Performance Metrics

Scalability

  • ✅ Supports up to 10 concurrent clients
  • ✅ Thread pool prevents resource exhaustion
  • ✅ Efficient message handling

Reliability

  • ✅ TCP ensures message delivery
  • ✅ Synchronization prevents data corruption
  • ✅ Error handling for disconnections

Responsiveness

  • ✅ Non-blocking server operations
  • ✅ Immediate question delivery
  • ✅ Real-time score updates

🎓 Learning Outcomes

Technical Skills Gained

✅ Socket programming (TCP & UDP)
✅ Multithreaded application development
✅ Thread synchronization techniques
✅ Client-server architecture design
✅ Network protocol design
✅ Spring Boot framework
✅ RESTful API development
✅ Web frontend development

Concepts Mastered

✅ Connection-oriented vs connectionless protocols
✅ Concurrent programming
✅ Race condition prevention
✅ Broadcasting mechanisms
✅ Request-response patterns


🚀 Deployment Instructions

Prerequisites

  • Java JDK 17+
  • Maven 3.6+
  • Network connectivity

Build

mvn clean install

Run Server

mvn spring-boot:run

OR

run-server.bat

Run Client

java -cp target\online-quiz-system-1.0.0.jar com.quiz.client.QuizClient

OR

run-client.bat

Access Web UI

http://localhost:8080

📚 Documentation Files

File Purpose Audience
README.md Complete documentation All users
SETUP_GUIDE.md Installation & setup New users
NETWORK_CONCEPTS.md Concept explanations Students/Instructors
QUICK_START.md Quick reference Developers
PROJECT_SUMMARY.md Overview & summary Reviewers/Instructors

🎯 Project Achievements

Functional Requirements ✅

  • Multi-client support
  • Real-time quiz delivery
  • Score tracking
  • Results broadcasting
  • Web monitoring

Technical Requirements ✅

  • TCP socket programming
  • Multithreading implementation
  • Synchronization mechanisms
  • UDP broadcasting
  • Client-server communication

Additional Features ✅

  • Web dashboard
  • REST API
  • Comprehensive documentation
  • Easy-to-use launchers
  • Error handling

💡 Key Highlights

Innovation

  • 🌟 Combines 5 network concepts in one application
  • 🌟 Real-world practical implementation
  • 🌟 Modern tech stack (Spring Boot)
  • 🌟 Professional-grade code structure

Code Quality

  • ✨ Well-documented code
  • ✨ Clean architecture
  • ✨ Proper error handling
  • ✨ Thread-safe implementations

User Experience

  • 🎨 Intuitive web interface
  • 🎨 Clear console output
  • 🎨 Easy setup process
  • 🎨 Comprehensive documentation

🏆 Project Success Criteria

Functionality ✅

  • Application runs without errors
  • All network concepts demonstrated
  • Multiple clients work concurrently
  • Results are accurate and consistent

Code Quality ✅

  • Clean, readable code
  • Proper documentation
  • Error handling implemented
  • Best practices followed

Documentation ✅

  • Complete README
  • Setup instructions
  • Concept explanations
  • Code comments

Demonstration ✅

  • Live demo possible
  • All features working
  • Concepts clearly visible
  • Easy to explain

📞 Support & Resources

Documentation

  • Full docs: README.md
  • Setup: SETUP_GUIDE.md
  • Concepts: NETWORK_CONCEPTS.md
  • Quick ref: QUICK_START.md

Code Structure

  • Well-commented source code
  • Clear package organization
  • Separation of concerns

Testing

  • Manual testing scenarios
  • Network monitoring tools
  • API endpoints for verification

🎉 Conclusion

This project successfully demonstrates all 5 required network programming concepts through a practical, real-world application. The implementation showcases:

Technical Proficiency: Proper use of sockets, threads, and synchronization
System Design: Clean client-server architecture
Code Quality: Well-structured, documented, and maintainable code
Practical Application: Real-world use case (quiz game)
Comprehensive Documentation: Multiple guides for different audiences

The project is ready for demonstration and evaluation! 🚀


Project Status: ✅ COMPLETE
Build Status: ✅ SUCCESS
Test Status: ✅ PASSED
Documentation: ✅ COMPLETE


Built with ❤️ for Network Programming Module