A modern React-based frontend application for generating and managing AI-powered coding challenges. Built with Vite, React Router, and Clerk authentication for a seamless user experience.
- Modern React UI: Built with React 19 and modern hooks
 - Secure Authentication: Seamless user authentication via Clerk with protected routes
 - Challenge Generation: Interactive interface for generating coding challenges at different difficulty levels
 - Real-time Quota Display: Shows remaining daily challenges and reset information
 - Challenge History: View and review previously generated challenges
 - Responsive Design: Clean, accessible interface that works across devices
 - Interactive MCQ Interface: Click-to-answer multiple choice questions with immediate feedback
 
- Frontend: React 19, Vite
 - Routing: React Router DOM v6
 - Authentication: Clerk React SDK
 - Styling: CSS3 with custom properties
 - Build Tool: Vite with HMR
 - Code Quality: ESLint with React-specific rules
 
frontend/
βββ public/                   # Static assets
βββ src/
β   βββ App.jsx              # Main application component
β   βββ App.css              # Global styles and CSS variables
β   βββ index.css            # Base styles and resets
β   βββ main.jsx             # Application entry point
β   βββ auth/
β   β   βββ AuthenticationPage.jsx    # Sign-in/Sign-up page
β   β   βββ ClerkProviderWithRoutes.jsx # Clerk provider setup
β   βββ challenge/
β   β   βββ ChallengeGenerator.jsx    # Main challenge generation interface
β   β   βββ MCQChallenge.jsx          # Multiple choice question component
β   βββ history/
β   β   βββ HistoryPanel.jsx          # Challenge history display
β   βββ layout/
β   β   βββ Layout.jsx               # App layout with header and navigation
β   βββ utils/
β       βββ api.js                   # API utilities and request handling
βββ index.html               # HTML template
βββ package.json            # Dependencies and scripts
βββ vite.config.js          # Vite configuration
βββ eslint.config.js        # ESLint configuration
βββ .env                    # Environment variables (not tracked)
Create a .env file in the root directory with the following variables:
VITE_CLERK_PUBLISHABLE_KEY=your_clerk_publishable_key- 
Clone the repository
git clone https://github.com/asheint/ai-challenge-generator-app.git cd ai-challenge-generator-app - 
Install dependencies
npm install
 - 
Set up environment variables
- Create a 
.envfile in the root directory - Add your Clerk publishable key as shown above
 
 - Create a 
 - 
Run the development server
npm run dev
 
The application will start on http://localhost:5173.
This frontend works with the AI Challenge Generator backend:
- Repository: https://github.com/asheint/ai-challenge-generator-app-backend
 - Backend handles AI generation, authentication, and data persistence
 
- Wraps the application with Clerk authentication
 - Configures routing for the entire app
 - Validates Clerk publishable key
 
- Handles both sign-in and sign-up flows
 - Uses Clerk's built-in components
 - Redirects authenticated users
 
- Main interface for generating new challenges
 - Difficulty selector (Easy/Medium/Hard)
 - Real-time quota display with reset information
 - Error handling and loading states
 - Integrates with 
useApihook 
- Interactive multiple choice question display
 - Click-to-answer functionality
 - Visual feedback for correct/incorrect answers
 - Conditional explanation display
 - Handles both string and parsed JSON options
 
- Displays user's challenge history
 - Loading and error states
 - Retry functionality for failed requests
 - Uses 
MCQChallengecomponent with explanations shown 
- App header with navigation
 - User button for account management
 - Protected route wrapper
 - Responsive navigation menu
 
- Custom hook for authenticated API requests
 - Automatic token injection using Clerk
 - Error handling for common scenarios (401, 429)
 - Configures requests to backend at 
localhost:8000 
The application uses a comprehensive CSS custom property system defined in App.css:
:root {
  --primary-color: #2563eb;
  --error-color: #dc2626;
  --text-color: #1f2937;
  --bg-color: #f3f4f6;
  --border-color: #e5e7eb;
}- Responsive Design: Mobile-first approach with flexible layouts
 - Accessible Focus States: Keyboard navigation support
 - Interactive Feedback: Hover and click states for all interactive elements
 - Loading States: Visual feedback during async operations
 - Error Handling: Styled error messages with retry options
 
The application implements route protection using Clerk:
- Public Routes: 
/sign-in,/sign-up - Protected Routes: 
/(ChallengeGenerator),/history(HistoryPanel) - Automatic Redirects: Unauthenticated users redirected to sign-in
 
- Select difficulty level (Easy, Medium, Hard)
 - Real-time quota tracking
 - Instant challenge generation
 - Visual feedback for selections
 
- Click-to-answer multiple choice
 - Immediate visual feedback
 - Detailed explanations after answering
 - Support for both new and historical challenges
 
- Seamless sign-in/sign-up flow
 - User profile management via Clerk
 - Session persistence
 - Secure token handling
 
- Complete challenge history
 - Review previous questions and answers
 - Explanations always visible in history
 - Chronological organization
 
# Start development server
npm run dev
# Build for production
npm run build
# Run ESLint
npm run lint
# Preview production build
npm run preview- React 19.1.0: Modern React with latest features
 - React Router DOM 6.30.1: Client-side routing
 - @clerk/clerk-react 5.32.0: Authentication integration
 
- Vite 6.3.5: Fast build tool and dev server
 - @vitejs/plugin-react 4.4.1: React plugin for Vite
 - ESLint 9.25.0: Code linting and quality
 - eslint-plugin-react-hooks: React hooks linting rules
 
vite.config.js includes:
- React plugin for JSX support
 - Hot Module Replacement (HMR)
 - Fast development server
 
eslint.config.js provides:
- React-specific linting rules
 - Modern JavaScript standards
 - React hooks validation
 - Import/export validation
 
The frontend communicates with the backend through standardized endpoints:
- POST 
/api/generate-challenge- Generate new challenge - GET 
/api/my-history- Fetch user history - GET 
/api/quota- Check remaining quota 
All requests include:
- Automatic authentication via Clerk tokens
 - Proper error handling and user feedback
 - Loading states for better UX
 
npm run build- Optimized bundles: Tree-shaking and minification
 - Asset optimization: Image and font optimization
 - Modern browser targets: ES2020+ support
 - Source maps: For debugging in production
 
If you found this project helpful, please star the repository!
Support the development of this project:
This project is open source and available under the MIT License.
Contributions are welcome! Please feel free to submit a Pull Request.
Related Projects:
- Backend Repository - FastAPI backend for this application