Sql_Adv_Proj

πŸŽ“ Examination Management System - Frontend

![React](https://img.shields.io/badge/React-19.2.0-61DAFB?style=for-the-badge&logo=react&logoColor=white) ![Vite](https://img.shields.io/badge/Vite-7.2.5-646CFF?style=for-the-badge&logo=vite&logoColor=white) ![Tailwind CSS](https://img.shields.io/badge/Tailwind_CSS-4.1.18-06B6D4?style=for-the-badge&logo=tailwindcss&logoColor=white) ![React Router](https://img.shields.io/badge/React_Router-7.12.0-CA4245?style=for-the-badge&logo=reactrouter&logoColor=white) **A modern, responsive React application for managing educational examinations with real-time features.** [Live Demo](#) β€’ [Features](#-features) β€’ [Getting Started](#-getting-started) β€’ [Documentation](#-documentation)

πŸ“‹ Table of Contents


🎯 Overview

The Examination Management System Frontend is a feature-rich React application that provides an intuitive interface for students and instructors to manage educational examinations. Built with React 19, Vite, and Tailwind CSS, this application offers:


✨ Features

For Students

| Feature | Description | |β€”β€”β€”|β€”β€”β€”β€”-| | πŸ“ Take Exams | Interactive exam interface with timer | | ⏱️ Real-time Timer | Countdown with auto-submit on expiry | | 🚩 Question Flagging | Mark questions for review | | πŸ“Š View Results | Detailed exam results with correct answers | | πŸ“š Browse Courses | Explore available courses | | πŸ’Ύ State Persistence | Resume exams after page refresh |

For Instructors

| Feature | Description | |β€”β€”β€”|β€”β€”β€”β€”-| | πŸ“– Manage Courses | Create and edit courses | | πŸ‘¨β€πŸŽ“ Manage Students | View and assign students to tracks | | πŸ“ Create Exams | Generate exams for courses | | πŸ“ˆ View Analytics | Monitor student performance |

General Features

| Feature | Description | |β€”β€”β€”|β€”β€”β€”β€”-| | πŸ” Authentication | Secure login/register with role detection | | πŸ›‘οΈ Protected Routes | Role-based access control | | πŸ”” Toast Notifications | Real-time feedback on actions | | 🎨 Responsive Design | Mobile-first approach | | ⚑ Fast Performance | Optimized with Vite |


πŸ› οΈ Tech Stack

Technology Version Purpose
React 19.2.0 UI Library
Vite 7.2.5 Build Tool & Dev Server
React Router 7.12.0 Client-side Routing
Tailwind CSS 4.1.18 Utility-first CSS Framework
Axios 1.13.2 HTTP Client
React Hot Toast 2.6.0 Toast Notifications
ESLint 9.39.1 Code Linting

πŸ“ Project Structure

Front_sql_projrct/
β”‚
β”œβ”€β”€ πŸ“„ index.html               # HTML entry point
β”œβ”€β”€ πŸ“„ package.json             # Dependencies & scripts
β”œβ”€β”€ πŸ“„ vite.config.js           # Vite configuration
β”œβ”€β”€ πŸ“„ eslint.config.js         # ESLint configuration
β”‚
β”œβ”€β”€ πŸ“ public/                  # Static assets
β”‚
└── πŸ“ src/
    β”‚
    β”œβ”€β”€ πŸ“„ main.jsx             # Application entry point
    β”œβ”€β”€ πŸ“„ App.jsx              # Root component & routing
    β”œβ”€β”€ πŸ“„ App.css              # Global styles & animations
    β”‚
    β”œβ”€β”€ 🌐 api/
    β”‚   └── axios.js            # Axios instance & interceptors
    β”‚
    β”œβ”€β”€ 🧩 components/
    β”‚   β”œβ”€β”€ auth/
    β”‚   β”‚   └── ProtectedRoute.jsx   # Route protection HOC
    β”‚   β”‚
    β”‚   β”œβ”€β”€ common/
    β”‚   β”‚   β”œβ”€β”€ Badge.jsx       # Badge & StatusBadge
    β”‚   β”‚   β”œβ”€β”€ Button.jsx      # Button with variants
    β”‚   β”‚   β”œβ”€β”€ Card.jsx        # Card component
    β”‚   β”‚   β”œβ”€β”€ EmptyState.jsx  # Empty state display
    β”‚   β”‚   β”œβ”€β”€ Input.jsx       # Input with validation
    β”‚   β”‚   β”œβ”€β”€ Loader.jsx      # Loader & Skeleton
    β”‚   β”‚   β”œβ”€β”€ Modal.jsx       # Modal & ConfirmModal
    β”‚   β”‚   └── index.js        # Barrel export
    β”‚   β”‚
    β”‚   └── layout/
    β”‚       β”œβ”€β”€ Footer.jsx      # Footer component
    β”‚       β”œβ”€β”€ MainLayout.jsx  # Layout wrapper with Outlet
    β”‚       β”œβ”€β”€ Navbar.jsx      # Role-based navigation
    β”‚       └── index.js        # Barrel export
    β”‚
    β”œβ”€β”€ πŸ”„ context/
    β”‚   β”œβ”€β”€ AuthContext.jsx     # Authentication state
    β”‚   β”œβ”€β”€ ExamContext.jsx     # Exam state & timer
    β”‚   └── StudentContext.jsx  # Student data state
    β”‚
    β”œβ”€β”€ πŸ“Š data/
    β”‚   └── courseData.js       # Static course data
    β”‚
    β”œβ”€β”€ πŸ“„ Module/
    β”‚   β”œβ”€β”€ Exam.jsx            # Legacy exam component
    β”‚   └── home.jsx            # Legacy home component
    β”‚
    β”œβ”€β”€ πŸ“± pages/
    β”‚   β”œβ”€β”€ LandingPage.jsx     # Public landing page
    β”‚   β”œβ”€β”€ NotFoundPage.jsx    # 404 page
    β”‚   β”œβ”€β”€ index.js            # Barrel export
    β”‚   β”‚
    β”‚   β”œβ”€β”€ auth/
    β”‚   β”‚   β”œβ”€β”€ LoginPage.jsx   # Login with tabs
    β”‚   β”‚   β”œβ”€β”€ RegisterPage.jsx # Registration form
    β”‚   β”‚   └── index.js
    β”‚   β”‚
    β”‚   β”œβ”€β”€ exams/
    β”‚   β”‚   β”œβ”€β”€ ExamListPage.jsx    # Exam history
    β”‚   β”‚   β”œβ”€β”€ TakeExamPage.jsx    # Exam interface
    β”‚   β”‚   β”œβ”€β”€ ExamResultPage.jsx  # Result display
    β”‚   β”‚   └── index.js
    β”‚   β”‚
    β”‚   β”œβ”€β”€ instructor/
    β”‚   β”‚   β”œβ”€β”€ InstructorDashboard.jsx  # Instructor home
    β”‚   β”‚   β”œβ”€β”€ InstructorCoursesPage.jsx # Course management
    β”‚   β”‚   β”œβ”€β”€ InstructorStudentsPage.jsx # Student management
    β”‚   β”‚   β”œβ”€β”€ InstructorExamsPage.jsx   # Exam management
    β”‚   β”‚   └── index.js
    β”‚   β”‚
    β”‚   └── student/
    β”‚       β”œβ”€β”€ StudentDashboard.jsx  # Student home
    β”‚       β”œβ”€β”€ CoursesPage.jsx       # Course listing
    β”‚       β”œβ”€β”€ CourseDetailPage.jsx  # Course details
    β”‚       └── index.js
    β”‚
    β”œβ”€β”€ πŸ”Œ services/
    β”‚   β”œβ”€β”€ authService.js      # Auth API calls
    β”‚   β”œβ”€β”€ courseService.js    # Course API calls
    β”‚   β”œβ”€β”€ examService.js      # Exam API calls
    β”‚   └── studentService.js   # Student API calls
    β”‚
    └── πŸ”§ utils/
        β”œβ”€β”€ constants.js        # API endpoints & constants
        └── helpers.js          # Utility functions

πŸš€ Getting Started

Prerequisites

Installation

  1. Clone the repository
    git clone https://github.com/your-username/examination-system.git
    cd Front_sql_projrct
    
  2. Install dependencies
    npm install
    
  3. Configure environment (optional)

    Create a .env file for API configuration:

    VITE_API_BASE_URL=http://localhost:3000/api/v1
    
  4. Start the development server
    npm run dev
    
  5. Open in browser
    http://localhost:5173
    

βš™οΈ Environment Configuration

Variable Description Default
VITE_API_BASE_URL Backend API base URL http://localhost:3000/api/v1

πŸ“œ Available Scripts

Script Command Description
Dev npm run dev Start development server with HMR
Build npm run build Build for production
Preview npm run preview Preview production build
Lint npm run lint Run ESLint

πŸ›€οΈ Routes Structure

Public Routes

Route Component Description
/ LandingPage Public landing page
/login LoginPage User login (Student/Instructor tabs)
/register RegisterPage User registration

Student Routes (Protected)

Route Component Description
/student/dashboard StudentDashboard Student home page
/student/courses CoursesPage Browse courses
/student/courses/:id CourseDetailPage Course details
/student/exams ExamListPage Exam history
/student/exams/take/:courseId TakeExamPage Take new exam
/student/exams/:examId/retake TakeExamPage Resume pending exam
/student/exams/:examId/result ExamResultPage View exam results

Instructor Routes (Protected)

Route Component Description
/instructor/dashboard InstructorDashboard Instructor home
/instructor/courses InstructorCoursesPage Manage courses
/instructor/students InstructorStudentsPage Manage students
/instructor/exams InstructorExamsPage Manage exams

🧩 Components

Common Components

Component Props Description
Button variant, size, fullWidth, disabled Customizable button
Input label, error, icon, type Form input with validation
Card title, headerAction, padding, hoverable Content card
Modal isOpen, onClose, title, size Modal dialog
Badge variant, size Status badge
Loader size Loading spinner
EmptyState title, description, action Empty content state

Layout Components

Component Description
MainLayout Layout wrapper with Navbar and Footer
Navbar Role-based navigation menu
Footer Application footer
ProtectedRoute HOC for route protection

πŸ”„ State Management

Context Providers

AuthContext

// Available values and methods
const { 
  user,              // Current user object
  isAuthenticated,   // Auth status
  isLoading,         // Loading state
  login,             // Login function
  logout,            // Logout function
  register           // Register function
} = useAuth();

ExamContext

// Available values and methods
const {
  currentExam,       // Current exam data
  questions,         // Exam questions
  answers,           // Student answers
  timeRemaining,     // Timer in seconds
  flaggedQuestions,  // Flagged question IDs
  isSubmitting,      // Submission state
  generateExam,      // Start new exam
  resumeExamFromServer, // Resume pending exam
  selectAnswer,      // Select answer for question
  toggleFlag,        // Flag/unflag question
  submitExam,        // Submit exam
  resetExam          // Clear exam state
} = useExam();

πŸ”Œ API Integration

Services

Service Methods
authService loginStudent(), registerStudent(), loginInstructor()
courseService getAllCourses(), getCourseById(), createCourse()
examService generateExam(), submitExamAnswers(), getExamReview(), getStudentExams(), checkExamStatus()
studentService getAllStudents(), getStudentById(), assignTrack()

Axios Instance

The axios instance (src/api/axios.js) includes:


🎨 Styling

Tailwind CSS

This project uses Tailwind CSS 4.x with Vite integration:

// vite.config.js
import tailwindcss from '@tailwindcss/vite'

export default defineConfig({
  plugins: [react(), tailwindcss()]
})

Custom Animations

Custom animations are defined in App.css:

Color Palette

Color Usage Tailwind Class
Blue Primary actions bg-blue-600
Green Success states bg-green-500
Red Error/Danger bg-red-500
Amber Warning states bg-amber-500
Gray Neutral/Text bg-gray-100

πŸ” Authentication Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Landing    │────>β”‚   Login/    │────>β”‚  Dashboard  β”‚
β”‚   Page      β”‚     β”‚  Register   β”‚     β”‚ (by role)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚
                           β”‚ Auth Token
                           β–Ό
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    β”‚ localStorageβ”‚
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ“ Exam Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Generate   │────>β”‚  Take Exam  │────>β”‚   Submit    β”‚
β”‚    Exam     β”‚     β”‚  (15 min)   β”‚     β”‚   Answers   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                           β”‚                   β”‚
                    Timer Expires              β”‚
                           β”‚                   β–Ό
                           └──────────>β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                       β”‚   Results   β”‚
                                       β”‚    Page     β”‚
                                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🀝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

Code Style Guidelines


πŸ“š Additional Documentation


πŸ“„ License

This project is licensed under the ISC License.


πŸ‘¨β€πŸ’» Author

CrossITI Team


**⭐ Star this repository if you found it helpful!** Made with ❀️ using React and Vite