Skip to content
This repository was archived by the owner on Dec 2, 2026. It is now read-only.
aisutdPublic archive

About

AIM Fall 2026: NOSH — AI-powered student cooking assistant.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

NOSH

One app, one launch path

Use the repository-root Backend/ and Frontend/. Voice, memory, personalization, inventory, substitutions, and serving controls run together there. The old nested nosh-backend/ app has been consolidated and removed. Stop old backend and Vite processes before starting this checkout.

Description

NOSH is an AI-powered student cooking assistant that turns ingredients from a refrigerator photo or video into practical, budget-friendly meals. It combines ingredient detection, recipe retrieval, and a voice interface for cooking questions, substitutions, and step-by-step guidance.

Technologies include:

  • Python and JavaScript
  • React and Vite
  • Three.js, React Three Fiber, and Drei
  • FastAPI and MongoDB
  • YOLO, OpenCV, and EasyOCR
  • Hybrid RAG and vector search
  • Speech-to-text and text-to-speech

Project folders

  • Backend/ — FastAPI and MongoDB API
  • Frontend/ — React web app and interactive presentation
  • Mobile/ — Expo app showing the web app with native camera, microphone, and speech playback
  • docker/ and root docker-compose.yml — container builds and runtime configuration

Setup

Run these commands from the repository root.

Windows PowerShell

python -m venv .venv
.venv\Scripts\Activate.ps1
python -m pip install -r Backend/requirements.txt
Copy-Item Backend/.env.example Backend/.env

macOS / Linux

python3 -m venv .venv
source .venv/bin/activate
python -m pip install -r Backend/requirements.txt
cp Backend/.env.example Backend/.env

Fill in Backend/.env with your own configuration. If it already exists, skip the copy command to keep your existing configuration.

MongoDB and SECRET_KEY must be configured before running the app.

Secret key

SECRET_KEY signs the login tokens. Generate your own with:

python -c "import secrets; print(secrets.token_hex(32))"

Copy the output into Backend/.env as SECRET_KEY=....

Get the MONGO_URI connection string privately from the team. It contains database credentials.

Set up RAG and run the backend

Before starting:

  • Fill in Backend/.env.
  • Put the trained model weights at the path configured by MODEL_PATH. The video detector currently references Backend/models/best (1).pt.
  • Start Ollama with the models required by the backend configuration.

From the repository root, with your virtual environment activated:

cd Backend
python -m rag.build_embeddings
python -m uvicorn main:app --reload --host 0.0.0.0 --port 8000

Build the recipe index on first setup or when the recipe data changes. For later launches, skip python -m rag.build_embeddings.

API docs: http://localhost:8000/docs

Health check: http://localhost:8000/health

The health check should list recipes, inventory, voice, and memory.

Run the web app

In a second terminal, from the repository root:

cd Frontend
npm ci
npm run dev -- --host

Open http://localhost:5173 in Google Chrome.

Vite uses port 5173 strictly so a second accidental launch fails instead of silently opening another app on 5174.

VITE_API_URL can override the backend address. Restart Vite after changing it.

Presentation demo

NOSH includes an interactive presentation with a live app displayed inside an animated 3D phone built with Three.js, React Three Fiber, and Drei.

After starting the web app, open:

http://localhost:5173/presentation

Keep the backend running to use scanning, recipe generation, inventory, and voice.

Guided walkthrough

Open Preparation → Open live phone to sign in before presenting. Use Check / Retry readiness to check backend reachability and sign-in. The health endpoint alone does not verify MongoDB, model files, or Ollama. Prepare a scan photo/video and test microphone permissions before the talk.

  1. Begin the presentation and press → to introduce the problem.
  2. Open Scan fridge in the phone. Press → to explain training and video tracking.
  3. Scan ingredients, tap Find Recipes, and review substitutions. Press → to explain them.
  4. Save a recipe, open Saved, and select it.
  5. Adjust Servings, open Steps, and use a voice control or send a question.
  6. Mark the recipe cooked, then open My inventory. Only opening the inventory screen reveals its presentation explanation.
  7. Press → for the future of NOSH, then the thank-you screen.

Hide bar hides the top controls; use the small Show bar button to restore them. H toggles the bar when focus is outside the phone and text fields.

← / → navigate explanations. At action checkpoints, → shows what to do in the phone instead of skipping ahead. Click outside the phone and controls before using arrow keys. Press End to jump to the wrap-up if you need to finish early.

Use sample demo starts a separate, clearly labeled tomato-pasta walkthrough. Its scanning and voice replies are simulated; it makes no backend requests and never changes your account or real inventory. Reset sample clears sample state only. Return to live app restores the still-mounted live phone; any live voice conversation is paused when switching to samples. Reset presentation resets the talk without clearing the live app.

Presentation checks

With Vite running, run node Frontend/tests/presentation-smoke.cjs from the repo root with NODE_PATH pointing to a Playwright installation and Chrome installed. For Docker, set NOSH_TEST_ORIGIN=http://127.0.0.1:5173 and NOSH_TEST_API_PREFIX=/api when running the same command (adjust the port if needed). The test uses isolated API fixtures, not a real account, and covers the live UI walkthrough, retry states, sample isolation/reset, inventory gating, keyboard navigation, and desktop/mobile layouts.

Dependencies

The presentation dependencies are included in Frontend/package.json and installed by npm ci.

When changing dependencies, commit both Frontend/package.json and Frontend/package-lock.json. Do not commit node_modules/.

Run the phone app

In another terminal, from the repository root:

cd Mobile
npm ci
npx expo start

Scan the QR code with a compatible version of Expo Go. Phone and laptop must be on the same Wi-Fi, and the backend and frontend must both be running.

Update the addresses in Mobile/App.js to match your laptop's local IP address. On Windows, use ipconfig to find it. Make sure the frontend origin is allowed by the CORS configuration in Backend/main.py.

Voice on web and mobile

  • The website uses browser speech recognition to turn speech into text.
  • The Expo app records audio and sends it to POST /voice/transcribe.
  • Both send the resulting text and cooking context to POST /voice/turn.
  • Web replies use browser text-to-speech; mobile replies use native speech playback.

Browser microphone access requires HTTPS or localhost. Opening the website over a plain HTTP LAN address on a phone may disable browser microphone access.

Mobile transcription requires DEEPGRAM_API_KEY in Backend/.env.

Voice uses the same signed-in user and current pantry as the rest of the app. Do not run the desktop voice script for the web or Expo app.

Desktop users may still run voice-agent/voice_agent.py.

Recipe endpoints

The image and JSON recipe endpoints live in Backend/routes/pipeline.py:

  • POST /recipes/from-image: multipart image and optional user_query.
  • POST /recipes/from-detections: JSON detections.ingredients entries with name and confidence, plus optional user_query.
  • Both return detections, normalized ingredients, and the pipeline result.
  • no_recipes_found is a valid result when no source satisfies ingredient constraints.

The root nosh_pipeline.py is a compatibility entry point delegating to Backend/nosh_pipeline.py.

Root requirements.txt is for evaluation tooling; Backend/requirements.txt is for the web application.

Scanning endpoints

Scanning requires a login token.

  • POST /scan: upload an image using the multipart field image.
  • POST /scan-video: upload a video using the multipart field video.

The scan results include detected ingredient names. Video scanning also produces tracking-based quantity estimates.

Docker setup — Windows, Linux, and macOS

Docker runs the frontend and backend. MongoDB remains external, and Ollama runs on your host computer.

You do not need a local Python virtual environment or node_modules. The images include Node 22, Python 3.13, and CPU-based detection.

See recorded verification for tested environments and results. Instructions alone do not establish that a platform has passed runtime testing.

1. Install and start prerequisites

Install:

  • Git
  • Docker Desktop with Docker Compose v2
  • Ollama

Start Docker Desktop before continuing.

Windows: Use Docker Desktop with its WSL 2 backend and Linux containers. Run the Windows commands below in PowerShell.

macOS: Start Docker Desktop and the Ollama application. Run commands in Terminal.

Linux: These instructions cover Docker Desktop on Ubuntu. Run commands in Bash. Standalone Docker Engine requires separate networking configuration and validation.

On Linux, select Docker Desktop's context:

docker context use desktop-linux

Use the same context throughout setup. Do not use sudo with this Docker Desktop context.

Verify Docker:

docker version
docker compose version

Allow several GB of disk space for images, Ollama models, downloaded models, and the recipe index. Initial setup can take several minutes.

2. Clone the repository

Run on any platform:

git clone --branch main --single-branch https://github.com/aisutd/nosh.git nosh-docker
cd nosh-docker
git rev-parse HEAD

Run all remaining Compose commands from this repository root.

3. Configure secrets and model weights

Obtain the MongoDB connection string and trained weights privately from the team. Neither is included in Git.

Windows — PowerShell

Copy-Item Backend/.env.example Backend/.env
New-Item -ItemType Directory -Force Backend/models
Copy-Item "C:\path\to\best.pt" "Backend/models/best (1).pt"

macOS / Linux — Terminal or Bash

cp Backend/.env.example Backend/.env
mkdir -p Backend/models
cp "/absolute/path/to/best.pt" "Backend/models/best (1).pt"

Replace the source model path with its actual location. Skip the .env copy if that file already exists.

Edit Backend/.env and configure:

  • MONGO_URI: the team's MongoDB connection string.
  • SECRET_KEY: a private random signing key.
  • DEEPGRAM_API_KEY: optional; required for native mobile transcription.

Generate a signing key on any platform without installing Python locally:

docker run --rm python:3.13-slim-bookworm python -c "import secrets; print(secrets.token_hex(32))"

Copy the output into Backend/.env as SECRET_KEY=....

Both image and video detection require this exact destination:

Backend/models/best (1).pt

Compose mounts it read-only at /app/models/best (1).pt. MongoDB Atlas must allow your network and account.

Never commit secrets, tokens, or model weights. Do not share docker compose config output; it can contain resolved secrets.

4. Prepare Ollama

Start Ollama on your host computer, then install the required models:

ollama pull llama3.2
ollama pull gemma2
ollama list

Keep Ollama running while using NOSH. If running ollama serve in a terminal, leave that terminal open. Do not start another server on an already occupied port.

Containers connect to:

http://host.docker.internal:11434

The readiness command in the next section verifies this connection from inside Docker.

If Docker cannot reach Ollama

Ollama's listening address is controlled by OLLAMA_HOST. Changing it to 0.0.0.0:11434 also exposes it on host network interfaces; restrict access with your firewall.

Windows: Quit Ollama from the system tray. Add this user environment variable through “Edit environment variables for your account,” then restart Ollama:

OLLAMA_HOST=0.0.0.0:11434

macOS: Set the variable, then quit and reopen the Ollama application:

launchctl setenv OLLAMA_HOST "0.0.0.0:11434"

Linux with a systemd Ollama service: Run:

sudo systemctl edit ollama.service

Add:

[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"

Then apply the change:

sudo systemctl daemon-reload
sudo systemctl restart ollama

Ubuntu Snap installation used during project testing: If Ollama is not already serving, run this in a separate terminal:

OLLAMA_HOST=0.0.0.0:11434 OLLAMA_MODELS=/var/snap/ollama/common/models ollama serve

The Snap model path applies only to that installation. Keep the terminal open and verify that ollama list shows both required models.

See Ollama configuration and Docker Desktop networking for additional troubleshooting.

5. Build, initialize, and start

These commands work in PowerShell, Bash, and macOS Terminal:

docker compose build --pull --no-cache
docker compose run --rm init
docker compose run --rm readiness
docker compose up -d --wait
docker compose ps

Stop and resolve any failed initialization or readiness check before continuing.

init builds the recipe index from the tracked CSV and downloads embedding and OCR models into named volumes.

Run initialization:

  • On first setup.
  • After changing recipe data.
  • After deleting the project's index or model-cache volumes.

Stop the backend before rebuilding an existing index:

docker compose stop backend
docker compose run --rm init
docker compose run --rm readiness
docker compose up -d --wait

Normal restarts do not require initialization.

6. Open and verify the app

Default addresses:

Use Google Chrome for browser voice testing and allow microphone access.

The frontend proxies /api requests to the backend.

Container health checks confirm HTTP startup. The separate readiness command checks configuration, MongoDB access, Ollama models, detection weights, recipe retrieval, and OCR models.

Use a dedicated test account to verify:

  1. Sign-in.
  2. Image and video scanning.
  3. Recipe search.
  4. Saving and opening recipes.
  5. Serving adjustments.
  6. Voice questions.
  7. Marking a recipe cooked and inventory deductions.
  8. Refreshing /presentation.

A healthy container alone does not prove these flows work.

An optional API smoke check is available:

docker compose exec backend python scripts/smoke.py

It creates a temporary test account and exercises the API with synthetic uploads. It does not test a real microphone or photo detection accuracy. Shared recipe sources saved through the normal API remain.

7. Verify an isolated fresh clone

Use a second clone and supply only the private configuration and weights. Do not copy .venv, node_modules, dist, or an existing Chroma index.

Set these variables in the terminal where you will run Compose.

Windows — PowerShell

$env:COMPOSE_PROJECT_NAME = "nosh-clean-check"
$env:NOSH_IMAGE_TAG = "clean-check"
$env:NOSH_FRONTEND_PORT = "5174"
$env:NOSH_BACKEND_PORT = "8001"

macOS / Linux — Terminal or Bash

export COMPOSE_PROJECT_NAME=nosh-clean-check
export NOSH_IMAGE_TAG=clean-check
export NOSH_FRONTEND_PORT=5174
export NOSH_BACKEND_PORT=8001

Then run on any platform:

git rev-parse HEAD
docker compose build --pull --no-cache
docker compose run --rm init
docker compose run --rm readiness
docker compose up -d --wait
docker compose ps

Windows checks

curl.exe --fail http://localhost:5174/api/health
curl.exe --fail --output NUL http://localhost:5174/presentation

macOS / Linux checks

curl --fail http://localhost:5174/api/health
curl --fail --output /dev/null http://localhost:5174/presentation

Open http://localhost:5174/presentation and repeat the app walkthrough.

Record the commit, operating system, build result, readiness results, and any failed flows in docs/docker-validation.md.

These environment variables apply to the current terminal session. Set them again if you open another terminal to manage this test project.

Configuration

Compose supports shell variables or entries in a private repository-root .env file. Backend/.env contains backend application secrets.

Variable Default Purpose
NOSH_ENV_FILE ./Backend/.env Backend secrets file
NOSH_MODEL_PATH ./Backend/models/best (1).pt Host model weights
NOSH_OLLAMA_HOST http://host.docker.internal:11434 Ollama address from containers
NOSH_FRONTEND_PORT 5173 Local frontend port
NOSH_BACKEND_PORT 8000 Local backend port
NOSH_IMAGE_TAG local Image tag
COMPOSE_PROJECT_NAME Derived from folder Container and volume isolation

Ports bind to localhost. This configuration does not expose the app to a physical phone over Wi-Fi; use the development setup for that.

For occupied ports, use the overrides above.

Updating and restarting

For a normal restart:

docker compose up -d --wait

After frontend or backend source changes:

docker compose up -d --build --wait

After changing backend environment configuration:

docker compose up -d --force-recreate --wait

Frontend VITE_* settings are build-time settings and require rebuilding the frontend.

After recipe CSV changes, rebuild the backend image and index:

docker compose stop backend
docker compose build backend
docker compose run --rm init
docker compose run --rm readiness
docker compose up -d --wait

Do not run init while the backend is using the same index volume.

Logs and troubleshooting

docker compose logs --tail=100 frontend backend
docker compose run --rm readiness
  • MongoDB failure: check credentials, network allowlisting, and permissions.
  • Missing detection weights: verify the exact host filename and mount path.
  • Missing index or OCR models: run initialization.
  • Ollama failure: confirm both models are installed and reachable from Docker.
  • Slow generation: check ollama ps; CPU inference can take substantially longer than GPU inference.

Keep Docker Desktop and Ollama running while using the app.

Stop and cleanup

Stop the project:

docker compose down

This preserves the project's recipe index and model caches.

To intentionally remove those volumes as well:

docker compose down --volumes

Removing volumes requires initialization again. It does not delete MongoDB data or host model weights.

Do not use global Docker prune commands to clean up this project.

Adding an endpoint

  1. Make a file in Backend/routes/ with router = APIRouter() and a function such as @router.post("/name").
  2. Register it in Backend/main.py: app.include_router(yourfile.router).
  3. Test it at http://localhost:8000/docs.

Rules

  • Never commit .env files or API keys.
  • Keep private model weights and generated scan outputs out of commits.
  • Commit dependency manifests and lockfiles when dependencies change.
  • Do not commit virtual environments or node_modules/.

About

AIM Fall 2026: NOSH — AI-powered student cooking assistant.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages