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.
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
Backend/— FastAPI and MongoDB APIFrontend/— React web app and interactive presentationMobile/— Expo app showing the web app with native camera, microphone, and speech playbackdocker/and rootdocker-compose.yml— container builds and runtime configuration
Run these commands from the repository root.
python -m venv .venv
.venv\Scripts\Activate.ps1
python -m pip install -r Backend/requirements.txt
Copy-Item Backend/.env.example Backend/.envpython3 -m venv .venv
source .venv/bin/activate
python -m pip install -r Backend/requirements.txt
cp Backend/.env.example Backend/.envFill 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 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.
Before starting:
- Fill in
Backend/.env. - Put the trained model weights at the path configured by
MODEL_PATH. The video detector currently referencesBackend/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 8000Build 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.
In a second terminal, from the repository root:
cd Frontend
npm ci
npm run dev -- --hostOpen 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.
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.
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.
- Begin the presentation and press → to introduce the problem.
- Open Scan fridge in the phone. Press → to explain training and video tracking.
- Scan ingredients, tap Find Recipes, and review substitutions. Press → to explain them.
- Save a recipe, open Saved, and select it.
- Adjust Servings, open Steps, and use a voice control or send a question.
- Mark the recipe cooked, then open My inventory. Only opening the inventory screen reveals its presentation explanation.
- 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.
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.
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/.
In another terminal, from the repository root:
cd Mobile
npm ci
npx expo startScan 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.
- 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.
The image and JSON recipe endpoints live in Backend/routes/pipeline.py:
POST /recipes/from-image: multipartimageand optionaluser_query.POST /recipes/from-detections: JSONdetections.ingredientsentries withnameandconfidence, plus optionaluser_query.- Both return
detections, normalizedingredients, and the pipelineresult. no_recipes_foundis 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 requires a login token.
POST /scan: upload an image using the multipart fieldimage.POST /scan-video: upload a video using the multipart fieldvideo.
The scan results include detected ingredient names. Video scanning also produces tracking-based quantity estimates.
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.
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-linuxUse the same context throughout setup. Do not use sudo with this
Docker Desktop context.
Verify Docker:
docker version
docker compose versionAllow several GB of disk space for images, Ollama models, downloaded models, and the recipe index. Initial setup can take several minutes.
Run on any platform:
git clone --branch main --single-branch https://github.com/aisutd/nosh.git nosh-docker
cd nosh-docker
git rev-parse HEADRun all remaining Compose commands from this repository root.
Obtain the MongoDB connection string and trained weights privately from the team. Neither is included in Git.
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"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.
Start Ollama on your host computer, then install the required models:
ollama pull llama3.2
ollama pull gemma2
ollama listKeep 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.
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.serviceAdd:
[Service]
Environment="OLLAMA_HOST=0.0.0.0:11434"Then apply the change:
sudo systemctl daemon-reload
sudo systemctl restart ollamaUbuntu 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 serveThe 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.
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 psStop 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 --waitNormal restarts do not require initialization.
Default addresses:
- App: http://localhost:5173
- Presentation: http://localhost:5173/presentation
- API docs: http://localhost:8000/docs
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:
- Sign-in.
- Image and video scanning.
- Recipe search.
- Saving and opening recipes.
- Serving adjustments.
- Voice questions.
- Marking a recipe cooked and inventory deductions.
- 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.pyIt 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.
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.
$env:COMPOSE_PROJECT_NAME = "nosh-clean-check"
$env:NOSH_IMAGE_TAG = "clean-check"
$env:NOSH_FRONTEND_PORT = "5174"
$env:NOSH_BACKEND_PORT = "8001"export COMPOSE_PROJECT_NAME=nosh-clean-check
export NOSH_IMAGE_TAG=clean-check
export NOSH_FRONTEND_PORT=5174
export NOSH_BACKEND_PORT=8001Then 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 pscurl.exe --fail http://localhost:5174/api/health
curl.exe --fail --output NUL http://localhost:5174/presentationcurl --fail http://localhost:5174/api/health
curl --fail --output /dev/null http://localhost:5174/presentationOpen 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.
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.
For a normal restart:
docker compose up -d --waitAfter frontend or backend source changes:
docker compose up -d --build --waitAfter changing backend environment configuration:
docker compose up -d --force-recreate --waitFrontend 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 --waitDo not run init while the backend is using the same index volume.
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 the project:
docker compose downThis preserves the project's recipe index and model caches.
To intentionally remove those volumes as well:
docker compose down --volumesRemoving 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.
- Make a file in
Backend/routes/withrouter = APIRouter()and a function such as@router.post("/name"). - Register it in
Backend/main.py:app.include_router(yourfile.router). - Test it at http://localhost:8000/docs.
- Never commit
.envfiles 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/.