This is the backend API for the NutriHelp project. It exposes the REST endpoints used by the frontend, integrates with Supabase, serves OpenAPI documentation, and supports optional Python-based AI features used by some endpoints.
If you want the fastest setup path for local development:
git clone https://github.com/Gopher-Industries/Nutrihelp-api.git
cd Nutrihelp-api
npm install
pip install -r requirements.txtRequest the shared .env file from a project maintainer and place it in the project root, then start the backend:
npm startThe backend will be available at:
http://localhost:80http://localhost:80/api-docs
If you prefer Docker, jump to Docker Setup.
To run the full NutriHelp system locally, keep the frontend and backend repositories under the same parent folder:
NutriHelp/
├── Nutrihelp-web
└── Nutrihelp-api
Example:
mkdir NutriHelp
cd NutriHelp
git clone https://github.com/Gopher-Industries/Nutrihelp-web.git
git clone https://github.com/Gopher-Industries/Nutrihelp-api.gitcd Nutrihelp-apiInstall Node.js dependencies:
npm installInstall Python dependencies:
pip install -r requirements.txtPython dependencies are optional for some basic API flows, but recommended if you want the full backend runtime, including AI and image-classification features.
Request the shared .env file from a project leader or maintainer, then place it here:
Nutrihelp-api/.env
If you receive a file named env, rename it to .env.
If needed, create it manually:
touch .env
nano .envThe current backend expects these required values:
JWT_SECRETSUPABASE_URLSUPABASE_ANON_KEYSUPABASE_SERVICE_ROLE_KEYPORT
Common optional values:
SENDGRID_API_KEYFROM_EMAILNODE_ENVCORS_ORIGIN
npm startExpected local URLs:
- API base URL:
http://localhost:80 - API docs:
http://localhost:80/api-docs
To test the full NutriHelp app locally, run the frontend in a separate terminal:
cd Nutrihelp-web
npm install
npm startFrontend URL:
http://localhost:3000
After both frontend and backend are running, open:
http://localhost:3000
Typical manual checks:
- User registration
- Login
- MFA verification
Docker is supported as a full local development path for this backend. It is useful if you want the runtime dependencies installed inside the container instead of on your host machine.
From the Nutrihelp-api folder:
docker compose up --buildThe backend will be available at:
http://localhost:80http://localhost:80/api-docs
Notes:
- Docker Compose loads environment variables from
.env. - The default compose service builds the
devtarget from theDockerfile. - The compose setup mounts the source code, uploads, logs, and
node_modulesvolumes for development use.
Build the production image:
docker build -t nutrihelp-api --target prod .Run it:
docker run --rm -p 80:80 --env-file .env nutrihelp-apiIf Python or TensorFlow dependencies are problematic during image build, you can temporarily skip Python package installation for Node-only debugging:
docker build -t nutrihelp-api --target prod --build-arg INSTALL_PY_DEPS=false .This is for troubleshooting only and is not suitable for validating AI-related features.
curl http://localhost:80/api/system/healthdocker compose exec api python -c "import tensorflow as tf; print(tf.__version__)"
docker compose exec api python -c "import numpy, pandas, seaborn, sklearn, matplotlib; print('python-ai-runtime-ok')"docker compose exec api npm testRequired runtime components currently used by this repository:
| Component | Version / Source | Notes |
|---|---|---|
| Node.js | 22-bookworm image pinned by digest |
Backend runtime |
| Python | 3.11 via Debian Bookworm packages |
Used by AI routes |
| TensorFlow | 2.17.0 |
Image classification runtime |
| numpy | 1.26.4 |
TensorFlow-compatible numerical runtime |
| matplotlib | 3.9.2 |
Required by model/imageClassification.py imports |
| pandas | 2.2.3 |
Required by model/imageClassification.py imports |
| seaborn | 0.13.2 |
Required by model/imageClassification.py imports |
| scikit-learn | 1.5.2 |
Required by model/imageClassification.py imports |
| Pillow | 9.5.0 |
Image preprocessing |
| h5py | 3.10.0 |
Keras model loading |
| python-docx | 1.1.2 |
Document-processing utilities |
| build-essential | Debian package | Native build dependency for Python wheels |
Optional or troubleshooting-only runtime component:
| Component | Notes |
|---|---|
INSTALL_PY_DEPS=false build arg |
Lets the image build without Python AI dependencies for troubleshooting only |
You can validate the environment configuration with:
node scripts/validateEnv.jsThis script checks required variables, validates the JWT setup, and attempts a Supabase connection test.
The API contract is defined in index.yaml.
When the server is running, open:
http://localhost:80/api-docs
The current repository uses mocha for automated tests.
Run the full suite:
npm testRun unit tests only:
npm run test:unitUseful checks during development:
npm run lint
npm run format:check
npm run openapi:validate- If port
80is already in use, stop the conflicting process or change the port mapping indocker-compose.yml. - If the AI image build is slow, let the TensorFlow wheel finish downloading. The first build is much slower than rebuilds.
- If model-related endpoints fail, confirm the model file exists at prediction_models/best_model_class.hdf5.
- If environment validation fails, confirm that
.envexists in the project root and contains the required keys. - If Supabase-related requests fail immediately on startup, verify
SUPABASE_URLandSUPABASE_SERVICE_ROLE_KEY.
The AI service is optional for some development flows, but this repository includes AI-related code and runtime dependencies.
- Python packages are listed in requirements.txt.
- AI-related JavaScript code lives under ai.
- Python model scripts live under model.
- Model files are stored under prediction_models.
- Patch history is available in PatchNotes_VersionControl.yaml.
- Additional technical and security material is available under technical_docs and security.
This repository includes a render.yaml file that enables one-click deployment on Render.
-
Fork or use this repository — make sure the code is in a GitHub/GitLab repository connected to your Render account.
-
Connect the repository to Render — in the Render dashboard click New > Web Service, select your repository, and Render will auto-detect
render.yaml. -
Set environment variables — in the Render dashboard under Environment, add every variable listed in
.env.example. Variables markedsync: falseinrender.yamlmust be filled in manually:Variable Description SUPABASE_URLYour Supabase project URL SUPABASE_ANON_KEYSupabase anonymous/public key JWT_TOKENSecret used to sign JWT tokens SENDGRID_KEYSendGrid API key for email GMAIL_USERGmail address for Nodemailer GMAIL_APP_PASSWORDGmail app password for Nodemailer ALLOWED_ORIGINSComma-separated list of allowed frontend origins (e.g. https://nutrihelp.com,https://www.nutrihelp.com) -
Deploy — Render will run
npm installthennpm startautomatically.
Render confirms a successful deploy by polling:
GET /health
Expected response:
{ "status": "ok", "timestamp": "...", "uptime": 0 }Once deployed, the interactive API documentation is available at:
https://<your-service>.onrender.com/api-docs
Warning: Render uses an ephemeral filesystem. Any files written to the local
uploads/directory are permanently deleted on every deploy or restart. To persist user-uploaded files, migrate the upload destination to Supabase Storage or another external object store.