Welcome to the Campus Connect Backend API repository. For detailed installation instructions, please refer to the Installation Guide.
This repository contains the backend API for the Campus Connect project. The API is built using Node.js and Express, and it connects to a MongoDB database. It also utilizes Socket.IO for real-time communication and other technologies to enhance functionality.
- Node.js: JavaScript runtime built on Chrome's V8 JavaScript engine.
- Express: Fast, unopinionated, minimalist web framework for Node.js.
- MongoDB: NoSQL database for storing application data.
- Mongoose: Elegant MongoDB object modeling for Node.js.
- Socket.IO: Enables real-time, bidirectional and event-based communication.
- JWT (JSON Web Tokens): For secure authentication.
- dotenv: Loads environment variables from a
.env
file intoprocess.env
. - bcrypt: Library to help hash passwords.
- cloudinary: Cloud-based image and video management service.
- cookie-parser: Middleware to parse cookies.
- cors: Middleware to enable Cross-Origin Resource Sharing.
- mongoose-aggregate-paginate-v2: Mongoose plugin for aggregate pagination.
- multer: Middleware for handling
multipart/form-data
, used for file uploads.
Before you begin, ensure you have met the following requirements:
- You have installed Node.js (version 14 or higher).
- You have a Git client installed.
- You have a code editor like Visual Studio Code.
To install the project, follow these steps:
-
Fork the repository:
- Go to the repository on GitHub.
- Click the "Fork" button at the top right of the page.
-
Clone your forked repository:
git clone https://github.com/your-username/your-forked-repository.git
-
Navigate to the project directory:
cd your-forked-repository
-
Install dependencies:
npm install
-
Create a
.env
file:- Copy the
.env.sample
file to.env
:cp .env.sample .env
- Open the
.env
file and replace the placeholder values with your actual URI and keys. - Example:
PORT=3000 MONGODB_URI=mongodb://localhost:27017/campus-connect NODE_ENV=development CORS_ORIGIN=http://localhost:3000 ACCESS_TOKEN_SECRET=your_access_token_secret ACCESS_TOKEN_EXPIRY=1h REFRESH_TOKEN_SECRET=your_refresh_token_secret REFRESH_TOKEN_EXPIRY=7d CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name CLOUDINARY_API_KEY=your_cloudinary_api_key CLOUDINARY_API_SECRET=your_cloudinary_api_secret
- Copy the
-
Set up Cloudinary:
- Follow the Cloudinary Node.js SDK Quick Start Guide to set up and configure Cloudinary.
-
Set up MongoDB Atlas:
- Follow the MongoDB Atlas Getting Started Guide to create a cluster, configure network access, and connect to your database.
-
Change the database name in
constants.js
:- Open the
constants.js
file in your code editor. - Locate the line that defines the database name:
export const DB_NAME = "campus-connect";
- Change
"campus-connect"
to your desired database name:export const DB_NAME = "your-database-name";
- Open the
To run the project, follow these steps:
-
Start the development server:
npm run dev
-
Open your browser and navigate to
http://localhost:8000
if you haven't setup the PORT on .env or change the 8000 with your PORT.
For detailed information on the API endpoints, please refer to the Postman Documentation