Skip to content

A robust and scalable RESTful API backend for a course selling platform

Notifications You must be signed in to change notification settings

iamJ3/Course-Selling-Backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎓 Course Selling Backend API

A robust and scalable RESTful API backend for a course selling platform built with Node.js, Express, and MongoDB. This application provides comprehensive user authentication, admin course management, and purchase tracking capabilities.

✨ Features

🔐 Authentication & Authorization

  • User Authentication: Secure signup and signin with JWT tokens
  • Admin Authentication: Separate admin authentication system with elevated privileges
  • Token-based Security: JSON Web Tokens for secure API access

👥 User Management

  • User registration and login
  • View purchased courses
  • Purchase course functionality

🎯 Admin Features

  • Admin registration and login
  • Create and manage courses
  • Course content management (title, description, price, images)

📚 Course Management

  • Course creation and listing
  • Course preview for users
  • Purchase tracking and management

🛠️ Tech Stack

  • Backend: Node.js, Express.js
  • Database: MongoDB with Mongoose ODM
  • Authentication: JWT (JSON Web Tokens)
  • Development: Nodemon for hot reloading

🚀 Quick Start

Prerequisites

  • Node.js (v14 or higher)
  • MongoDB database
  • npm or yarn

Installation

  1. Clone the repository

    git clone <repository-url>
    cd course-selling-backend
  2. Install dependencies

    npm install
  3. Environment Setup

    • Update the MongoDB connection string in index.js
    • Configure JWT secrets in config/config.js
  4. Start the application

    # Development mode
    npm run dev
    
    # Production mode
    npm start

The server will start on http://localhost:3000

📡 API Endpoints

User Routes

  • POST /user/signup - Register a new user
  • POST /user/signin - User login
  • GET /user/purchases - View purchased courses
  • POST /user/purchases - Purchase a course

Admin Routes

  • POST /admin/signup - Register a new admin
  • POST /admin/signin - Admin login
  • POST /admin/course - Create a new course (admin only)
  • GET /admin/course - View courses (admin only)

Course Routes

  • GET /course/preview - Preview available courses
  • POST /course/purchases - Purchase a course

🏗️ Project Structure

course-selling-backend/
├── config/
│   └── config.js          # JWT configuration
├── db/
│   └── db.js              # Database models and schemas
├── middlewares/
│   ├── admin.middleware.js # Admin authentication middleware
│   └── user.middlewares.js # User authentication middleware
├── routes/
│   ├── admin.route.js     # Admin-related routes
│   ├── courses.route.js   # Course-related routes
│   └── user.route.js      # User-related routes
├── index.js               # Main application entry point
├── package.json           # Project dependencies and scripts
└── README.md              # This file

🗄️ Database Schema

User Model

{
  email: String (unique),
  password: String,
  firstname: String,
  lastName: String
}

Admin Model

{
  email: String (unique),
  password: String,
  firstname: String,
  lastName: String
}

Course Model

{
  title: String,
  desc: String,
  price: Number,
  imageUrl: String,
  creatorId: ObjectId
}

Purchase Model

{
  userId: ObjectId,
  courseId: ObjectId
}

🔧 Configuration

The application uses the following configuration:

  • Database: MongoDB connection string in index.js
  • JWT Secrets: User and admin JWT passwords in config/config.js

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📝 License

This project is licensed under the ISC License - see the package.json file for details.

🐛 Issues

If you encounter any issues or have suggestions, please create an issue in the repository.

📞 Contact

For any queries or collaboration, please reach out through the repository issues section.


Built with ❤️ using Node.js and Express

About

A robust and scalable RESTful API backend for a course selling platform

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published