CMPE352/451 Group 1 - A comprehensive application for planning and managing community gardens.
- Overview
- Prerequisites
- Project Structure
- Setup Instructions
- Docker Deployment
- Configuration
- Troubleshooting
The Garden Planner is a full-stack application consisting of:
- Backend: Django REST Framework API with PostgreSQL database
- Frontend: React web application with Vite
- Mobile: React Native mobile app using Expo
Features include:
- User authentication and profiles
- Garden creation and management
- Task assignment and tracking
- Community forum and messaging
- Real-time notifications via Firebase
- Badge system for user achievements
Before you begin, ensure you have the following installed:
- Python 3.8+ - Download
- Node.js 18+ and npm - Download
- PostgreSQL 15+ - Download
- Git - Download
- Expo CLI (for mobile development) - Install via npm
- Firebase Account - Create account
- Docker & Docker Compose - Download
- Android Studio - For Android emulator
- Xcode - For iOS simulator (macOS only)
bounswe2025group1/
├── gardenPlannerBackend/ # Django backend
├── frontend/ # React frontend
├── MOBILE/ # React Native mobile app
│ └── CommunityGardenApp/
├── docker-compose.yml # Docker orchestration
└── README.md # This file
cd gardenPlannerBackend# Create virtual environment
python3 -m venv venv
# Activate on macOS/Linux
source venv/bin/activate
# Activate on Windows
venv\Scripts\activatepip install -r requirements.txtCreate a .env file in the gardenPlannerBackend directory:
DEBUG=True
SECRET_KEY=your-secret-key-here
DB_NAME=gardenplanner
DB_USER=postgres
DB_PASSWORD=postgres
DB_HOST=localhost
DB_PORT=5432
FIREBASE_SERVICE_ACCOUNT_KEY=firebase-service-account.json- Go to Firebase Console
- Select your project
- Go to Project Settings > Service Accounts
- Click "Generate New Private Key"
- Save the JSON file as
firebase-service-account.jsoningardenPlannerBackend/
# Create database (run in PostgreSQL shell or use pgAdmin)
createdb gardenplanner
# Or connect to PostgreSQL and run:
# CREATE DATABASE gardenplanner;python manage.py migratepython manage.py createsuperuserpython manage.py runserverThe backend API will be available at http://127.0.0.1:8000/
Admin panel: http://127.0.0.1:8000/admin/
API documentation: http://127.0.0.1:8000/swagger/
cd frontendnpm installCreate a .env file in the frontend directory:
VITE_API_URL=http://localhost:8000
VITE_FIREBASE_API_KEY=your-firebase-api-key
VITE_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
VITE_FIREBASE_PROJECT_ID=your-project-id
VITE_FIREBASE_STORAGE_BUCKET=your-project.appspot.com
VITE_FIREBASE_MESSAGING_SENDER_ID=your-sender-id
VITE_FIREBASE_APP_ID=your-app-idnpm run devThe frontend will be available at http://localhost:5173/
npm run buildcd MOBILE/CommunityGardenAppnpm installCreate a .env file in the MOBILE/CommunityGardenApp directory:
EXPO_PUBLIC_API_URL=http://your-backend-ip:8000
EXPO_PUBLIC_FIREBASE_API_KEY=your-firebase-api-key
EXPO_PUBLIC_FIREBASE_AUTH_DOMAIN=your-project.firebaseapp.com
EXPO_PUBLIC_FIREBASE_PROJECT_ID=your-project-id
EXPO_PUBLIC_FIREBASE_STORAGE_BUCKET=your-project.appspot.com
EXPO_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your-sender-id
EXPO_PUBLIC_FIREBASE_APP_ID=your-app-idNote: For mobile testing on physical devices, replace localhost with your computer's local IP address (e.g., 192.168.1.100).
- Go to Firebase Console
- Add Android and/or iOS apps to your project
- Download
google-services.json(Android) and/orGoogleService-Info.plist(iOS) - Follow Expo Firebase setup guide: Expo Firebase Docs
npx expo start- Press
a- Open on Android emulator - Press
i- Open on iOS simulator (macOS only) - Press
w- Open in web browser - Scan QR code with Expo Go app on physical device
# Android
npx expo build:android
# iOS
npx expo build:iosRun all services (backend, frontend, mobile, and PostgreSQL) using Docker:
Make sure you have .env files in:
gardenPlannerBackend/.envfrontend/.envMOBILE/CommunityGardenApp/.env
docker-compose up --build- Frontend: http://localhost (port 80)
- Backend API: http://localhost:8000
- Mobile: Expo DevTools at http://localhost:19000
- PostgreSQL: localhost:5433
docker-compose down# All services
docker-compose logs
# Specific service
docker-compose logs backend
docker-compose logs frontend
docker-compose logs mobileIf you intend to serve the frontend over HTTPS with the included Nginx config:
- Point your domain's A record to the host running Docker.
- Obtain Let's Encrypt certificates (on the host, not inside the container):
sudo certbot certonly --standalone \
-d yourdomain.example \
--email [email protected] \
--agree-tos --non-interactive- Ensure the certificates are available at
/etc/letsencrypt/live/yourdomain.example/and mount that path (read-only) into the frontend container (already configured as/etc/letsencrypt). - Fix permissions if the key cannot be read:
sudo chmod 644 /etc/letsencrypt/live/yourdomain.example/fullchain.pem
sudo chmod 600 /etc/letsencrypt/live/yourdomain.example/privkey.pem- Test renewal:
sudo certbot renew --dry-runWindows / WSL: Use WSL (Ubuntu) to run certbot so certificates reside under /etc/letsencrypt/ in the WSL filesystem for Docker to mount. Plain Windows paths like C:\... will not map directly.
For purely local docker testing without certificates:
- Edit
frontend/nginx.confand remove the redirect server block. - Change the HTTPS server block to listen on port 80 only and remove all
ssl_*directives. - Rebuild:
docker-compose up --buildThen access via http://localhost.
- PostgreSQL data:
postgres_datanamed volume. - Django static files:
static_volume(aftercollectstatic). - Django media uploads:
media_volume. Recreation of containers will not delete data stored in these volumes; usedocker volume lsanddocker volume rmto manage manually.
| Issue | Cause | Fix |
|---|---|---|
SSL: no such file |
Certificates not mounted or wrong domain folder | Verify /etc/letsencrypt/live/<domain>/ path and volume mount |
| Permission denied reading key | File mode too restrictive | Adjust with chmod 600 privkey.pem and 644 fullchain |
| Frontend deep-link 404 | Missing try_files in Nginx |
Restore try_files $uri $uri/ /index.html; |
| Backend cannot reach DB | Postgres not healthy yet | Compose healthcheck waits; re-run after readiness |
| Mobile cannot hit API | Using localhost on device |
Replace with host LAN IP (e.g. 192.168.x.x) |
Template files (.env.example) are provided in each of:
gardenPlannerBackend/.env.example
frontend/.env.example
MOBILE/CommunityGardenApp/.env.example
Copy them to .env before editing secrets:
cp gardenPlannerBackend/.env.example gardenPlannerBackend/.env
cp frontend/.env.example frontend/.env
cp MOBILE/CommunityGardenApp/.env.example MOBILE/CommunityGardenApp/.envNever commit populated .env files.
Backend uses a Firebase Admin service account JSON (firebase-service-account.json) referenced by FIREBASE_SERVICE_ACCOUNT_KEY; do NOT commit this file.
Frontend and Mobile rely on environment variables (VITE_FIREBASE_* / EXPO_PUBLIC_FIREBASE_*). Vite exposes variables prefixed with VITE_ via import.meta.env. React Native (Expo) exposes those prefixed with EXPO_PUBLIC_.
Security best practices:
- Restrict API key usage in Firebase console (HTTP referrers / app restrictions).
- Rotate service account keys if compromised.
- Use environment variables instead of hardcoding.
- Confirm push notification permissions and messaging sender ID are correct.
Key files in gardenPlannerBackend/:
gardenplanner/settings.py- Django settings.env- Environment variablesfirebase-service-account.json- Firebase Admin SDK credentials
Key files in frontend/:
vite.config.js- Vite build configuration.env- Environment variablessrc/constants/Config.js- API endpoints
Key files in MOBILE/CommunityGardenApp/:
app.json- Expo configuration.env- Environment variablesconstants/Config.ts- API endpointsconfig/firebaseConfig.ts- Firebase client configuration
Database connection error
# Check PostgreSQL is running
pg_isready
# Check database exists
psql -l | grep gardenplannerMigration errors
# Reset migrations (⚠️ destroys data)
python manage.py migrate --run-syncdb
# Or create fresh migrations
python manage.py makemigrations
python manage.py migrateFirebase errors
- Verify
firebase-service-account.jsonis in the correct location - Check Firebase project permissions
- Ensure service account has proper roles
API connection error
- Verify backend is running on port 8000
- Check CORS settings in backend
settings.py - Ensure
VITE_API_URLin.envis correct
Build errors
# Clear cache and reinstall
rm -rf node_modules package-lock.json
npm installMetro bundler errors
# Clear Expo cache
npx expo start -cCannot connect to backend
- Use your computer's local IP address instead of
localhost - Ensure devices are on the same network
- Check firewall settings
Firebase authentication errors
- Verify Firebase config in
config/firebaseConfig.ts - Check Firebase project settings
- Ensure Firebase authentication methods are enabled
iOS build issues
- Ensure Xcode is up to date
- Install CocoaPods:
sudo gem install cocoapods - Run
npx pod-installin iOS directory
- Django Documentation
- Django REST Framework
- React Documentation
- Vite Documentation
- Expo Documentation
- Firebase Documentation
- PostgreSQL Documentation
- Create a new branch for your feature
- Make your changes
- Test thoroughly
- Submit a pull request
This project is part of CMPE352/451 coursework at Boğaziçi University.