"প্রাকটিস করি প্রতিদিন এবং জয়ী হই।" এটা আমাদের প্রোজেক্টর স্লোগান। যেখানে ছাত্রছাত্রীরা এবং জব প্রত্যাশীরা প্রতিদিন MCQ প্রশ্ন প্রাকটিস করবে। যা তাদের জিততে সাহায্য করবে। একাডেমিক লাইফে, জব প্রস্তুতি ও ভর্তি পরীক্ষা ভালো অবস্থান তইরি করতে।
Comprehensive Documentation for Quiz Application Backend
Introduction
This documentation outlines the backend architecture, API design, and necessary diagrams for the Quiz Application. The system is designed with a modular approach to handle user authentication, quiz management, participation, and leaderboard functionalities. The structure ensures scalability, maintainability, and ease of integration for large-scale deployment.
1. Backend Architecture Overview
The application follows the RESTful API principles and is built with the following modules:
1.1 Authentication Module
- Purpose: Handles user and admin authentication.
- Endpoints:
POST /auth/register
: Register a new user.POST /auth/register-admin
: Register a new admin.POST /auth/login
: Authenticate user and issue JWT.POST /auth/admin-login
: Authenticate admin and issue JWT.POST /auth/refresh-token
: Refresh JWT using the refresh token.
1.2 Quiz Management Module
- Purpose: Admin functionalities for quiz creation and management.
- Endpoints:
GET /admin/quiz-sets
: Fetch all quiz sets.POST /admin/quiz-sets
: Create a new quiz set.PATCH /admin/quiz-sets/{id}
: Update quiz set details.DELETE /admin/quiz-sets/{id}
: Delete a quiz set.POST /admin/quiz-sets/{id}/questions
: Add a question to a quiz set.DELETE /admin/quiz-sets/{id}/questions/{questionId}
: Remove a question.PATCH /admin/quiz-sets/{id}/questions/{questionId}
: Update a question.
1.3 Quiz Participation Module
- Purpose: Enables users to take quizzes.
- Endpoints:
GET /quizzes/{id}
: Retrieve quiz details.GET /quiz-sets
: Fetch all available quiz sets.POST /quizzes/{id}/attempts
: Submit quiz answers.
1.4 Leaderboard Module
- Purpose: Manage leaderboard data for quizzes.
- Endpoints:
GET /quizzes/{id}/attempts
: Fetch quiz attempts for leaderboard.
2. Entity-Relationship Diagram (ERD)
The ERD captures relationships between database entities:
- Users: Store user information (name, email, role).
- QuizSets: Group quizzes into sets.
- Questions: Questions under a quiz set.
- Attempts: User quiz attempts.
Users (id, name, email, role, password)
|
|----< QuizSets (id, title, description, status)
|
|----< Questions (id, quizSetId, content, options, correctOption)
|
|----< Attempts (id, userId, questionId, selectedOption, isCorrect)
3. Schema Diagram
Users Table:
Field | Type | Constraints |
---|---|---|
id | UUID | Primary Key |
name | VARCHAR(100) | NOT NULL |
VARCHAR(255) | UNIQUE, NOT NULL | |
role | ENUM | ('user', 'admin') |
password | VARCHAR(255) | NOT NULL |
QuizSets Table:
Field | Type | Constraints |
---|---|---|
id | UUID | Primary Key |
title | VARCHAR(255) | NOT NULL |
description | TEXT | |
status | ENUM | ('draft', 'published') |
Questions Table:
Field | Type | Constraints |
---|---|---|
id | UUID | Primary Key |
quizSetId | UUID | Foreign Key (QuizSets) |
content | TEXT | NOT NULL |
options | JSON | NOT NULL |
correctOption | VARCHAR(255) | NOT NULL |
Attempts Table:
Field | Type | Constraints |
---|---|---|
id | UUID | Primary Key |
userId | UUID | Foreign Key (Users) |
questionId | UUID | Foreign Key (Questions) |
selectedOption | VARCHAR(255) | |
isCorrect | BOOLEAN |
4. UML Diagrams
4.1 Use Case Diagram
- Actors: Admin, User
- Use Cases: Register, Login, Manage Quizzes, Take Quiz, View Leaderboard
4.2 Class Diagram
Classes:
- User
- QuizSet
- Question
- Attempt
4.3 Sequence Diagram
Example: Quiz Attempt Submission
- User selects options.
- Client sends answers to
POST /quizzes/{id}/attempts
. - Server validates answers and responds with results.
4.4 Activity Diagram
Example: User Quiz Flow
- Login.
- View available quizzes.
- Take quiz.
- Submit answers.
- View results.
4.5 State Diagram
States:
- Quiz: Draft -> Published -> Completed
4.6 Component Diagram
Components:
- Authentication Service
- Quiz Management Service
- Leaderboard Service
4.7 Deployment Diagram
- Client: Web browser/mobile app.
- Server: Backend service.
- Database: Relational database (PostgreSQL/MySQL).
5. API Design Diagrams
5.1 API Endpoints
/auth
- POST /register
- POST /register-admin
- POST /login
- POST /admin-login
- POST /refresh-token
/admin
- GET /quiz-sets
- POST /quiz-sets
- PATCH /quiz-sets/{id}
- DELETE /quiz-sets/{id}
- POST /quiz-sets/{id}/questions
- DELETE /quiz-sets/{id}/questions/{questionId}
- PATCH /quiz-sets/{id}/questions/{questionId}
/quizzes
- GET /{id}
- POST /{id}/attempts
/leaderboard
- GET /quizzes/{id}/attempts
5.2 Data Flow
-
User Registration/Login:
- Client ->
/auth/register
-> Server -> Database
- Client ->
-
Quiz Management:
- Admin ->
/admin/quiz-sets
-> Server -> Database
- Admin ->
-
Quiz Participation:
- User ->
/quizzes/{id}
-> Server -> Database
- User ->
-
Leaderboard:
- Client ->
/leaderboard
-> Server -> Database
- Client ->
6. Engineering Best Practices
- Scalability: Use microservices architecture.
- Security: Implement JWT for authentication and secure sensitive data.
- Performance: Optimize database queries and use caching mechanisms.
- Testing: Perform unit, integration, and end-to-end tests.
Conclusion
This documentation provides a clear blueprint for building the backend of the Quiz Application. By adhering to the described architecture and diagrams, developers can ensure the project meets industry standards for scalability, maintainability, and user experience.