Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
c6b9826
added icon
gyash1512 Jan 31, 2025
a335401
updated banners, footer, boxes
gyash1512 Jan 31, 2025
399db09
Add backend folder
rajanraj2 Feb 3, 2025
d2a4e05
auth added
gyash1512 Feb 3, 2025
5c69995
updated env
gyash1512 Feb 3, 2025
598fdbe
updated log
gyash1512 Feb 3, 2025
7f055a5
Add or update the Azure App Service build and deployment workflow config
gyash1512 Feb 4, 2025
64fb475
Update main_nutriback.yml
gyash1512 Feb 4, 2025
bb47125
Update main_nutriback.yml
gyash1512 Feb 4, 2025
8c8cad6
server and index updated
gyash1512 Feb 4, 2025
0cd8ff5
Merge branch 'main' of https://github.com/gyash1512/NutriGuide_ai
gyash1512 Feb 4, 2025
0b7865a
upd
gyash1512 Feb 4, 2025
a76e313
updated package
gyash1512 Feb 4, 2025
30b415e
refactor: use environment variables for Firebase configuration
gyash1512 Feb 4, 2025
57e08ea
fix: update CORS headers to include 'Origin' and 'X-Auth-Token'
gyash1512 Feb 4, 2025
7fe1214
Update main_nutriback.yml
gyash1512 Feb 4, 2025
f2c064c
Update main_nutriback.yml
gyash1512 Feb 4, 2025
111aaea
updated path in yml
gyash1512 Feb 4, 2025
1d36432
updated extraction in yml
gyash1512 Feb 4, 2025
a0db7ac
fix: update artifact names and paths in main_nutriback.yml
gyash1512 Feb 4, 2025
bdf4edb
fix: correct artifact paths in main_nutriback.yml and add directory v…
gyash1512 Feb 4, 2025
0afb46a
fix: update package path in main_nutriback.yml
gyash1512 Feb 4, 2025
e33f675
fix: update artifact download path in main_nutriback.yml
gyash1512 Feb 4, 2025
470cda9
fix: comment out directory verification step in main_nutriback.yml
gyash1512 Feb 4, 2025
1412235
fix: add Azure configuration step to automatically start Node.js app …
gyash1512 Feb 4, 2025
d3dbc9c
feat: add health check endpoint to server.js
gyash1512 Feb 4, 2025
8208176
feat: add IIS configuration for Node.js application in web.config
gyash1512 Feb 5, 2025
8835c95
fix: update IIS rewrite rules for Node.js application in web.config
gyash1512 Feb 5, 2025
f06b873
feat: enable ES Modules support in IIS configuration for Node.js appl…
gyash1512 Feb 5, 2025
8920f61
refactor: switch from ES Modules to CommonJS in server.js
gyash1512 Feb 5, 2025
fcde406
feat: migrate server.js to ES Modules and enhance CORS configuration;…
gyash1512 Feb 5, 2025
87adadf
feat: update token verification endpoint to use production URL and ad…
gyash1512 Feb 5, 2025
cde9a65
fix: update backend token verification endpoint URL in App.jsx
gyash1512 Feb 5, 2025
d05436d
fix: update CORS configuration to allow preflight requests and adjust…
gyash1512 Feb 5, 2025
09f912c
feat: integrate MongoDB for user management and enhance authenticatio…
gyash1512 Feb 8, 2025
a482bfb
fix: replace bcrypt with bcryptjs for compatibility and improve Mongo…
gyash1512 Feb 8, 2025
e57347a
feat: add user existence check before registration and update signup …
gyash1512 Feb 9, 2025
b8b4720
feat: implement MySQL integration for user management and add user an…
gyash1512 Feb 10, 2025
dd49d04
Support for chatbot and medical data analysis
gyash1512 Aug 4, 2025
ec7f607
Merge pull request #1 from gyash1512/feature/llm
gyash1512 Aug 4, 2025
340ddf7
updated headers
gyash1512 Aug 4, 2025
b1b44c2
moved from sql to mongo
gyash1512 Aug 5, 2025
1fc451b
avoid ngrok warning
gyash1512 Aug 5, 2025
e613c69
updated workflow and unused dependencies
gyash1512 Aug 5, 2025
931a98f
minor fix
gyash1512 Aug 5, 2025
0b92339
minor build change
gyash1512 Aug 5, 2025
d6d858e
updated readme
gyash1512 Aug 5, 2025
e9cc26d
Update README.md
gyash1512 Aug 5, 2025
2517b7d
minor change
gyash1512 Aug 5, 2025
17afa1d
Merge branch 'main' of https://github.com/gyash1512/NutriGuide_ai
gyash1512 Aug 5, 2025
b9d9776
minor fix in badge
gyash1512 Aug 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/workflows/main_nutriback.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and deploy Node.js app to Azure Web App - nutriback

on:
push:
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: windows-latest
permissions:
contents: read #This is required for actions/checkout

steps:
- uses: actions/checkout@v4

- name: Set up Node.js version
uses: actions/setup-node@v3
with:
node-version: '18.x'

- name: npm install, build, and test
run: |
# Build frontend
cd frontend
npm install
npm run build --if-present

# Build backend
cd ../backend
npm install
npm run build --if-present

- name: Upload artifact for deployment job
uses: actions/upload-artifact@v4
with:
name: node-app
path: .
if-no-files-found: error

- name: Verify artifact structure
run: ls -R
# deploy:
# runs-on: ubuntu-latest
# needs: build
# environment:
# name: 'Production'
# url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
# permissions:
# id-token: write #This is required for requesting the JWT
# contents: read #This is required for actions/checkout

# steps:
# - name: Download artifact from build job
# uses: actions/download-artifact@v4
# with:
# name: node-app
# path: .
# # - name: Verify directory structure
# # run: ls -R backend
# - name: Login to Azure
# uses: azure/login@v2
# with:
# client-id: ${{ secrets.AZUREAPPSERVICE_CLIENTID_C2BA3F7D4AB049E2B0647734EB5864AF }}
# tenant-id: ${{ secrets.AZUREAPPSERVICE_TENANTID_2AE5CA2A4AC04D8F82224F60376CE03E }}
# subscription-id: ${{ secrets.AZUREAPPSERVICE_SUBSCRIPTIONID_B38416D7C22E4DE297FCB4E97729CF9A }}

# - name: 'Deploy to Azure Web App'
# uses: azure/webapps-deploy@v3
# id: deploy-to-webapp
# with:
# app-name: 'nutriback'
# slot-name: 'Production'
# package: .
# - name: Configure Azure to start app
# run: |
# # Azure automatically runs 'npm start' if it's specified in your package.json
# echo "Setting up Node.js app to run automatically..."
# echo "node -v" # Optional: To check node version (confirm it’s installed)
# echo "npm start" # This is automatically triggered by Azure on deployment
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*/service_account.json
86 changes: 85 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,85 @@
# NutriGuide_ai
# NutriGuide AI

[![Vercel Deployment](https://img.shields.io/badge/Vercel-nutriguideai.vercel.app-black?style=for-the-badge&logo=vercel)](https://nutriguideai.vercel.app/)

NutriGuide AI is an intelligent nutrition assistant designed to provide personalized dietary guidance. It leverages the power of a powerful AI model to deliver meal plans, workout routines, and health summaries tailored to your unique medical data and preferences.

**Live Demo:** [nutriguideai.vercel.app](https://nutriguideai.vercel.app/)

## Key Features

* **AI-Powered Chatbot:** Get instant answers to your nutrition and fitness questions with our intelligent, streaming chatbot.
* **Personalized Diet Plans:** Receive custom 7-day diet plans based on your medical data, location, and dietary preferences.
* **Custom Workout Plans:** Get personalized 7-day workout plans that take into account your fitness level, goals, and medical history.
* **AI Health Summary:** Get a comprehensive, AI-generated summary of your health based on your medical records.
* **Secure Data Management:** All your data is securely stored in a unified MongoDB database.

## Architecture

### Frontend

The frontend is a modern, responsive single-page application built with React and Vite. For more details, see the [frontend README](./frontend/README.md).

### Backend

The backend is a robust Node.js application built with Express. It uses MongoDB for data storage and the Google Vertex AI SDK to interact with the AI model. For more details, see the [backend README](./backend/README.md).

### System Architecture Diagram

```mermaid
graph TD
A[User] -->|Interacts with| B(React Frontend);
B -->|API Calls| C(Node.js Backend);
C -->|Queries| D(MongoDB);
C -->|Prompts| E(AI API);
E -->|Responses| C;
D -->|Data| C;
```

### Database Schema

```mermaid
erDiagram
User {
string name
string email
string password
date dob
number weight
number height
string gender
}

MedicalData {
string email
object complete_blood_count
object lipid_panel
object liver_function
object kidney_function
object blood_sugar
object thyroid_function
object vitamin_levels
object inflammatory_markers
object coagulation_tests
object cancer_markers
string ai_health_summary
}

MealPlan {
string email
string plan
}

WorkoutPlan {
string email
string plan
}

User ||--o{ MedicalData : "has"
User ||--o{ MealPlan : "has"
User ||--o{ WorkoutPlan : "has"
```

## Deployment

The application can be configured for continuous deployment to Azure Web App using GitHub Actions. The workflow can be defined in `.github/workflows/main_nutriback.yml`.
138 changes: 138 additions & 0 deletions backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)
web_modules/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional stylelint cache
.stylelintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache

# Next.js build output
.next
out

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# vuepress v2.x temp and cache directory
.temp
.cache

# vitepress build output
**/.vitepress/dist

# vitepress cache directory
**/.vitepress/cache

# Docusaurus cache and generated files
.docusaurus

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
.env
config/serviceAccountKey.json
58 changes: 58 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# NutriGuide AI - Backend

This is the backend for the NutriGuide AI application, a robust Node.js application built with Express.

## Key Features

* **AI Integration:** Uses the Google Vertex AI SDK to interact with a powerful AI model for generating personalized diet plans, workout routines, and health summaries.
* **Secure Data Management:** All user data is securely stored in a unified MongoDB database.
* **RESTful API:** Provides a comprehensive RESTful API for the frontend to consume.

## Setup and Installation

### Prerequisites

* Node.js (v18.x or later)
* npm
* A Google Cloud Platform project with the Vertex AI API enabled
* A service account with the "Vertex AI User" role

### Installation

1. **Navigate to the `backend` directory:**
```bash
cd backend
```
2. **Install dependencies:**
```bash
npm install
```
3. **Create a `.env` file** and add the following environment variables:
```
MONGO_URI="your_mongodb_connection_string"
GOOGLE_APPLICATION_CREDENTIALS="path/to/your/service_account.json"
GCP_PROJECT_ID="your_gcp_project_id"
GCP_LOCATION="your_gcp_location"
FIREBASE_TYPE="service_account"
FIREBASE_PROJECT_ID="your_firebase_project_id"
FIREBASE_PRIVATE_KEY_ID="your_firebase_private_key_id"
FIREBASE_PRIVATE_KEY="your_firebase_private_key"
FIREBASE_CLIENT_EMAIL="your_firebase_client_email"
FIREBASE_CLIENT_ID="your_firebase_client_id"
FIREBASE_AUTH_URI="https://accounts.google.com/o/oauth2/auth"
FIREBASE_TOKEN_URI="https://oauth2.googleapis.com/token"
FIREBASE_AUTH_PROVIDER_X509_CERT_URL="https://www.googleapis.com/oauth2/v1/certs"
FIREBASE_CLIENT_X509_CERT_URL="your_firebase_client_x509_cert_url"
FIREBASE_UNIVERSE_DOMAIN="googleapis.com"
```
4. **Start the server:**
```bash
npm start
```

## Available Scripts

* `npm start`: Runs the app in production mode.
* `npm run dev`: Runs the app in development mode with nodemon.
* `npm test`: Placeholder for tests.
* `npm run build`: Placeholder for a build step.
22 changes: 22 additions & 0 deletions backend/config/db.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import mongoose from 'mongoose';
import dotenv from 'dotenv';

dotenv.config();

const connectDB = async () => {
try {
await mongoose.connect(process.env.MONGO_URI, {
useNewUrlParser: true,
useUnifiedTopology: true,
maxPoolSize: 10, // Set the maximum number of connections in the pool
serverSelectionTimeoutMS: 5000, // Keep trying to send operations for 5 seconds
socketTimeoutMS: 45000, // Close sockets after 45 seconds of inactivity
});
console.log('✅ Connected to MongoDB with connection pooling.');
} catch (err) {
console.error('❌ Failed to connect to MongoDB:', err.message);
process.exit(1);
}
};

export default connectDB;
Loading
Loading