Features β’ Tech Stack β’ Getting Started β’ API Docs β’ Architecture β’ Repository
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.
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:
- 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
- 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
- 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
- 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
- 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
| 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 |
| 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 |
| 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 |
| 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 |
| 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 |
| Feature | Description |
|---|---|
| AI Chat Assistant | HuggingFace-powered learning assistant |
| Smart Recommendations | Course suggestions based on interests |
| 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 |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β 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 β β
β ββββββββββββ ββββββββββββ ββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
| 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 |
| 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 |
| Technology | Purpose |
|---|---|
| SQL Server | Primary relational database |
| Redis | Distributed caching |
| ASP.NET Core Identity | User and role management |
| Technology | Purpose |
|---|---|
| Scalar | Modern API documentation UI |
| Asp.Versioning | API version management |
| FluentValidation | Request validation |
| AutoMapper | Object-to-object mapping |
| Technology | Purpose |
|---|---|
| Hangfire | Background job scheduling |
| Serilog | Structured logging |
| Seq | Log aggregation and search |
| 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 |
| Library | Purpose |
|---|---|
| MediatR | CQRS and pipeline behaviors |
| FluentValidation | Input validation rules |
| AutoMapper | DTO mapping automation |
- .NET 9.0 SDK - Download
- SQL Server (or LocalDB for development)
- Redis (optional, for distributed caching)
- Stripe Account - Sign up
- Cloudinary Account - Sign up
git clone https://github.com/AhmedV20/Learnify.git
cd Learnify/src/Learnify.Api
dotnet restoreCreate 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.
dotnet ef database update --project ../Learnify.Infrastructuredotnet run| 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 |
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.
| 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 | β |
| 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 | β |
| Method | Endpoint | Description | Auth |
|---|---|---|---|
GET |
/user |
Get current user's enrollments | β |
GET |
/check/{courseId} |
Check enrollment status | β |
POST |
/ |
Create enrollment | β |
DELETE |
/{id} |
Delete enrollment | β |
| 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 | β |
| 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 | β |
| 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 |
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
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.
We welcome contributions! Here's how to get started:
- Fork the repository
- Clone your fork:
git clone https://github.com/YOUR_USERNAME/Learnify.git - Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and ensure the project builds
- Commit using Conventional Commits:
git commit -m 'feat: add amazing feature' - Push to your branch:
git push origin feature/amazing-feature - Open a Pull Request against the
developbranch
- Follow Microsoft's C# Coding Conventions
- Write meaningful commit messages
- Add/update tests for new features
- Update documentation as needed
See CONTRIBUTING.md for detailed guidelines and docs/GIT_WORKFLOW.md for branching strategy.
This project is licensed under the MIT License - see the LICENSE file for details.
Built with β€οΈ using .NET 9