Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/eunoia-scu/eunoia-api

Graduation Project
https://github.com/eunoia-scu/eunoia-api

cloudinary ec2 expressjs mongodb mongoose multer nodejs nodemailer paymob pug redis stripe

Last synced: 2 days ago
JSON representation

Graduation Project

Awesome Lists containing this project

README

        




Natours


Eunoia API


# ๐Ÿ’ซ Eunoia Project (Graduation Project)

Eunoia simplifies event planning by integrating services like venues, catering, and photography into a single platform. Accessible via app and web, it features AI-powered recommendations and secure booking.

## ๐ŸŒŸ Eunoia API

This project offers APIs for efficient event planning, enabling access to service provider directories, booking services, and user account management. Built with Express.js and tested with Jest, it includes AI-powered recommendations and secure transactions to enhance user experience.

## ๐Ÿ“‹ Table of Contents

- [๐ŸŒŸ Eunoia API](#-eunoia-api)
- [๐Ÿ“‹ Table of Contents](#-table-of-contents)
- [๐Ÿš€ Getting Started](#-getting-started)
- [๐Ÿ”ง Prerequisites](#-prerequisites)
- [๐Ÿ“ฆ Installation](#-installation)
- [๐Ÿ–ฅ๏ธ Running the Server](#๏ธ-running-the-server)
- [๐Ÿงช Running Tests](#-running-tests)
- [๐Ÿ“š API Documentation](#-api-documentation)
- [๐Ÿ‘ฅ Authentication Endpoints](#-authentication-endpoints)
- [๐Ÿ“Š Services Endpoints](#-services-endpoints)
- [๐Ÿ‘Œ API Complete Docs](#-api-complete-Docs)
- [๐Ÿ—‚๏ธ Project Structure](#๏ธ-project-structure)
- [๐Ÿ“œ License](#-license)

## ๐Ÿš€ Getting Started

### ๐Ÿ”ง Prerequisites

Ensure you have the following installed:

- Node.js
- npm or yarn

### ๐Ÿ“ฆ Installation

1. Clone the repository:

```bash
git clone https://github.com/your-username/Eunoia-Backend.git
cd Eunoia-Backend
```

2. Install dependencies:
```bash
npm install
# or
yarn install
```

### ๐Ÿ–ฅ๏ธ Running the Server

1. Start the development server :

```bash
npm run dev
# or
yarn dev
```

2. The server should now be running at `http://localhost:3000`.

### ๐Ÿงช Running Tests

To run the test suite:

```bash
npm test
# or
yarn test
```

## ๐Ÿ“š API Documentation

### ๐Ÿ‘ฅ Authentication Endpoints

- **Endpoint:** `api/v1/auth/register`
- **Method:** `Post`
- **Body:**

- `name` (string): user name
- `email` (string): user email
- `password` (string): user password
- `passwordConfirm` (string): user confirm password
- `role` (string): user role (user/serviceProvider)

- **Example Request:**

```bash
curl "http://localhost:3000/api/v1/auth/register"
```

- **Example Response:**

```json
[
{
"status": "success",
"token": "JWT TOKEN"
}
]
```

- **Endpoint:** `api/v1/auth/login`
- **Method:** `Post`
- **Body:**

- `email` (string): user email
- `password` (string): user password

- **Example Request:**

```bash
curl "http://localhost:3000/api/v1/auth/login"
```

- **Example Response:**

```json
[
{
"status": "success",
"token": "JWT TOKEN"
}
]
```

- **Endpoint:** `api/v1/auth/logout`
- **Method:** `Post`
- **Body:**

- empty

- **Example Request:**

```bash
curl "http://localhost:3000/api/v1/auth/logout"
```

- **Example Response:**

```json
[
{
"status": "success"
}
]
```

- **Endpoint:** `api/v1/auth/forgotPassword`
- **Method:** `Post`
- **Body:**

- `email` (string): user email

- **Example Request:**

```bash
curl "http://localhost:3000/api/v1/auth/forgotPassword"
```

- **Example Response:**

```json
[
{
"status": "Success",
"message": "Reset code sent to email"
}
]
```

- **Endpoint:** `api/v1/auth/forgotPassword`
- **Method:** `Post`
- **Body:**

- `otp` (number): The code sent to the email

- **Example Request:**

```bash
curl "http://localhost:3000/api/v1/auth/verfiyCode"
```

- **Example Response:**

```json
[
{
"status": "Success",
"messgae": "Your Code has been successfully verified. You can now proceed to reset your password."
}
]
```

- **Endpoint:** `api/v1/auth/resetPassword`
- **Method:** `Patch`
- **Body:**

- `email` (string): your email
- `newPassword` (string): your new password

- **Example Request:**

```bash
curl "http://localhost:3000/api/v1/auth/resetPassword"
```

- **Example Response:**

```json
[
{
"status": "success",
"token": "JWT TOKEN"
}
]
```

### ๐Ÿ“Š Services Endpoints

- **Endpoint:** `api/v1/services`
- **Method:** `POST`
- **Body:**

- `businessName` (String)
- `about` (string)
- `location` (string)
- `businessCategory` (string)
- `phoneNumber` (number)
- `avatar` (FormData)
- `images` (FormData):array of images
- `imageCover`(FormData)

- **Example Request:**

```bash
curl "http://127.0.0.1:3000/api/v1/services/"
```

- **Example Response:**

```json
{
"status": "success",
"message": "Service Profile created successfully",
"data": {
"_id": "660878526adb0cb6ece59904",
"businessName": "The Garden",
"about": "The Garden features three main spaces for your wedding day: a Rooftop Terrace with a picturesque views of Bryant Park, the Grill Dining Room, and the South Garden. The terrace is best suited for your wedding ceremony and can accommodate up to 220 guests. The restaurant can host a seated dinner for up to 220 guests. For couples interested in booking the full venue, up to 1,000 guests can be serviced.",
"location": "Ismailia",
"businessCategory": "Venues",
"phoneNumber": "01234567890",
"avatar": "http://res.cloudinary.com/dbrywi5aw/image/upload/v1711831118/avatar.jpg",
"imageCover": "http://res.cloudinary.com/dbrywi5aw/image/upload/v1714673495/CoverImages/serviceProfile/cb13896a-1d0c-4d66-b7e0-9334a9c4cc37.jpg",
"images": [
"http://res.cloudinary.com/dbrywi5aw/image/upload/v1714669784/Albums/serviceProfile/Albums0-10974f93-dd59-435f-9c34-a15e14e0dcff.jpg"
],
"owner": "660860be6adb0cb6ece598fe",
"createdAt": "2024-03-30T20:38:43.001Z",
"updatedAt": "2024-06-21T13:32:59.867Z",
"ratingsAverage": 4,
"ratingsQuantity": 2,
"id": "660878526adb0cb6ece59904"
}
}
```

- **Endpoint:** `api/v1/services`
- **Method:** `GET`
- **Query Parameters:**

- `page` (number): the number of page you want to return.
- `limit` (number): the number of document you want to return in the page.
- `sort` (string): (ratingsQuantity|ratingsAverage|updatedAt|updatedAt)
- `limitFields` (string): name of field you want to return in the response (\_id|businessName|about|location|businessCategory|phoneNumber|images|owner|ratingsQuantity|ratingsAverage)
- `ratingsAverage` return the services which have ratingsAverage[gte(greater than or equal) || gt(greater than) || ls(less than ) || lte(less than or equal) ]:(number)
- `sort` (field name): sort by filed name like ratingsAverage or ratingsquantity

- **Example Request:**

```bash
curl "http://127.0.0.1:3000/api/v1/services/?page=2&limit=5&ratingsAverage[gte]=4.3&filter=DJs&sort=createdAt"
```

- **Example Response:**

```json
{
"results": 7,
"paginationResult": {
"currntPage": 1,
"limit": 50,
"numberOfPages": 1
},
"data": [
{
"_id": "660878526adb0cb6ece59904",
"businessName": "The Garden",
"about": "The Garden features three main spaces for your wedding day: a Rooftop Terrace with a picturesque views of Bryant Park, the Grill Dining Room, and the South Garden. The terrace is best suited for your wedding ceremony and can accommodate up to 220 guests. The restaurant can host a seated dinner for up to 220 guests. For couples interested in booking the full venue, up to 1,000 guests can be serviced.",
"location": "Ismailia",
"businessCategory": "Venues",
"phoneNumber": "01234567890",
"avatar": "http://res.cloudinary.com/dbrywi5aw/image/upload/v1711831118/avatar.jpg",
"imageCover": "http://res.cloudinary.com/dbrywi5aw/image/upload/v1714673495/CoverImages/serviceProfile/cb13896a-1d0c-4d66-b7e0-9334a9c4cc37.jpg",
"images": [
"http://res.cloudinary.com/dbrywi5aw/image/upload/v1714669784/Albums/serviceProfile/Albums0-10974f93-dd59-435f-9c34-a15e14e0dcff.jpg"
],
"owner": "660860be6adb0cb6ece598fe",
"createdAt": "2024-03-30T20:38:43.001Z",
"updatedAt": "2024-06-21T13:32:59.867Z",
"ratingsAverage": 4,
"ratingsQuantity": 2,
"id": "660878526adb0cb6ece59904"
}
// more services ...
]
}
```

- **Endpoint:** `api/v1/services/:id`
- **Method:** `GET`
- **Query params:**

- `id` (mongoID): mongoId of exist document

- **Example Request:**

```bash
curl "http://127.0.0.1:3000/api/v1/services/660878526adb0cb6ece59904"
```

- **Example Response:**

```json
{
"data": {
"_id": "660878526adb0cb6ece59904",
"businessName": "The Garden",
"about": "The Garden features three main spaces for your wedding day: a Rooftop Terrace with a picturesque views of Bryant Park, the Grill Dining Room, and the South Garden. The terrace is best suited for your wedding ceremony and can accommodate up to 220 guests. The restaurant can host a seated dinner for up to 220 guests. For couples interested in booking the full venue, up to 1,000 guests can be serviced.",
"location": "Ismailia",
"businessCategory": "Venues",
"phoneNumber": "01234567890",
"avatar": "http://res.cloudinary.com/dbrywi5aw/image/upload/v1711831118/avatar.jpg",
"imageCover": "http://res.cloudinary.com/dbrywi5aw/image/upload/v1714673495/CoverImages/serviceProfile/cb13896a-1d0c-4d66-b7e0-9334a9c4cc37.jpg",
"images": [
"http://res.cloudinary.com/dbrywi5aw/image/upload/v1714669784/Albums/serviceProfile/Albums0-10974f93-dd59-435f-9c34-a15e14e0dcff.jpg",
"http://res.cloudinary.com/dbrywi5aw/image/upload/v1714673192/Albums/serviceProfile/Albums0-2e6d3f3e-c654-4fc2-a0f0-64ab474406dc.jpg"
],
"owner": "660860be6adb0cb6ece598fe",
"createdAt": "2024-03-30T20:38:43.001Z",
"updatedAt": "2024-06-21T13:32:59.867Z",
"__v": 5,
"ratingsAverage": 4,
"ratingsQuantity": 2,
"reviews": [
{
"_id": "662aa6131bef1b61ca7c3e8e",
"title": "amazing service\n",
"ratings": 3,
"user": {
"_id": "6612f57ad4ff84c0ed4acced",
"name": "omar ",
"avatar": "http://res.cloudinary.com/dbrywi5aw/image/upload/v1713651559/avatar.jpg"
},
"service": "660878526adb0cb6ece59904",
"createdAt": "2024-04-25T18:50:59.017Z",
"updatedAt": "2024-04-25T18:50:59.017Z",
"__v": 0
},
{
"_id": "6675810af4e1130ec348b254",
"title": "",
"ratings": 5,
"user": {
"_id": "6674a92b8217a177b6921aa0",
"name": "Ali Nour",
"avatar": "http://res.cloudinary.com/dbrywi5aw/image/upload/v1718922031/ProfilePicture/avatar/7219325b-667c-47db-a7f1-b25128955cc0.jpg"
},
"service": "660878526adb0cb6ece59904",
"createdAt": "2024-06-21T13:32:58.550Z",
"updatedAt": "2024-06-21T13:32:58.550Z",
"__v": 0
}
],
"packages": [],
"id": "660878526adb0cb6ece59904"
}
}
```

- **Endpoint:** `api/v1/services/:id`
- **Method:** `DELETE`
- **Query params:**

- `id` (mongoID): mongoId of exist document (You should be the owner of the service to delete it)

- **Example Request:**

```bash
curl "http://127.0.0.1:3000/api/v1/services/660878526adb0cb6ece59904"
```

- **Example Response:**

```json
{}
```

- **Endpoint:** `api/v1/services/:id`
- **Method:** `PATCH`
- **Query params:**

- `id` (mongoID): mongoId of exist document (You should be the owner of the service to delete it)

- **Body:**
- `businessName`:(String)
- `about`:(String)
- `images`:(formData)
- `location`:(String)
- `businessCategory`:(String)
- `phoneNumber`:(number)
- `avatar`:(formData)
- `imageCover`:(formData)
- `latitude`:(number)
- `longitude`:(number)
- **Example Request:**

```bash
curl "http://127.0.0.1:3000/api/v1/services/660878526adb0cb6ece59904"
```

- **Example Response:**

```json
{
"data": {
"_id": "660878526adb0cb6ece59904",
"businessName": "The Garden",
"about": "The Garden features three main spaces for your wedding day: a Rooftop Terrace with a picturesque views of Bryant Park, the Grill Dining Room, and the South Garden. The terrace is best suited for your wedding ceremony and can accommodate up to 220 guests. The restaurant can host a seated dinner for up to 220 guests. For couples interested in booking the full venue, up to 1,000 guests can be serviced.",
"location": "Ismailia",
"businessCategory": "Venues",
"phoneNumber": "01234567890",
"avatar": "http://res.cloudinary.com/dbrywi5aw/image/upload/v1711831118/avatar.jpg",
"imageCover": "http://res.cloudinary.com/dbrywi5aw/image/upload/v1714673495/CoverImages/serviceProfile/cb13896a-1d0c-4d66-b7e0-9334a9c4cc37.jpg",
"images": [
"http://res.cloudinary.com/dbrywi5aw/image/upload/v1714669784/Albums/serviceProfile/Albums0-10974f93-dd59-435f-9c34-a15e14e0dcff.jpg",
"http://res.cloudinary.com/dbrywi5aw/image/upload/v1714673192/Albums/serviceProfile/Albums0-2e6d3f3e-c654-4fc2-a0f0-64ab474406dc.jpg"
],
"__v": 5,
"ratingsAverage": 4,
"ratingsQuantity": 2
}
}
```

### ๐Ÿ‘Œ API Complete Docs

_You can see all API docs [here](http://ec2-3-129-5-59.us-east-2.compute.amazonaws.com/api/v1/)_

```
- Postman Docs will be avaliable soon.
```

## ๐Ÿ—‚๏ธ Project Structure

```
Here's the project structure based on the provided image:

eunoia-backend/
โ”œโ”€โ”€ **tests**/
โ”‚ โ”œโ”€โ”€ service.test.js
โ”œโ”€โ”€ src/
โ”‚ โ”œโ”€โ”€ config/
โ”‚ โ”‚ โ”œโ”€โ”€ db.js
โ”‚ โ”œโ”€โ”€ controllers/
โ”‚ โ”‚ โ”œโ”€โ”€ authController.js
โ”‚ โ”‚ โ”œโ”€โ”€ errorController.js
โ”‚ โ”‚ โ”œโ”€โ”€ handelFactory.js
โ”‚ โ”‚ โ”œโ”€โ”€ orderController.js
โ”‚ โ”‚ โ”œโ”€โ”€ reviewController.js
โ”‚ โ”‚ โ”œโ”€โ”€ serviceController.js
โ”‚ โ”‚ โ”œโ”€โ”€ userController.js
โ”‚ โ”‚ โ”œโ”€โ”€ packageController.js
โ”‚ โ”‚ โ”œโ”€โ”€ requestController.js
โ”‚ โ”‚ โ”œโ”€โ”€ wishlistController.js
โ”‚ โ”œโ”€โ”€ middlewares/
โ”‚ โ”‚ โ”œโ”€โ”€ uploadImageMiddleware.js
โ”‚ โ”‚ โ”œโ”€โ”€ emailMiddleware.js
โ”‚ โ”‚ โ”œโ”€โ”€ validatorMiddleware.js
โ”‚ โ”‚ โ”œโ”€โ”€ verifyPaymobRequest.js
โ”‚ โ”œโ”€โ”€ models/
โ”‚ โ”‚ โ”œโ”€โ”€ orderModel.js
โ”‚ โ”‚ โ”œโ”€โ”€ packageModel.js
โ”‚ โ”‚ โ”œโ”€โ”€ requestModel.js
โ”‚ โ”‚ โ”œโ”€โ”€ reviewModel.js
โ”‚ โ”‚ โ”œโ”€โ”€ serviceModel.js
โ”‚ โ”‚ โ”œโ”€โ”€ userModel.js
โ”‚ โ”œโ”€โ”€ routes/
โ”‚ โ”‚ โ”œโ”€โ”€ authRoutes.js
โ”‚ โ”‚ โ”œโ”€โ”€ orderRoutes.js
โ”‚ โ”‚ โ”œโ”€โ”€ packageRoutes.js
โ”‚ โ”‚ โ”œโ”€โ”€ requestRoutes.js
โ”‚ โ”‚ โ”œโ”€โ”€ reviewRoutes.js
โ”‚ โ”‚ โ”œโ”€โ”€ serviceRoutes.js
โ”‚ โ”‚ โ”œโ”€โ”€ userRoutes.js
โ”‚ โ”‚ โ”œโ”€โ”€ welcomeRoutes.js
โ”‚ โ”‚ โ”œโ”€โ”€ wishlistRoutes.js
โ”‚ โ”œโ”€โ”€ utils/
โ”‚ โ”‚ โ”œโ”€โ”€ paymob/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ authenticate.js
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ checkout.js
โ”‚ โ”‚ โ”œโ”€โ”€ validators/
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ packageValidator.js
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ requestValidator.js
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ reviewValidator.js
โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ serviceValidator.js
โ”‚ โ”‚ โ”œโ”€โ”€ apiFeatures.js
โ”‚ โ”‚ โ”œโ”€โ”€ appError.js
โ”‚ โ”‚ โ”œโ”€โ”€ catchAsync.js
โ”‚ โ”‚ โ”œโ”€โ”€ cloudinary.js
โ”‚ โ”‚ โ”œโ”€โ”€ createToken.js
โ”‚ โ”‚ โ”œโ”€โ”€ logger.js
โ”‚ โ”‚ โ”œโ”€โ”€ paymob.js
โ”‚ โ”‚ โ”œโ”€โ”€ redis.js
โ”‚ โ””โ”€โ”€ app.js
โ”‚ โ””โ”€โ”€ server.js
โ”œโ”€โ”€ views/
โ”‚ โ”œโ”€โ”€ email/
โ”‚ โ”‚ โ”œโ”€โ”€ \_style.pug
โ”‚ โ”‚ โ”œโ”€โ”€ baseEmail.pug
โ”‚ โ”‚ โ”œโ”€โ”€ passwordChanged.pug
โ”‚ โ”‚ โ”œโ”€โ”€ passwordReset.pug
โ”‚ โ”‚ โ”œโ”€โ”€ requestAccepted.pug
โ”‚ โ”‚ โ”œโ”€โ”€ requestDecline.pug
โ”‚ โ”‚ โ”œโ”€โ”€ welcome.pug
โ”‚ โ”œโ”€โ”€ index.pug
โ”œโ”€โ”€ .env
โ”œโ”€โ”€ app.js
โ”œโ”€โ”€ server.js
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ README.md

```

## ๐Ÿ“œ License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.

---

This README provides a comprehensive guide for setting up, running, and testing the project, as well as detailed API documentation and project structure information.

# Worked on this Project

ยฉ [Ali Nour](https://github.com/alin00r) ยฉ [Mazen](https://github.com/mazenmohamedmahmoudatia666) ยฉ [Kareem](https://github.com/karemhamed)