Skip to content

πŸŽ“ Production-ready .NET 9 e-learning backend API with Clean Architecture, CQRS, JWT/2FA auth, Stripe payments, Cloudinary streaming, and Hangfire jobs.

License

Notifications You must be signed in to change notification settings

AhmedV20/Learnify

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Learnify Backend API

.NET 9.0 ASP.NET Core C# 13 License: MIT

Backend CI EF Core 9 SQL Server Redis Stripe Cloudinary

Features β€’ Tech Stack β€’ Getting Started β€’ API Docs β€’ Architecture β€’ Repository


πŸ“ Description

Learnify API is a comprehensive, production-ready backend solution for building modern e-learning platforms. Built with .NET 9 and following Clean Architecture principles, it provides a robust, scalable, and maintainable foundation for online education systems.

This API powers a complete learning management system with features including:

  • Multi-tenant user management with role-based access control (Admin, Instructor, Student)
  • Complete course lifecycle from creation to certification
  • Dual payment processing via Stripe and manual payment workflows with admin approval
  • Advanced security with JWT authentication, refresh tokens, 2FA (Email, Authenticator App, Backup Codes), and Google OAuth
  • Real-time video streaming and progress tracking with resume functionality
  • AI-powered learning assistance via HuggingFace integration
  • Enterprise-grade observability with structured logging, health checks, and performance monitoring

Whether you're building a corporate training platform, an online academy, or a MOOC system, Learnify provides the battle-tested backend infrastructure you need.


πŸ“– Overview

Learnify is designed as a scalable e-learning platform backend that handles everything from user authentication to payment processing and course delivery. The system is built around these core modules:

πŸ” Authentication & Security

  • JWT-based authentication with configurable token expiry and automatic refresh token rotation
  • OTP email verification for account activation and password reset flows
  • Two-factor authentication supporting Email codes, Authenticator apps (TOTP), and Backup recovery codes
  • Google OAuth integration for seamless social login
  • Rate limiting on sensitive endpoints (login, payments, file uploads)
  • Role-based authorization with granular permission control

πŸ“š Learning Management

  • Hierarchical course structure: Courses β†’ Sections β†’ Lectures
  • Video content delivery via Cloudinary with adaptive streaming
  • Lecture progress tracking with resume playback functionality
  • Course ratings and reviews with moderation capabilities
  • Course bookmarking for students' learning lists
  • Category-based course organization with slug-based URLs
  • Certificate generation upon course completion

πŸ’³ Payment Processing

  • Stripe integration for seamless card payments with checkout sessions
  • Manual payment system with proof upload and admin approval workflow
  • Shopping cart functionality for multi-course purchases
  • Coupon and discount system with usage tracking
  • Instructor payout system with Stripe Connect integration
  • Invoice generation for completed transactions

πŸ“Š Analytics & Reporting

  • Instructor dashboard with enrollment analytics and revenue tracking
  • Course performance metrics including completion rates and ratings
  • Admin reports with platform-wide statistics
  • Monthly trend analysis for business insights

βš™οΈ Enterprise Features

  • Serilog structured logging with Console, File, and Seq sinks
  • Hangfire background jobs for email sending, cleanup tasks, and scheduled operations
  • Health checks for Database, Redis, Stripe, Cloudinary, and Email services
  • API versioning for backward compatibility
  • CQRS pattern with MediatR for clean command/query separation

✨ Features

πŸŽ“ Learning Management System

Feature Description
Course Creation Full course builder with sections, lectures, and video uploads
Video Streaming Cloudinary-powered video delivery with adaptive bitrate
Progress Tracking Lecture-level progress with resume playback position
Certificates Automatic certificate generation upon completion
Ratings & Reviews 5-star rating system with written reviews
Bookmarks Save courses to personal learning lists
Category System Organize courses with hierarchical categories
Search & Filter Advanced course discovery with pagination

πŸ‘₯ User Management

Feature Description
Multi-role System Admin, Instructor, and Student roles with distinct permissions
Profile Management User profiles with avatar upload and personal info
JWT Authentication Secure token-based auth with refresh token rotation
Two-Factor Auth Email, Authenticator App, and Backup Codes support
Google OAuth One-click social login integration
Email Verification OTP-based email verification flow
Password Recovery Secure password reset with expiring tokens
Account Banning Admin ability to ban/unban users

πŸ’° Payment & Commerce

Feature Description
Stripe Payments Full Stripe integration with checkout sessions
Manual Payments Alternative payment with proof upload
Payment Approval Admin workflow for manual payment verification
Shopping Cart Multi-item cart with real-time totals
Coupon System Discount codes with usage limits and expiry
Instructor Payouts Stripe Connect for instructor withdrawals
Invoice Generation Detailed invoices for all transactions
Refund Handling Admin-managed refund processing

πŸ‘¨β€πŸ« Instructor Tools

Feature Description
Course Analytics Detailed enrollment and revenue statistics
Student Management View enrolled students and their progress
Payout Management Request and track earnings withdrawals
Stripe Connect Full onboarding for direct bank payouts
Revenue Dashboard Real-time earnings and trend analysis

πŸ›‘οΈ Admin Dashboard

Feature Description
User Management View, ban, and manage all platform users
Course Moderation Approve, reject, and manage course publications
Payment Oversight Review and process manual payments
Platform Analytics Overall statistics and growth metrics
Payment Settings Enable/disable payment methods dynamically
Withdrawal Approvals Process instructor withdrawal requests

πŸ€– AI Features

Feature Description
AI Chat Assistant HuggingFace-powered learning assistant
Smart Recommendations Course suggestions based on interests

πŸ”§ Enterprise & Operations

Feature Description
Structured Logging Serilog with Console, File, and Seq sinks
Background Jobs Hangfire for async task processing
Health Monitoring Comprehensive health check endpoints
Rate Limiting Protection against abuse and DDoS
API Versioning Backward-compatible API evolution
Email Templates Branded HTML email notifications
Performance Logging Request timing and slow query detection

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                           LEARNIFY BACKEND API                              β”‚
β”‚                          Clean Architecture Design                          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚                    🌐 Presentation Layer (API)                        β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
β”‚  β”‚  β”‚ Controllers β”‚ β”‚ Middleware  β”‚ β”‚ Rate Limit  β”‚ β”‚ Health Checks   β”‚  β”‚  β”‚
β”‚  β”‚  β”‚   (25)      β”‚ β”‚ Exception   β”‚ β”‚ Policies    β”‚ β”‚ DB/Redis/Stripe β”‚  β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
β”‚  β”‚  REST API (v1) β€’ Scalar API Docs β€’ JWT Auth β€’ API Versioning          β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                      β”‚                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚                  πŸ“‹ Application Layer (CQRS)                          β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
β”‚  β”‚  β”‚  Commands   β”‚ β”‚   Queries   β”‚ β”‚    DTOs     β”‚ β”‚   Validators    β”‚  β”‚  β”‚
β”‚  β”‚  β”‚ CreateUser  β”‚ β”‚ GetCourses  β”‚ β”‚  Requests   β”‚ β”‚ FluentValidationβ”‚  β”‚  β”‚
β”‚  β”‚  β”‚ EnrollUser  β”‚ β”‚ GetPayments β”‚ β”‚  Responses  β”‚ β”‚ Business Rules  β”‚  β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
β”‚  β”‚  MediatR Handlers β€’ AutoMapper Profiles β€’ Pipeline Behaviors         β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                      β”‚                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚                  πŸ›οΈ Domain Layer (Core)                               β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
β”‚  β”‚  β”‚                      Entities (23 Total)                        β”‚  β”‚  β”‚
β”‚  β”‚  β”‚  ApplicationUser β€’ Course β€’ Section β€’ Lecture β€’ Enrollment      β”‚  β”‚  β”‚
β”‚  β”‚  β”‚  Payment β€’ Cart β€’ CartItem β€’ Category β€’ Coupon β€’ Invoice        β”‚  β”‚  β”‚
β”‚  β”‚  β”‚  LectureProgress β€’ CourseRating β€’ UserBookmark β€’ InstructorPayoutβ”‚ β”‚  β”‚
β”‚  β”‚  β”‚  ManualPaymentRequest β€’ ManualPaymentMethod β€’ SystemSetting     β”‚  β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
β”‚  β”‚  Enums β€’ Value Objects β€’ Domain Events                                β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                      β”‚                                      β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚               πŸ”Œ Infrastructure Layer (External Concerns)             β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
β”‚  β”‚  β”‚ EF Core 9   β”‚ β”‚Repositories β”‚ β”‚  Services   β”‚ β”‚  Background     β”‚  β”‚  β”‚
β”‚  β”‚  β”‚ DbContext   β”‚ β”‚ Generic +   β”‚ β”‚ Cloudinary  β”‚ β”‚  Hangfire Jobs  β”‚  β”‚  β”‚
β”‚  β”‚  β”‚ Migrations  β”‚ β”‚ Specialized β”‚ β”‚ Stripe API  β”‚ β”‚  Email Queue    β”‚  β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
β”‚  β”‚  Identity β€’ JWT Service β€’ Email Service β€’ TOTP Service               β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                                                             β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                         πŸ”— External Services                                β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”‚
β”‚  β”‚SQL Serverβ”‚ β”‚  Redis   β”‚ β”‚Cloudinaryβ”‚ β”‚  Stripe  β”‚ β”‚HuggingFaceβ”‚         β”‚
β”‚  β”‚  (Data)  β”‚ β”‚ (Cache)  β”‚ β”‚ (Media)  β”‚ β”‚(Payments)β”‚ β”‚   (AI)    β”‚         β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                   β”‚
β”‚  β”‚   Seq    β”‚ β”‚  Gmail   β”‚ β”‚  Google  β”‚                                   β”‚
β”‚  β”‚(Logging) β”‚ β”‚  (SMTP)  β”‚ β”‚  OAuth   β”‚                                   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Architectural Patterns

Pattern Implementation
Clean Architecture 4-layer separation: API β†’ Application β†’ Domain β†’ Infrastructure
CQRS Commands and Queries separated via MediatR handlers
Repository Pattern Generic and specialized repositories for data access
Unit of Work EF Core DbContext manages transaction boundaries
Dependency Injection Microsoft.Extensions.DependencyInjection throughout
Options Pattern Strongly-typed configuration binding
Middleware Pipeline Request/response pipeline for cross-cutting concerns

πŸ› οΈ Tech Stack

Core Framework

Technology Version Purpose
.NET 9.0 Runtime and SDK
ASP.NET Core 9.0 Web framework
C# 13.0 Programming language
Entity Framework Core 9.0 ORM and migrations

Database & Caching

Technology Purpose
SQL Server Primary relational database
Redis Distributed caching
ASP.NET Core Identity User and role management

API & Documentation

Technology Purpose
Scalar Modern API documentation UI
Asp.Versioning API version management
FluentValidation Request validation
AutoMapper Object-to-object mapping

Background Processing & Logging

Technology Purpose
Hangfire Background job scheduling
Serilog Structured logging
Seq Log aggregation and search

External Services

Service Purpose
Stripe Payment processing & Connect payouts
Cloudinary Video/image hosting and streaming
HuggingFace AI chat assistance
Google OAuth Social authentication
Gmail SMTP Email notifications

Application Patterns

Library Purpose
MediatR CQRS and pipeline behaviors
FluentValidation Input validation rules
AutoMapper DTO mapping automation

πŸš€ Getting Started

Prerequisites

  • .NET 9.0 SDK - Download
  • SQL Server (or LocalDB for development)
  • Redis (optional, for distributed caching)
  • Stripe Account - Sign up
  • Cloudinary Account - Sign up

1. Clone & Install

git clone https://github.com/AhmedV20/Learnify.git
cd Learnify/src/Learnify.Api
dotnet restore

2. Configure

Create appsettings.Development.json with the following essential settings:

{
  "ConnectionStrings": {
    "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=LearnifyDb;Trusted_Connection=True;TrustServerCertificate=True;",
    "Redis": "localhost:6379"
  },
  "JWT": {
    "ValidAudience": "Learnify_Users",
    "ValidIssuer": "Learnify_Api",
    "Secret": "YOUR_JWT_SECRET_KEY_MINIMUM_64_CHARACTERS_FOR_SECURITY",
    "TokenExpiryHours": 168
  },
  "Stripe": {
    "SecretKey": "sk_test_YOUR_STRIPE_SECRET_KEY",
    "PublishableKey": "pk_test_YOUR_STRIPE_PUBLISHABLE_KEY",
    "WebhookSecret": "whsec_YOUR_WEBHOOK_SECRET"
  },
  "Cloudinary": {
    "CloudName": "YOUR_CLOUD_NAME",
    "ApiKey": "YOUR_API_KEY",
    "ApiSecret": "YOUR_API_SECRET"
  },
  "Email": {
    "SmtpServer": "smtp.gmail.com",
    "SmtpPort": 587,
    "SenderEmail": "your-email@gmail.com",
    "SenderName": "Learnify",
    "SenderPassword": "YOUR_EMAIL_APP_PASSWORD"
  },
  "Google": {
    "ClientId": "YOUR_GOOGLE_CLIENT_ID.apps.googleusercontent.com"
  },
  "HuggingFace:ApiKey": "YOUR_HUGGINGFACE_API_KEY",
  "App": {
    "BaseUrl": "http://localhost:5279"
  }
}

Note: For Gmail, use an App Password instead of your regular password.

3. Run Database Migrations

dotnet ef database update --project ../Learnify.Infrastructure

4. Start the API

dotnet run

5. Access the Application

Endpoint URL Description
API Base http://localhost:5279 REST API endpoint
Scalar API Docs http://localhost:5279/scalar/v1 Interactive documentation
Hangfire Dashboard http://localhost:5279/hangfire Background jobs monitor
Health Check http://localhost:5279/health System health status
Health Check (Detailed) http://localhost:5279/health/details Detailed health report

πŸ“š API Documentation

Interactive API documentation is available at /scalar/v1 when the application is running. Below are the key endpoint groups. For a complete list, see the live Scalar documentation.

Note: The API has 25 controllers with 100+ endpoints. Only the most important ones are shown below.

πŸ” Authentication (/api/v1/users)

Method Endpoint Description Auth
POST /register Register a new user account ❌
POST /login Authenticate and receive JWT tokens ❌
POST /verify-2fa Verify 2FA code during login ❌
POST /google-login Sign in with Google OAuth ❌
POST /verify-otp Verify email with OTP ❌
POST /forgot-password Request password reset OTP ❌
POST /set-new-password Set new password with reset token ❌
GET /profile Get current user profile βœ…
PUT /profile Update user profile βœ…

πŸ“š Courses (/api/v1/courses)

Method Endpoint Description Auth
GET / List all courses (paginated) ❌
GET /{id} Get course details ❌
GET /{id}/learn Get course with full content βœ…
POST / Create new course βœ… Admin
PUT /{id} Update course βœ…
DELETE /{id} Delete course βœ…
GET /category Get courses by category ❌

πŸ“ Enrollments (/api/v1/enrollments)

Method Endpoint Description Auth
GET /user Get current user's enrollments βœ…
GET /check/{courseId} Check enrollment status βœ…
POST / Create enrollment βœ…
DELETE /{id} Delete enrollment βœ…

πŸ’³ Payments (/api/v1/payments)

Method Endpoint Description Auth
GET /settings Get payment settings βœ…
POST /checkout-session Create Stripe checkout βœ…
POST /verify-payment/{sessionId} Verify and process payment βœ…
GET /my-payments Get user's payment history βœ…

πŸ‘¨β€πŸ« Instructor (/api/v1/instructor)

Method Endpoint Description Auth
GET /balance Get earnings balance βœ…
GET /payouts Get payout history βœ…
POST /request-withdrawal Request funds withdrawal βœ…
POST /create-stripe-account Setup Stripe Connect βœ…
GET /stripe-connect-status Get Stripe account status βœ…

πŸ›‘οΈ Admin (/api/v1/admin)

Method Endpoint Description Auth
GET /dashboard-stats Get platform statistics βœ… Admin
GET /users List all users βœ… Admin
PATCH /users/{id}/ban Ban user βœ… Admin
GET /courses List all courses (admin) βœ… Admin
PATCH /courses/{id}/approve Approve course βœ… Admin
GET /withdrawal-requests List withdrawal requests βœ… Admin
PUT /withdrawal-requests/{id}/approve Approve withdrawal βœ… Admin

πŸ“Š Additional Endpoints

The API also includes endpoints for:

  • Two-Factor Auth - Email, Authenticator App, Backup Codes setup
  • Sections & Lectures - Course content management with video upload
  • Lecture Progress - Track watch position and completion
  • Shopping Cart - Add/remove courses from cart
  • Manual Payments - Alternative payment with proof upload
  • Course Ratings - Reviews and ratings system
  • Categories - Course organization
  • Bookmarks - Save courses for later
  • Coupons - Discount codes
  • Analytics - Instructor revenue and enrollment stats
  • AI Chat - HuggingFace-powered learning assistant
  • Health Checks - System monitoring

πŸ“ Project Structure

src/
β”œβ”€β”€ Learnify.Api/                     # 🌐 Presentation Layer
β”‚   β”œβ”€β”€ Controllers/                  # 25 REST API controllers
β”‚   β”‚   β”œβ”€β”€ UsersController.cs        # Authentication & profile
β”‚   β”‚   β”œβ”€β”€ CoursesController.cs      # Course management
β”‚   β”‚   β”œβ”€β”€ PaymentsController.cs     # Payment processing
β”‚   β”‚   β”œβ”€β”€ AdminController.cs        # Admin operations
β”‚   β”‚   └── ...                       # + 21 more controllers
β”‚   β”œβ”€β”€ Extensions/                   # DI & service configuration
β”‚   β”œβ”€β”€ Health/                       # Health check implementations
β”‚   β”œβ”€β”€ Middleware/                   # Exception handling, logging
β”‚   └── RateLimiting/                 # Rate limit policies
β”‚
β”œβ”€β”€ Learnify.Application/             # πŸ“‹ Business Logic Layer
β”‚   β”œβ”€β”€ Users/                        # Auth commands & queries
β”‚   β”œβ”€β”€ Courses/                      # Course CQRS operations
β”‚   β”œβ”€β”€ Enrollments/                  # Enrollment logic
β”‚   β”œβ”€β”€ Payments/                     # Payment processing
β”‚   β”œβ”€β”€ Common/                       # Interfaces, pagination, behaviors
β”‚   β”œβ”€β”€ Mappings/                     # AutoMapper profiles
β”‚   └── ...                           # + 15 more feature modules
β”‚
β”œβ”€β”€ Learnify.Domain/                  # πŸ›οΈ Core Domain
β”‚   β”œβ”€β”€ Entities/                     # 23 domain entities
β”‚   β”‚   β”œβ”€β”€ ApplicationUser.cs        # Extended Identity user
β”‚   β”‚   β”œβ”€β”€ Course.cs                 # Course aggregate root
β”‚   β”‚   β”œβ”€β”€ Enrollment.cs             # Student enrollments
β”‚   β”‚   β”œβ”€β”€ Payment.cs                # Payment records
β”‚   β”‚   └── ...                       # + 19 more entities
β”‚   └── Enums/                        # Domain enumerations
β”‚
└── Learnify.Infrastructure/          # πŸ”Œ External Concerns
    β”œβ”€β”€ Data/                         # EF Core DbContext & migrations
    β”œβ”€β”€ Repositories/                 # Data access implementations
    β”œβ”€β”€ Services/                     # Cloudinary, Stripe, Email
    β”œβ”€β”€ BackgroundJobs/               # Hangfire job implementations
    └── Seed/                         # Database seeding

Note: For detailed file listings, browse the repository on GitHub.


🀝 Contributing

We welcome contributions! Here's how to get started:

  1. Fork the repository
  2. Clone your fork: git clone https://github.com/YOUR_USERNAME/Learnify.git
  3. Create a feature branch: git checkout -b feature/amazing-feature
  4. Make your changes and ensure the project builds
  5. Commit using Conventional Commits: git commit -m 'feat: add amazing feature'
  6. Push to your branch: git push origin feature/amazing-feature
  7. Open a Pull Request against the develop branch

Guidelines

See CONTRIBUTING.md for detailed guidelines and docs/GIT_WORKFLOW.md for branching strategy.


πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


Built with ❀️ using .NET 9

⬆ Back to Top

About

πŸŽ“ Production-ready .NET 9 e-learning backend API with Clean Architecture, CQRS, JWT/2FA auth, Stripe payments, Cloudinary streaming, and Hangfire jobs.

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks