A modern, full-stack learning platform built with React, TypeScript, Node.js, and MongoDB. Features user authentication, subscription management with Stripe, and a comprehensive lesson system with premium content support.
- User Authentication: Secure JWT-based authentication with refresh tokens
- Subscription Management: Stripe integration for premium subscriptions
- Lesson System: Comprehensive lesson management with categories and tags
- Premium Content: Protected premium lessons for subscribers
- Responsive Design: Modern, mobile-first UI built with Tailwind CSS
- Real-time Updates: React Query for efficient data fetching and caching
- User registration and login
- Profile management
- Subscription management (upgrade, cancel, billing portal)
- Browse and search lessons
- Filter lessons by category and premium status
- Watch video lessons with premium content protection
- Responsive design for all devices
- Lesson management (CRUD operations)
- User management
- Subscription monitoring
- Content categorization
- React 18 with TypeScript
- React Router for navigation
- React Query for state management
- React Hook Form with Yup validation
- Tailwind CSS for styling
- Lucide React for icons
- React Hot Toast for notifications
- Axios for API communication
- Node.js with TypeScript
- Express.js framework
- MongoDB with Mongoose ODM
- JWT for authentication
- Stripe for payment processing
- bcryptjs for password hashing
- Express Rate Limit for API protection
- Helmet for security headers
- Node.js (v18 or higher)
- MongoDB (local or cloud)
- Stripe account (for payments)
-
Clone the repository
git clone <repository-url> cd Subscription
-
Install dependencies
cd backend npm install -
Environment Configuration
cp env.example .env
Update the
.envfile with your configuration:PORT=5000 NODE_ENV=development MONGODB_URI=mongodb://localhost:27017/learnly JWT_SECRET=your_jwt_secret_key_here JWT_REFRESH_SECRET=your_jwt_refresh_secret_key_here STRIPE_SECRET_KEY=sk_test_your_stripe_secret_key STRIPE_WEBHOOK_SECRET=whsec_your_stripe_webhook_secret CLIENT_URL=http://localhost:3000
-
Start the development server
npm run dev
-
Install dependencies
cd frontend npm install -
Environment Configuration Create a
.envfile in the frontend directory:VITE_API_URL=http://localhost:5000/api VITE_STRIPE_PUBLISHABLE_KEY=pk_test_your_stripe_publishable_key VITE_APP_NAME=Learnly
-
Start the development server
npm run dev
{
email: string;
password: string;
firstName: string;
lastName: string;
role: 'user' | 'admin';
subscription?: {
status: 'active' | 'inactive' | 'cancelled';
stripeCustomerId?: string;
stripeSubscriptionId?: string;
currentPeriodEnd?: Date;
};
refreshTokens: string[];
}{
title: string;
description: string;
content: string;
videoUrl?: string;
thumbnailUrl?: string;
duration: number; // in minutes
category: string;
tags: string[];
isPremium: boolean;
author: string;
order: number;
}POST /api/auth/register- User registrationPOST /api/auth/login- User loginPOST /api/auth/refresh- Refresh JWT tokenPOST /api/auth/logout- User logoutGET /api/auth/profile- Get user profile
GET /api/lessons- Get all lessons (with pagination and filters)GET /api/lessons/:id- Get lesson by IDGET /api/lessons/search- Search lessonsGET /api/lessons/category/:category- Get lessons by categoryPOST /api/lessons- Create lesson (admin only)PUT /api/lessons/:id- Update lesson (admin only)DELETE /api/lessons/:id- Delete lesson (admin only)
POST /api/subscriptions/checkout- Create Stripe checkout sessionPOST /api/subscriptions/billing-portal- Create billing portal sessionGET /api/subscriptions/status- Get subscription statusPOST /api/subscriptions/cancel- Cancel subscriptionPOST /api/subscriptions/webhook- Stripe webhook handler
- JWT-based authentication with refresh tokens
- Password hashing with bcrypt
- Rate limiting on API endpoints
- CORS configuration
- Helmet security headers
- Input validation and sanitization
- Protected routes for premium content
The platform integrates with Stripe for subscription management:
-
Setup Stripe Account
- Create a Stripe account
- Get your API keys
- Create products and prices in Stripe dashboard
-
Configure Webhooks
- Set up webhook endpoint:
POST /api/subscriptions/webhook - Configure events:
customer.subscription.created,customer.subscription.updated,customer.subscription.deleted
- Set up webhook endpoint:
-
Environment Variables
STRIPE_SECRET_KEY=sk_test_... STRIPE_WEBHOOK_SECRET=whsec_...
- Build the application:
npm run build - Set production environment variables
- Deploy to your preferred platform (Heroku, AWS, DigitalOcean, etc.)
- Build the application:
npm run build - Deploy the
distfolder to your hosting platform - Update environment variables for production
# Build and run with Docker Compose
docker-compose up --build- Register an account or sign in
- Browse available lessons
- Upgrade to premium for access to premium content
- Watch lessons and track your progress
- Manage your subscription through the billing portal
- Access admin features through the dashboard
- Create and manage lessons
- Monitor user subscriptions
- Manage content categories
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Commit your changes:
git commit -am 'Add feature' - Push to the branch:
git push origin feature-name - Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
For support, email khankhizerjahangir@gmail.com or create an issue in the repository.
- Initial release
- User authentication system
- Subscription management with Stripe
- Lesson browsing and viewing
- Premium content protection
- Responsive design
- Admin dashboard