A robust REST API backend for an online course-selling platform built with Node.js, Express, and MongoDB. This application handles user authentication, course management, and purchase workflows.
-
User Authentication & Authorization
- JWT-based authentication
- Secure password hashing
- Role-based access control (Admin/User)
-
Course Management
- Create, read, update, and delete courses
- Course categorization and filtering
- Course purchase functionality
-
User Management
- User registration and login
- Profile management
- Purchase history tracking
-
Security
- Password encryption using bcrypt
- JWT token-based authentication
- Protected routes with middleware
- Input validation and sanitization
- Runtime: Node.js
- Framework: Express.js
- Database: MongoDB
- Authentication: JWT (JSON Web Tokens)
- Password Hashing: bcrypt
Course-Selling-App/
├── middleware/ # Authentication and validation middleware
├── routes/ # API route handlers
├── db.js # Database connection and schemas
├── index.js # Main application entry point
├── package.json # Project dependencies
└── .gitignore # Git ignore rules
-
Clone the repository
git clone https://github.com/AdityaJRDev/Course-Selling-App.git cd Course-Selling-App -
Install dependencies
npm install
-
Set up environment variables
Create a
.envfile in the root directory:PORT=3000 MONGODB_URI=your_mongodb_connection_string JWT_SECRET=your_jwt_secret_key
-
Start the server
npm start
The server will start on
http://localhost:3000
POST /api/user/signup- Register a new userPOST /api/user/login- User loginGET /api/user/courses- Get all available coursesPOST /api/user/courses/:courseId- Purchase a courseGET /api/user/purchasedCourses- Get purchased courses
POST /api/admin/signup- Register a new adminPOST /api/admin/login- Admin loginPOST /api/admin/courses- Create a new coursePUT /api/admin/courses/:courseId- Update a courseGET /api/admin/courses- Get all courses (admin view)
This API uses JWT (JSON Web Tokens) for authentication. Include the token in the Authorization header for protected routes:
Authorization: Bearer <your_jwt_token>
{
username: String,
password: String (hashed),
purchasedCourses: [CourseId]
}{
username: String,
password: String (hashed)
}{
title: String,
description: String,
price: Number,
imageLink: String,
published: Boolean
}You can test the API endpoints using tools like:
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
Aditya JR
-
GitHub: @AdityaJRDev
-
Built as a learning project to understand backend development
-
Inspired by modern e-learning platforms
⭐ If you found this project helpful, please consider giving it a star!