Local Development Setup
Step-by-step guide to set up BabyShopHub on your local machine for development.
Local Development Setup
This guide walks you through setting up BabyShopHub on a local machine from scratch — including Flutter, Firebase, the Node.js SMTP relay, and the Groq AI key.
Prerequisites
| Tool | Version | Install |
|---|---|---|
| Flutter SDK | ≥ 3.11.5 | flutter.dev/docs/get-started |
| Dart SDK | ≥ 3.0 (bundled with Flutter) | Included |
| Node.js | ≥ 18 LTS | nodejs.org |
| Firebase CLI | Latest | npm install -g firebase-tools |
| Git | Any | git-scm.com |
| Chrome | Latest (for web dev) | Included on most systems |
Step 1 — Clone & Install Flutter Dependencies
Verify the Flutter setup:
All items should show . Fix any issues reported before continuing.
Step 2 — Firebase Project Setup
- Go to console.firebase.google.com and create a new project
- Enable Authentication → Sign-in methods:
- Email/Password
- Enable Cloud Firestore → Start in test mode (update to production rules later)
- Install the FlutterFire CLI:
- Configure Firebase for your project:
This generateslib/firebase_options.dartautomatically.
Step 3 — Start the Node.js Email Relay Server
The SMTP relay handles all transactional emails (OTPs, order confirmations, welcome emails).
The server starts on http://localhost:3000.
Environment Variables
Set these before running (or edit server/index.js directly for development):
Development shortcut: If the SMTP relay is not running, all email-based flows still work — OTP codes are printed to the Flutter debug console with a clear OTP CODE IS: XXXXX marker.
Step 4 — Configure Groq API (Optional)
To enable the live AI chat assistant:
- Get a free API key at console.groq.com
- Pass it as a build-time Dart environment variable:
Without the key, the assistant uses the intelligent offline keyword-matching fallback automatically.
Step 5 — Run the App
Web (recommended for development)
Android
iOS (macOS only)
List available devices:
Step 6 — Verify the Setup
- Open the app in Chrome
- Tap "Create Account" → enter an email and password
- Check the Flutter debug console for the OTP code (look for
OTP CODE IS:) - Enter the OTP — you should be logged in and see the Home Screen with products
If products don't appear, Firestore is seeding them on first run — wait 3–5 seconds and they'll populate.
Firestore Indexes
Some queries (e.g. notifications ordered by createdAt) require a composite index. If you see a Firestore index error in the console, click the URL in the error message to create the index in the Firebase Console automatically.
Hot Reload & Hot Restart
Flutter's hot reload (r in terminal) reloads UI changes without resetting state.
Hot restart (R) resets the entire app state — useful if you change provider logic.
Common Issues
| Problem | Solution |
|---|---|
firebase_options.dart missing | Run flutterfire configure |
| Products not loading | Check Firestore rules allow reads; verify project ID in firebase_options.dart |
| Google Sign-In fails | Add your SHA-1 fingerprint to Firebase Console → Project Settings → Android app |
| SMTP emails not sending | Ensure server/index.js is running; check EMAIL_USER / EMAIL_PASS env vars |
| Groq AI returns offline response | Set GROQ_API_KEY via --dart-define or check Groq console for rate limits |