This repository contains the backend service for the FoodSnap application. The backend service is built with Node.js, Express, and deployed on Google Cloud App Engine. It handles user authentication, food prediction, and history tracking.
- Prerequisites
- Installation
- Running the Application Locally
- Deployment
- API Endpoints
- Environment Variables
- Node.js (14 or higher)
- npm (6 or higher)
- Google Cloud Project with App Engine, Cloud Storage, Firestore enabled
- Clone the repository
git clone https://github.com/your-username/foodsnap-backend.git cd foodsnap-backend
- Install Dependencies
npm install
- Create a .env file in the root directory and add the following environment variables
GCLOUD_PROJECT_ID=your_gcloud_project_id GCLOUD_KEY_FILE=/path/to/serviceAccountKey.json GCLOUD_STORAGE_BUCKET=your_gcloud_storage_bucket_name JWT_SECRET=your_jwt_secret PORT=8080
- Start the application
npm run start
- Access the application Open your browser and navigate to http://localhost:8080
- Activate Cloud App Engine
- Create app.yaml file
- Deploy using Google Cloud CLI
gcloud app deploy
- POST /signup - Register a new user
- POST /login - Authenticate a user and return a token
- GET /profile - Get the user profile
- PUT /edit-profile - Update the user profile
- PUT /change-password - Change the user password
- GET /food - Get the list of food
- GET /food/{id} - Get Food Detail with id
- POST /predict - Preduct the food image and return food data
- GET /history - Get the user's food history
- POST /save - Save the prediction result to history
Make sure to set the following environment variables in your .env file or through your deployment platform:
- GCLOUD_PROJECT_ID : your Google Cloud Project ID
- GCLOUD_KEY_FILE : Path to your Google Cloud Service Account Key
- GCLOUD_STORAGE_BUCKET: Name of your Google Cloud Storage Bucket
- JWT_SECRET : Secret key for JWT authentication
- PORT : Port in which the app will run (default is 8080)