This repository contains the source code for a full-stack web application built using Node.js and Express. The application leverages MongoDB for data storage, Passport for user authentication, and EJS for rendering dynamic HTML templates. It also implements sessions and flash messaging for managing user state and providing feedback.
Dynamic Web Pages: Utilizes EJS as the templating engine to serve dynamic content to users. Authentication: Implements user authentication using Passport with a local strategy, allowing secure login and access control. Database Operations: Connects to a MongoDB database for storing and retrieving data, including user profiles, listings, and reviews. Session Management: Uses express-session with MongoStore for persistent sessions, enabling user state management across multiple requests. Flash Messaging: Provides immediate feedback to users through flash messages for success or error notifications. Custom Error Handling: Includes middleware for handling errors gracefully, displaying relevant messages to users. Static File Serving: Serves static files such as CSS, JavaScript, and images from a dedicated directory.
- -- Backend runtime environment.
- -- Minimalist web framework for Node.js.
- -- NoSQL database for data storage.
- -- Authentication middleware for Node.js.
- -- Template engine for generating dynamic HTML pages.
- -- Loads environment variables from a .env file.
- -- Allows the use of HTTP verbs such as PUT and DELETE in places where the client doesn't support them.
- -- Stores session data in MongoDB.
To run this application locally, follow these steps:
- Clone the repository to your local machine.
- Install the required dependencies by running npm install.
- Create a .env file in the root directory and define the necessary environment variables (NODE_ENV, ATLASDB_URL, SECRET, etc.).
- Start the application by running node app.js.
Cloudinary is a cloud-based service that provides an end-to-end image and video management solution, including uploads, storage, manipulations, optimizations, and delivery. In this project, Cloudinary is utilized to handle media files uploaded by users, ensuring efficient storage and retrieval of high-quality images and videos. This integration enhances the application's scalability and performance by offloading heavy lifting from the backend servers.
MongoDB Atlas is a fully-managed cloud database developed by the same people who build MongoDB. It offers a scalable, reliable, and secure way to deploy MongoDB databases in the cloud. In this project, MongoDB Atlas serves as the primary database for storing application data, including user profiles, posts, comments, and metadata. By leveraging MongoDB Atlas, the application benefits from automatic scaling, backups, and disaster recovery, ensuring high availability and data integrity.
Cloudinary Integration: Users can upload images and videos directly to Cloudinary via the application's frontend. The application then stores references to these media files in MongoDB Atlas, linking them to relevant records (e.g., user profiles, posts). This approach minimizes storage requirements on the application servers and optimizes media delivery to end-users. MongoDB Atlas Setup: The application connects to MongoDB Atlas using the MongoDB Node.js driver. This connection is configured with credentials obtained from the MongoDB Atlas dashboard, ensuring secure communication between the application and the database. MongoDB Atlas clusters are automatically scaled based on demand, adapting to changes in traffic patterns and data volume.
By integrating Cloudinary and MongoDB Atlas, this project achieves several key benefits:
Scalability: Both services offer automatic scaling capabilities, allowing the application to handle increased loads efficiently. Reliability: MongoDB Atlas provides high availability and automatic backups, safeguarding against data loss. Performance: Cloudinary optimizes media delivery, reducing loading times and improving the overall user experience. Cost Efficiency: Pay-as-you-go pricing models for both services allow for cost savings by adjusting resources according to actual usage.