A robust Spring Boot-based quiz platform that allows users to create, manage, and participate in quizzes across various categories.
-
User Management
- Registration and Authentication
- JWT-based authorization
- User profiles with points system
- Follow/Unfollow functionality
- Leaderboard system
-
Quiz Features
- Create and manage questions
- Multiple difficulty levels (Easy, Medium, Hard)
- Category-based organization
- Multiple choice questions (4 options)
- Points system based on difficulty
- Question history tracking
-
Category Management
- Create and manage categories
- Category-based question filtering
- Question count tracking per category
- Backend: Spring Boot 3.2.1
- Database: MySQL
- Security: JWT (JSON Web Tokens)
- Build Tool: Maven
- Java Version: 17
- JDK 17 or higher
- MySQL 8.0 or higher
- Maven 3.x
- Node.js (for frontend)
- Clone the Repository
git clone https://github.com/mirshaf/Web-Programming-Project
cd question-platform
- Database Setup
mysql -u root -p
Then run:
CREATE DATABASE soalpich;
- Configure Application Properties
Update src/main/resources/application.properties
:
spring.datasource.url=jdbc:mysql://localhost:3306/quizplatform
spring.datasource.username=your_username
spring.datasource.password=your_password
- Build and Run
./mvnw clean install
./mvnw spring-boot:run
POST /api/auth/register
- Register new userPOST /api/auth/login
- Login user
GET /api/questions
- Get all questionsGET /api/questions/{id}
- Get specific questionGET /api/questions/random
- Get random questionPOST /api/questions
- Create new questionPUT /api/questions/{id}
- Update questionDELETE /api/questions/{id}
- Delete questionGET /api/questions/answered
- Get user's answered questionsGET /api/questions/my
- Get user's created questions
GET /api/categories
- Get all categoriesPOST /api/categories
- Create new categoryPUT /api/categories/{id}
- Update categoryDELETE /api/categories/{id}
- Delete categoryGET /api/categories/my
- Get user's categories
GET /api/dashboard
- Get user dashboardGET /api/leaderboard
- Get user rankingsPOST /api/answers
- Submit answer to question
The application uses JWT for authentication. Include the JWT token in the Authorization header for protected endpoints:
Authorization: Bearer <jwt_token>
The application is configured to accept requests from http://localhost:3000
by default. To modify CORS settings, update the WebConfig.java
file.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature
) - Commit your changes (
git commit -m 'Add some AmazingFeature'
) - Push to the branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
- Spring Boot team for the excellent framework
- The open-source community for various dependencies used in this project
erDiagram
User {
int id PK
string username
string password
enum role
string email
int points
string avatar_url
timestamp created_at
timestamp updated_at
}
Category {
int id PK
string name
string description
int created_by FK
timestamp created_at
timestamp updated_at
}
Question {
int id PK
string text
string option1
string option2
string option3
string option4
int correct_answer
enum difficulty_level
int created_by FK
int category_id FK
array related_question_ids
timestamp created_at
timestamp updated_at
}
Answer {
int id PK
int question_id FK
int player_id FK
int selected_option
boolean is_correct
timestamp created_at
}
Follow {
int id PK
int follower_id FK
int following_id FK
timestamp created_at
}
User ||--o{ Category : "creates"
User ||--o{ Question : "creates"
User ||--o{ Answer : "submits"
Category ||--o{ Question : "contains"
Question ||--o{ Answer : "has"
User ||--o{ Follow : "follower"
User ||--o{ Follow : "following"
Question ||--o{ Question : "related to"