Visit our website 👇
Or watch our website and mobile demos.
We are Computer Engineering students studying at Boğaziçi University.
We are taking the course CmpE 451: Introduction to Software Engineering together.
To learn more about the team and the project, visit our Wiki Page.
- Project Overview
- Prerequisites
- Web Application
- Mobile Application
- Manual Development Setup
- Running Tests
- Contributing
NutriHub is a comprehensive platform that helps users discover and manage affordable and healthy food options. The project consists of three main components:
- Frontend: React + TypeScript + Vite
- Backend: Django REST Framework + MySQL
- Mobile App: React Native + Expo
Before you begin, ensure you have the following installed:
- Docker (20.10+) and Docker Compose (2.0+)
- For APK builds: Allocate at least 8GB RAM to Docker (Gradle build fails with OOM otherwise)
- macOS: Docker Desktop → Settings → Resources → Memory
- Windows: Docker Desktop → Settings → Resources → Memory
Optional (for manual development without Docker):
- Node.js (v20 or later)
- Python (3.11 or later)
- MySQL (8.0)
The easiest way to run the entire web application is using Docker Compose:
git clone https://github.com/bounswe/bounswe2025group9.git
cd bounswe2025group9Copy the example environment file and configure it:
cp .env.example .env
# Edit .env if needed (defaults work for local development)The provided .env.example contains sensible defaults for local development.
docker-compose up --build -dThis will start:
- Frontend at http://localhost:8080
- Backend API at http://localhost:8080/api/
- MySQL database (internal, port 3306)
See Database Population section below for two options to seed data.
- Open http://localhost:8080 in your browser
- Log in with default credentials
The web application uses environment variables defined in .env at the project root. Here's what each variable does:
| Variable | Default | Description |
|---|---|---|
BUILD |
DEV |
Build mode: DEV (http only) or PROD (https with redirect) |
PORT |
8080 |
Port for web hosting. Use 80 for production to enable http→https redirect |
| Variable | Default | Required | Description |
|---|---|---|---|
MYSQL_PASSWORD |
djangopass |
✓ | Password for MySQL user django |
MYSQL_ROOT_PASSWORD |
rootpass |
✓ | Password for MySQL root user |
Warning
Production Security: Use strong passwords in production! Change these defaults.
| Variable | Default | Required | Description |
|---|---|---|---|
DJANGO_SECRET_KEY |
super-secret-key |
✓ | Django secret key for cryptographic signing |
Warning
Production Security: Generate a unique secret key for production deployments.
These are optional for basic functionality but required for specific features:
| Variable | Default | Required | Description |
|---|---|---|---|
FATSECRET_CONSUMER_KEY |
(empty) | ✗ | FatSecret API key (for external food database) |
FATSECRET_CONSUMER_SECRET |
(empty) | ✗ | FatSecret API secret |
FAL_KEY |
(empty) | ✗ | Fal AI key (for AI image generation) |
CLOUDINARY_CLOUD_NAME |
(empty) | ✗ | Cloudinary cloud name (for image storage) |
CLOUDINARY_API_KEY |
(empty) | ✗ | Cloudinary API key |
CLOUDINARY_API_SECRET |
(empty) | ✗ | Cloudinary API secret |
FatSecret API Setup (optional):
- Create an account at FatSecret Platform API
- Get your consumer key and secret
- Add to
.envorbackend/.env.example
See backend/.env.example for additional backend-specific configuration options.
After starting the services, you need to populate the database. Choose one of two options:
The repository includes a complete database backup with users, foods, recipes, and posts.
Location: backup/nutrihub-db-backup.zip
Restore steps:
# 1. Unzip the backup file
cd backup
unzip nutrihub-db-backup.zip
# 2. Restore using docker exec (pipe SQL into container)
docker exec -i mysql-db mysql -udjango -pdjangopass mydb < nutrihub-db-backup.sqlAlternative using root user:
docker exec -i mysql-db mysql -uroot -prootpass mydb < nutrihub-db-backup.sqlNote
This is a destructive restore - existing tables in mydb will be dropped and recreated.
For more restore options, see backup/README.md.
Django migrations automatically create the schema and seed essential data:
# Migrations run automatically when backend container starts
# To run manually:
docker exec -it django-app python manage.py migrateWhat gets seeded automatically:
- ✓ Database schema (all tables)
- ✓ Default forum tags (Dietary tip, Recipe, Meal plan)
- ✓ Sample recipes with ingredients
- ✓ Default users (admin + demo user)
Loading additional food data (optional):
The database backup already contains ~500 foods. To load more from JSON:
# Load foods from JSON file
docker exec -it django-app python api/db_initialization/load_food_from_json.py \
api/db_initialization/NewFoodDatabase.json --limit 1000 --skip-errorsSee backend/api/db_initialization/readme.md for more details.
After seeding (either via backup or migrations), you can log in with these pre-created users:
| Role | Username | Password | Capabilities | |
|---|---|---|---|---|
| Admin | admin |
admin123 |
[email protected] | Full access, staff privileges, food moderation |
| Regular User | demo |
demo123 |
[email protected] | Standard user access |
Tip
Use the admin account to access the admin panel at http://localhost:8080/api/admin/ and moderate food proposals, manage users, etc.
For production deployment with HTTPS:
Edit .env:
export BUILD=PROD # Use production nginx config (https)
export PORT=80 # Allow http→https redirect
export MYSQL_PASSWORD="your-strong-password"
export MYSQL_ROOT_PASSWORD="your-strong-root-password"
export DJANGO_SECRET_KEY="your-random-secret-key-generate-this"Caution
Security Critical: Always use strong, random passwords and secret keys in production!
NutriHub uses Let's Encrypt for free SSL certificates via Certbot.
First, start the app in development mode to expose port 80:
# Temporarily use DEV mode with PORT=80
BUILD=DEV PORT=80 docker-compose up --build -dRun Certbot to obtain certificates:
sudo docker run --rm \
-v $(pwd)/certbot/www:/var/www/certbot \
-v $(pwd)/certbot/conf:/etc/letsencrypt \
certbot/certbot certonly \
--webroot \
--webroot-path=/var/www/certbot \
--email [email protected] \
--agree-tos \
--no-eff-email \
-d nutrihub.fit \
-d www.nutrihub.fitNote
Replace [email protected] and domain names with your actual values.
Certificates will be stored in certbot/conf/.
# Update .env: BUILD=PROD, PORT=80
docker-compose down
docker-compose up --build -dYour application is now running with HTTPS! 🎉
The mobile app needs to know where your backend API is located.
cd mobile/nutrihub
cp .env.example .envEdit mobile/nutrihub/.env and set API_BASE_URL:
For production (deployed server):
API_BASE_URL=https://nutrihub.fit/apiFor local development (Docker backend on your machine):
# Replace YOUR_LOCAL_IP with your computer's local network IP
API_BASE_URL=http://192.168.1.100:8080/apiImportant
Finding your local IP:
- macOS: System Preferences → Network, or run
ipconfig getifaddr en0 - Windows: Run
ipconfigand look for IPv4 Address - Linux: Run
hostname -Iorip addr show
See Network Configuration below for detailed guidance.
cd mobile/nutrihub
npm installMake sure .env points to your backend (see above).
npm run dev- Android Emulator: Press
ain the Expo terminal - iOS Simulator (macOS only): Press
iin the Expo terminal - Physical Device: Scan QR code with Expo Go app
Tip
Your device/emulator must be able to reach the backend API. See Network Configuration.
We have a github action that builds the apk for you. You can trigger it by going to the actions tab and selecting "Apk Builder" workflow. Then click on "Run workflow" button.
Docker ensures a consistent build environment and handles all dependencies.
Prerequisites: Docker with 8GB+ RAM allocated
cd mobile/nutrihub
# Build the Docker image
docker build -t nutrihub-apk .
# Create a temporary container
docker create --name nutrihub-temp nutrihub-apk
# Extract the APK
docker cp nutrihub-temp:/app/android/app/build/outputs/apk/release/app-release.apk ./nutrihub.apk
# Clean up
docker rm nutrihub-tempTroubleshooting:
- If build fails with "Gradle daemon disappeared", increase Docker memory to 8GB+
- Restart Docker Desktop after changing memory allocation
If you can't use Docker, you can build manually:
Prerequisites:
- Node.js 20+
- Java JDK 17+
- Android SDK (via Android Studio)
cd mobile/nutrihub
# Install dependencies
npm install
# Generate native Android project
npx expo prebuild --platform android --clean
# Build release APK
./gradlew assembleRelease
# APK output location:
# android/app/build/outputs/apk/release/app-release.apkTip
Pre-built APK Available: Download the compiled .apk file directly from GitHub Releases!
- Go to Releases
- Find the release tagged
customer-milestone-3 - Download
nutrihub.apkfrom the release assets - Install on your Android device
- Enable "Install from Unknown Sources" in Android settings
- Transfer the APK to your device
- Open the APK file to install
- Launch NutriHub!
If you prefer to run components individually without Docker:
Note
Assumes MySQL database is available and running with django@localhost user and mydb database.
cd backend
# Create and activate virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements-dev.txt
# Set up environment variables
source setup.sh # On Windows: .\setup.sh
# Run migrations
python manage.py makemigrations
python manage.py migrate
# Start development server
python manage.py runserver 9000Backend API will be available at http://localhost:9000/api/
cd frontend
# Install dependencies
npm install
# Start development server
npm startFrontend will be available at http://localhost:5173/ (or similar Vite port).
Configure API endpoint:
Set VITE_API_BASE_URL environment variable:
export VITE_API_BASE_URL="http://localhost:9000/api"
npm startcd mobile/nutrihub
# Install dependencies
npm install
# Configure backend URL in .env
echo "API_BASE_URL=http://YOUR_LOCAL_IP:9000/api" > .env
# Start development server
npm run devcd backend
python manage.py testcd frontend
npm testcd mobile/nutrihub
npm test- Create a new branch for your feature
- Make your changes
- Run tests to ensure everything works
- Submit a pull request
See our Wiki for contribution guidelines.
This project is part of the CmpE 451 course at Boğaziçi University.