This document provides instructions on how to set up and run the DietBot application, including both the backend and frontend services.
-
Clone the repository:
git clone https://github.com/cdm-depaul/dietbot.git cd dietbot
-
Set up the Backend:
-
Navigate to the backend directory:
cd backend
-
Supabase Project Setup:
- Go to Supabase and create a new project or use an existing one.
- In your Supabase project dashboard, navigate to Project Settings > API.
- You will find your Project URL (this is your
SUPABASE_URL
) and the anon public key (this is yourSUPABASE_ANON_KEY
).
-
The backend requires these environment variables. Create a
.env
file by copying the example file:cp .env.example .env
-
Open the
.env
file and fill in the required values you obtained from your Supabase project:SUPABASE_URL
SUPABASE_ANON_KEY
- Also, configure your API keys for other services:
NUTRITIONIX_APP_ID
NUTRITIONIX_API_KEY
OLLAMA_MODEL
(optional, defaults todietbot
)OLLAMA_API_URL
(optional, defaults tohttp://host.docker.internal:11434/api/chat
)
-
Create your db tables in Supabase using these SQL commands:
CREATE TABLE IF NOT EXISTS public.user_profiles (
id BIGSERIAL PRIMARY KEY,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
name TEXT,
email TEXT UNIQUE,
daily_calorie_goal INTEGER,
age INTEGER,
sex TEXT,
height INTEGER,
weight REAL,
activity_level TEXT,
allergies TEXT[],
likes TEXT[],
dislikes TEXT[],
diet TEXT,
goal TEXT
);
CREATE TABLE IF NOT EXISTS public.chat_history (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL REFERENCES public.user_profiles(id) ON DELETE CASCADE,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
sender TEXT,
message TEXT
);
CREATE TABLE IF NOT EXISTS public.food_intake (
id BIGSERIAL PRIMARY KEY,
user_id BIGINT NOT NULL REFERENCES public.user_profiles(id) ON DELETE CASCADE,
created_at TIMESTAMPTZ NOT NULL DEFAULT now(),
food_item TEXT,
calories INTEGER,
protein_g NUMERIC,
carbs_g NUMERIC,
fat_g NUMERIC,
details JSONB
);
- Set up the Frontend:
- Navigate to the frontend directory (from the project root):
cd frontend
- Install the necessary Node.js dependencies:
npm install
- Navigate to the frontend directory (from the project root):
- Then, populate the supabase database:
Once your
.env
file is configured with the Supabase credentials, run the script to populate your database with initial schema and data. Make sure you are in thebackend
directory.bash python scripts/populate_supabase.py
This script will create necessary tables and insert some sample data.
- Navigate to the
backend
directory: - Start the backend services using Docker Compose:
(You can omit
docker-compose up --build
--build
on subsequent runs if the Docker image hasn't changed.) - The backend API will be running at
http://localhost:8001
.
- Navigate to the
frontend
directory: - Start the Next.js development server:
npm run dev
- The frontend application will be accessible at
http://localhost:3000
.
To start Ollama server:
ollama pull gemma3
ollama serve
Restart ollama if port is already in use.
Once both services are running, open your web browser and go to:
- Backend: In the terminal where
docker-compose up
is running, pressCtrl+C
. To stop and remove the containers, you can rundocker-compose down
from thebackend
directory. - Frontend: In the terminal where
npm run dev
is running, pressCtrl+C
.