Welcome to Olivier's backend repository for the Node/React Practicum. Dive in to set up and operate the backend components crucial for Olivier's operations.
Front-End Repository: Link to Front-End Repository
- Introduction
- Screenshots
- User Authentication & Management
- Schemas & Data Structures
- Recipe Functionality
- Meal Planner Functionality
- User-Recipe Association
- Error Handling
- Shopping List API
- Mail Functionality
- Technologies Used
- Authors
- Contributing & Improvements
- License
Olivier combines AI and culinary tradition, revolutionizing kitchens with personalized recipes, meal plans, and shopping lists. More than just recipes, it's a chef and organizer in your pocket.
- Clone the repository onto your local device (following steps):
git clone git@github.com:Code-the-Dream-School/dd-prac-team1-back.git
cd dd-prac-team1-back
npm install
-
Set up Mongo database by installing MongoDB
-
Obtain the following API Keys:
-
Copy the
.env.example
file and rename it to.env
:
cp .env.example .env
- Replace the placeholders with your specific values:
MONGO_URI = "<your_mongodb_connection_url>"
JWT_SECRET = <your_unique_jwt_secret_key>
JWT_LIFETIME = <your_desired_jwt_lifetime>
SESSION_SECRET = <your_unique_session_secret_key>
NODE_ENV=<your_environment>
OPENAI_API_KEY = <your_openai_api_secret_key>
BING_IMAGE_SEARCH_API_KEY =<your_bing_api_secret_key>
CLOUD_NAME = <your_cloudinary_cloud_name>
CLOUD_API_KEY = <your_cloudinary_api_key>
CLOUD_API_SECRET = <your_cloudinary_api_secret_key>
FROM_EMAIL = <your_email_address>
CLIENT_ID=<your_client_id>
CLIENT_SECRET=<your_client_secret>
REDIRECT_URI=<your_redirect_uri>
REFRESH_TOKEN=<your_refresh_token>
- Run
npm run start
to start the development server - The app will be served at http://localhost:3000/.
- Your back-end server is now running. You can now run the front-end app.
Managing user sessions and ensuring security is paramount. The process involves:
- Registering new users
- Logging in and out
- Password management (including forgotten and reset functions)
HTTP Verbs | Endpoints | Action |
---|---|---|
POST | /api/v1/auth/register | Register User |
POST | /api/v1/auth/login | Login User |
POST | /api/v1/auth/logout | Logout User |
POST | /api/v1/auth/forget-password | Forgot Password |
PUT | /api/v1/auth/reset-password/:token | Reset Password |
Note: Proper validation and error handling are implemented for user security.
- Defines user data structure: usernames, emails, and hashed passwords.
- Includes methods for password management and JWT token creation.
- Defines recipe data, including:
- Name
- Ingredients
- Cooking instructions
- Nutrition info
- Image, and more.
- Uses subdocuments for ingredients and tags.
- Structured to include information like:
- Date
- Meals (Breakfast, Lunch, Dinner, Snacks)
- Notes
- Defines shopping list data structure:
- userId: Link to a unique user
- Ingredients: List of items with their name, amount, and unit of measurement.
Allows users to manage their recipes.
HTTP Verbs | Endpoints | Action |
---|---|---|
POST | /api/v1/recipes | Fetch AI Recipe |
POST | /api/v1/recipes/add-ai | Create AI Recipe |
POST | /api/v1/recipes/add-manual | Create Manual Recipe |
GET | /api/v1/recipes | Get All Recipes |
GET | /api/v1/recipes/:recipeId | Get Recipe by ID |
PATCH | /api/v1/recipes/:recipeId | Update Recipe |
DELETE | /api/v1/recipes/:recipeId | Delete Recipe |
Note: Authentication is required. Only creators can modify their recipes.
Allows users to create, view, update, and delete their meal plans.
HTTP Verbs | Endpoints | Action |
---|---|---|
GET | /api/v1/meal-planner/ | Get All Meal Plans |
POST | /api/v1/meal-planner/ | Create Meal Plan |
PUT | /api/v1/meal-planner/:id | Update Meal Plan |
DELETE | /api/v1/meal-planner/:id | Delete Meal Plan |
Note: Authentication is required. Only the creators can modify their meal plans.
- When a user creates a recipe, the
recipeCreatedBy
field is assigned their unique ID. - Authentication tokens ensure security.
Responses follow a consistent format. Errors return appropriate HTTP status codes and messages.
Allows users to manage shopping lists with functionalities like adding recipe ingredients.
HTTP Verbs | Endpoints | Action |
---|---|---|
POST | /api/v1/shopping-list/:recipeId | Add All Ingredients from Recipe to Shopping List |
GET | /api/v1/shopping-list | Get Shopping List |
DELETE | /api/v1/shopping-list/:ingredientName | Delete Ingredient |
DELETE | /api/v1/shopping-list/ | Clear Shopping List |
PUT | /api/v1/shopping-list/:ingredientName | Update Ingredient Amount |
POST | /api/v1/shopping-list/add-ingredient | Add Ingredient |
Note: Authentication is required.
HTTP Verbs | Endpoints | Action |
---|---|---|
POST | /api/v1/sendmail | Send an Email |
Note: Authentication is required. Only authorized users can send emails.
- NodeJS
- ExpressJS
- MongoDB
- Mongoose ODM
- jsonwebtoken
- bcryptjs
- OPEN AI
- Bing
- Cloudinary
- Nodemailer
- GoogleAPIs
Frontend | Backend |
---|---|
Anna Pestova | Aigul Yedigeyeva |
Anna Solovykh | Elena Cherpakova |
Elena Gornovoy | |
Svetlana Beynik |
We're always looking to improve and enhance our project. If you have suggestions, improvements, or find any bugs, please feel free to open a pull request or an issue on our GitHub repository.
Before submitting a pull request, please ensure the following:
- Your code is well-documented and follows the project's coding style.
- Your changes are well-tested and do not introduce new bugs.
- Include a detailed description of the changes you are proposing.
We appreciate all contributions and look forward to collaborating with you!
This project is available for use under the MIT License.