Skip to content

This is the backend part of the meet2learn application, a dynamic web platform that offers a rich set of features including user registration, post management, commenting, profile management, and more, complementing the frontend React application

Notifications You must be signed in to change notification settings

kozerka/meet2learn-BE

Repository files navigation

meet2learn Backend (meet2learn-BE)

Language

📖 Overview

This is the backend part of the meet2learn application, a dynamic web platform that offers a rich set of features including user registration, post management, commenting, profile management, and more, complementing the frontend React application. go to FE repository

🌍 Live

To check all the features please register. If you want to be able to control your account please provide VALID email! All dummy email will be deleted from DataBase after 10 days -> meet2learn LIVE

💻 Technology Stack

NODE JS NODEMON EXPRESS .env JS MONGODB MONGOOSE

📝 Features

  • User Authentication: Supports secure user registration and login processes, including password reset options.
  • Profile Management: Handles user profile updates including: changing personal data and password, removing an account, profile picture uploads.
  • Security: Implements essential security measures such as input sanitization, token-based authentication, and password hashing.
  • Role-Based Access Control: Implementing middleware for role management, the application ensures secure access to various features based on user roles, enhancing both security and usability.
  • Nodemailer Integration with Email Templates: Nodemailer for email notifications, incorporating custom templates for different types of emails, such as password resets and account confirmation.
  • Dynamic Routing and Controller Architecture: RESTful API is built with Express, featuring distinct routers and controllers for users, tutors, reviews, posts, notes, meetings, conversations, and contact forms. Each module is meticulously crafted to handle specific data and logic.
  • File Upload and Cloud Storage Integration: Multer for handling file uploads, coupled with Cloudinary for efficient and secure cloud-based storage of images.

Code Samples

User Authentication Middleware

const auth = asyncHandler(async (req, res, next) => {
	let token;

	token = req.cookies.jwt;

	if (token) {
		try {
			const decoded = jwt.verify(token, process.env.JWT_SECRET);

			req.user = await User.findById(decoded.userId).select('-password');

			next();
		} catch (error) {
			res.status(401);
			throw new Error('Not authorized, token failed');
		}
	} else {
		res.status(401);
		throw new Error('Not authorized, no token');
	}
});

Image Upload with Multer and Cloudinary

cloudinary.config({
	cloud_name: process.env.CLOUDINARY_CLOUD_NAME,
	api_key: process.env.CLOUDINARY_APIKEY,
	api_secret: process.env.CLOUDINARY_API_SECRET,
});

export const storage = new CloudinaryStorage({
	cloudinary,
	allowedFormats: ['jpg', 'png', 'jpeg'],
	params: {
		folder: 'meet2learn',
		transformation: [{ width: 500, height: 500, crop: 'fit' }],
	},
});

👉 Getting Started

To use all BE functionalities on the FE, remember to download the FE from the link and run it according to the instructions provided go to FE repository

  1. Clone the repository:

    git clone [Repo-URL]
  2. Navigate to the project directory:

    cd [Repo-Name]
  3. Install dependencies:

    npm install
  4. Set up environment variables:

  • Create a .env file in the project root. You can use the .env.example - change name to .env
  • Add the necessary environment variables (e.g., database URI, JWT secret).
    DB_USER=YOUR_USER_NAME
    DB_PASSWORD=YOUR_PASSWORD
    DB_HOST=DATABASE_HOST_NAME
    
    NODE_ENV=development
    PORT=4000(PORT ACCORDING YOUR PREFERENCES)
    JWT_SECRET=SECRET_TOKEN
    JWT_EXPIRES_IN=ADD_EXPIRE_TIME
    NODEMAILER_PASS=YOUR_NODEMAILER_PASSWORD
    NODEMAILER_EMAIL=YOUR_NODEMAILER_EMAIL
    
    CLOUDINARY_CLOUD_NAME=CLOUDINARY_CLOUD_NAME
    CLOUDINARY_APIKEY=CLOUDINARY_API_KEY
    CLOUDINARY_API_SECRET=CLOUDINARY_API_SECRET
    

Note: Always keep your API keys confidential. Do not expose them in the client-side code or public repositories.

  1. Run the server:
  • For development:
    npm run start:dev
    
  • For production:
    npm start
    

⭐️ Future Development Plans

The application is set for some exciting updates. Here's what's planned for the future:

  • Introduction of Admin Role: The backend and routing have been designed to easily add an admin role. This role will bring new levels of management and oversight to the app.

  • Two-Step Verification for Tutor Accounts: There are plans to add a two-step verification process for tutors. This will help in ensuring that the content they publish is secure and trustworthy.

  • Expanded Dashboard Notifications: The dashboard will be upgraded to show more notifications. Users will be informed about new posts, comments, messages from tutors, and other important updates.

  • User Engagement Enhancements: The app will include new features to make it more interactive and engaging. This might include elements like badges for achievements or personalized learning paths.

💪 Contributing

If you'd like to contribute, please fork the repository and make changes as you'd like. Pull requests are warmly welcome.

💬 Feedback

If you have any feedback or issues, please open an issue in this repository.

⚠️ License

MIT


Created with ❤️ by [kozerka].


 

 

🙏 Special Thanks

A heartfelt thank you to my Mentor - devmentor.pl for setting forth this challenge.


About

This is the backend part of the meet2learn application, a dynamic web platform that offers a rich set of features including user registration, post management, commenting, profile management, and more, complementing the frontend React application

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published