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

ToolVersionInstall
Flutter SDK≥ 3.11.5flutter.dev/docs/get-started
Dart SDK≥ 3.0 (bundled with Flutter)Included
Node.js≥ 18 LTSnodejs.org
Firebase CLILatestnpm install -g firebase-tools
GitAnygit-scm.com
ChromeLatest (for web dev)Included on most systems

Step 1 — Clone & Install Flutter Dependencies

git clone <your-repo-url>
cd babyshophub
flutter pub get

Verify the Flutter setup:

flutter doctor

All items should show . Fix any issues reported before continuing.


Step 2 — Firebase Project Setup

  1. Go to console.firebase.google.com and create a new project
  2. Enable Authentication → Sign-in methods:
    • Email/Password
    • Google
  3. Enable Cloud Firestore → Start in test mode (update to production rules later)
  4. Install the FlutterFire CLI:
    dart pub global activate flutterfire_cli
  5. Configure Firebase for your project:
    flutterfire configure
    This generates lib/firebase_options.dart automatically.

Step 3 — Start the Node.js Email Relay Server

The SMTP relay handles all transactional emails (OTPs, order confirmations, welcome emails).

cd server
npm install
node index.js

The server starts on http://localhost:3000.

Environment Variables

Set these before running (or edit server/index.js directly for development):

EMAIL_USER=your-zoho-email@yourdomain.com
EMAIL_PASS=your-zoho-app-password

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:

  1. Get a free API key at console.groq.com
  2. Pass it as a build-time Dart environment variable:
flutter run --dart-define=GROQ_API_KEY=gsk_your_key_here

Without the key, the assistant uses the intelligent offline keyword-matching fallback automatically.


Step 5 — Run the App

flutter run -d chrome

Android

flutter run -d <android-device-id>

iOS (macOS only)

flutter run -d <ios-device-id>

List available devices:

flutter devices

Step 6 — Verify the Setup

  1. Open the app in Chrome
  2. Tap "Create Account" → enter an email and password
  3. Check the Flutter debug console for the OTP code (look for OTP CODE IS:)
  4. 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

ProblemSolution
firebase_options.dart missingRun flutterfire configure
Products not loadingCheck Firestore rules allow reads; verify project ID in firebase_options.dart
Google Sign-In failsAdd your SHA-1 fingerprint to Firebase Console → Project Settings → Android app
SMTP emails not sendingEnsure server/index.js is running; check EMAIL_USER / EMAIL_PASS env vars
Groq AI returns offline responseSet GROQ_API_KEY via --dart-define or check Groq console for rate limits