Introduction
The SkillRise API is a RESTful API that powers the SkillRise e-learning platform. It provides endpoints for course management, user enrollment, AI-powered learning assistance, community features, quiz generation, and payment processing. The API is built with Express.js and uses MongoDB for data persistence, with integrations for:- Clerk for authentication
- Razorpay for payment processing
- Cloudinary for media storage
- Groq SDK for AI features
Base URL
The API base URL varies by environment:/api followed by the resource category:
/api/course- Public course endpoints/api/user- User-specific endpoints (protected)/api/educator- Educator endpoints (role-protected)/api/admin- Admin endpoints (role-protected)/api/community- Community posts and groups/api/quiz- Quiz generation and submission
API Architecture
Route Structure
The SkillRise API follows a modular route structure organized by resource type:Middleware Stack
Every request passes through a middleware stack:- Helmet - Security headers
- CORS - Cross-origin resource sharing
- Clerk Middleware - Auth context injection
- Rate Limiters - Request throttling (route-specific)
- Express JSON - Request body parsing
Rate Limiting
The API implements intelligent rate limiting based on userId (when authenticated) or IP address (for guests):Applied to
/api/user/ai-chat - Generous limit for frequent chatbot usageApplied to
/api/user/purchase and /api/user/verify-razorpay - Tight limit to prevent fraudApplied to quiz generation and roadmap endpoints - Prevents API cost abuse
Applied to
/api/quiz/submit - Prevents brute-forcing quiz answersApplied to POST operations on
/api/community/posts and replies - Spam protectionApplied to
/api/admin/* - Extra safety layer for admin operationsRate limits track by
userId when authenticated, preventing limit bypass through IP switching.Response Format
All API responses follow a consistent JSON format:Success Response
Error Response
Common Status Codes
Request successful, data returned in response body
Invalid request data (validation failed)
Missing or invalid authentication token
User lacks required role/permissions for this endpoint
Resource not found
Request conflicts with current state (e.g., duplicate purchase)
Rate limit exceeded, includes
RateLimit-* headers for retry timingUnexpected server error occurred
Request Validation
The API uses Zod schemas for request body validation. Invalid requests receive a400 Bad Request response:
Data Models
The API works with the following core data models:Course
Courses with chapters, lectures, ratings, and enrollment dataUser
Student profiles with enrolled courses and progress trackingCourseProgress
Tracks completed lectures and course completion statusPurchase
Payment transactions (Razorpay integration)Certificate
Generated PDF certificates for completed coursesCommunityPost & Reply
Discussion posts with upvotes and answersQuiz & QuizResult
AI-generated quizzes with performance trackingChatSession
AI chatbot conversation historyError Handling
The API includes a global error handler that:- Logs full stack traces in development
- Logs error messages only in production (security)
- Returns standardized error responses
- Catches unhandled errors with
500status
Pagination
Currently, the API does not implement cursor-based pagination. Large collections return all results. Future versions may add pagination for:- Course listings
- Community posts
- Enrollment data
CORS Configuration
CORS is configured to accept requests from the frontend URL specified in environment variables:Webhooks
The API exposes webhook endpoints for external services:Clerk Webhooks
POST /clerk - Handles user lifecycle events (user.created, user.updated, user.deleted)
Razorpay Webhooks
POST /razorpay - Processes payment confirmation events (uses raw body parser)
Razorpay webhooks require raw body for signature verification, so they’re processed before the JSON body parser middleware.
Health Check
A simple health check endpoint is available:"API Working"
SDK & Client Libraries
Currently, no official SDKs are provided. The frontend client uses directfetch calls to the API endpoints.