Documentation Index
Fetch the complete documentation index at: https://mintlify.com/pv-pushkarverma/SkillRise/llms.txt
Use this file to discover all available pages before exploring further.
Overview
The SkillRise API uses Clerk for authentication and authorization. Clerk provides secure session management with JWT tokens that include user identity and role-based metadata.Authentication Flow
Clerk Issues Token
Clerk generates a JWT session token containing:
userId- Unique user identifiersessionClaims.metadata.role- User role (student, educator, admin)
Frontend Includes Token
Frontend includes the Clerk session token in API requests (handled automatically by Clerk SDK)
Clerk Middleware
The API uses@clerk/express middleware globally:
- Validates Clerk session tokens
- Populates
req.authwith authentication context - Allows both authenticated and unauthenticated requests
Auth Context (req.auth)
On authenticated requests, req.auth contains:
Clerk user ID (used as MongoDB
_id for User documents)Clerk session claims object
User role:
"student", "educator", or "admin"Protected Routes
User Authentication
User-specific endpoints require authentication via Clerk’srequireAuth() middleware:
/api/user/* are protected:
/api/user/data- Get user profile/api/user/enrolled-courses- Get enrolled courses/api/user/purchase- Purchase course/api/user/ai-chat- AI chatbot- And more…
401 Unauthorized
Role-Based Access Control
SkillRise implements three user roles with distinct permissions:Student (Default)
All authenticated users have student access by default. Students can:- Browse and purchase courses
- Track progress and earn certificates
- Use AI chat assistant
- Participate in community discussions
- Take quizzes
Educator
Educators can create and manage courses. Educator routes use custom middleware:POST /api/educator/add-course- Create new courseGET /api/educator/courses- List educator’s coursesGET /api/educator/dashboard- Dashboard analyticsGET /api/educator/enrolled-students- Student enrollment dataPOST /api/quiz/generate- Generate AI quizGET /api/quiz/educator-insights- Quiz performance insights
403 Forbidden
Admin
Admins have full platform access. Admin routes use custom middleware:GET /api/admin/stats- Platform statisticsGET /api/admin/chart-data- Analytics chartsGET /api/admin/courses- All coursesGET /api/admin/purchases- All purchasesGET /api/admin/users- User managementGET /api/admin/educator-applications- Educator applicationsPATCH /api/admin/educator-applications/:id/approve- Approve educatorPATCH /api/admin/educator-applications/:id/reject- Reject educator
403 Forbidden
Becoming an Educator
Users can apply to become educators through the application system:
Check Application Status:
Public Endpoints
Some endpoints are publicly accessible without authentication:List all published courses
Get course details (lecture URLs hidden for non-free content)
Verify certificate authenticity via QR code
List community groups (membership requires auth)
Browse community posts (voting/posting requires auth)
Webhooks Authentication
Clerk Webhooks
Clerk webhooks use Svix signature verification:Razorpay Webhooks
Razorpay webhooks use HMAC signature verification:Example: Making Authenticated Requests
Frontend (with Clerk React)
@clerk/clerk-react hooks.
Direct API Call (with token)
Security Best Practices
Rate limiting is tied to
userId when authenticated, preventing users from bypassing limits by switching IP addresses.Token Validation
- Tokens are validated on every request via Clerk middleware
- Expired tokens receive
401 Unauthorized - Role changes take effect immediately (no token refresh needed)
CORS Protection
API accepts requests only from configured frontend origin:Troubleshooting
401 Unauthorized
Missing Authorization Header
Missing Authorization Header
Expired Session
Expired Session
User needs to re-authenticate. Clerk SDK handles this automatically.
Invalid Token
Invalid Token
Token may be malformed or from wrong Clerk instance. Verify
CLERK_PUBLISHABLE_KEY matches backend.403 Forbidden
Insufficient Role
Insufficient Role
User lacks required role (educator/admin) for this endpoint. Check
req.auth.sessionClaims.metadata.role.Course Not Purchased
Course Not Purchased
User attempting to access enrolled course content without purchasing. Verify enrollment via
/api/user/enrolled-courses.Next Steps
API Overview
Learn about API structure and response formats
Endpoints
Browse all available API endpoints