Backend for SmartLearn - A Learning Management System with TypeScript support and improved features.
SmartLearn-ts-backend is a backend service built with Node.js, TypeScript, and MongoDB. It provides RESTful APIs for managing learning resources.
- User authentication and authorization (AuthService)
- Email notifications using nodemailer
- Background workers (email service, upload) using BullMQ
- Logging System using RabbitMQ
- Media content management using Cloudinary
- Google Oauth (sign-in with google)
- Course management
- Lesson management
- Assignment tracking
-
Cloudinary: Cloudinary is a powerful media API for websites and mobile apps alike, Cloudinary enables developers to efficiently manage, transform, optimize, and deliver images and videos through multiple CDNs. Go to cloudinary, create an account and store your credential in the .env file
-
Nodemailer setup with gmail and app password: Nodemailer is a module for Node.js applications that allows easy email sending. This setup uses gmail as a transport service. using gmail as a transport expects an actual user, so go over to your google account, ensure 2fa is setup for your account, create an app password, for nodemailer to work, store the app password in SMTP_PASS. You may refer to this guide
-
EmailQueueService: To handle sending of email off the main application thread of the server, An EmailQueueService is setup, using Bullmq(a Redis-backed queue system). On email transmission, the EmailQueueService, enqueue the a mesage containing the email payload. An EmailWorker process (seperate node.js process) runs independently, subscribed to the BullMQ email queue and listens for new queues added to the email queue, on reception performs sending of emails. You may refer to this guide
-
Google Sign-in using passport.js: Google APIs are application programming interfaces developed by Google which allow communication with Google Services and their integration to other services.The authentication process of this application utilizes a self hosted AuthService and Google Strategy. In order for Google to identify which application's Passport interacts with their API, you will need to obtain clientID and clientSecret in Google Developers Console. You may refer to this guide for the steps.
-
Clone the repo:
git clone https://github.com/Elijah57/SmartLearn-ts-backend.git cd SmartLearn-ts-backend
-
Install dependencies:
npm install
-
Set up environment variables: Create a
.env
file in the root directory and add the following:PORT = 4000 ENV = "DEV" HOST = "http://localhost:4000" DB_URI=your_mongodb_connection_string DB_URI_LOCAL= "mongodb://root:mongodb@localhost:27017/smart-learn?authSource=admin" JWT_SECRET=your_jwt_secret SMTP_MAIL=google_mail SMTP_PASS=google_app_password SMTP_HOST = "smtp.gmail.com" SMTP_PORT = 465 SMTP_SERVICE = "gmail" REDIS_SESSION_URL="redis://localhost:6370" REDIS_CACHE_URL="redis://localhost:6350" RABBITMQ_URL=rabbitMq_url SESSION_SECRET= CLOUD_NAME=cloudinary_name CLOUD_API_KEY=cloudinary_api_key CLOUD_API_SECRET=cloudinary_secret CLIENT_ID=your_google_client_id_for_oauth CLIENT_SECRET=your-google_client_secret CALLBACK_URL=oauth_callback_url OPEN_API_KEY=your_openaikey
-
Start the server:
npm start
To start using the API, send requests to http://localhost:4000/api
.
-
POST /api/auth/register
- Register a new user -
POST /api/auth/login
- Login a user -
GET /api/auth/verify-email
- Verify User Email -
GET/api/auth/send-verification-link
- Send email verification link -
GET/api/auth/forgot-password
- Send reset password link -
GET/api/auth/reset-password
- Reset users password -
GET /api/courses
- Get all courses -
POST /api/courses
- Create a new course
We welcome contributions! Please follow these steps to contribute:
- Fork the repository.
- Create a new branch (
git checkout -b feature-branch
). - Make your changes.
- Commit your changes (
git commit -m 'Add some feature'
). - Push to the branch (
git push origin feature-branch
). - Open a pull request.
This project is licensed under the MIT License.