feat(dev): add local development setup — one-command startup, contributor guide, and bug fixes - #1163
Open
JoelJosephPhilip wants to merge 2 commits into
Open
JoelJosephPhilip wants to merge 2 commits into
JoelJosephPhilip wants to merge 2 commits into
Conversation
- Add run-all.ps1 (Windows) and run-all.sh (macOS/Linux) one-command startup scripts that validate prerequisites, auto-bootstrap backend/.env from .example.env, auto-fix Firebase project ID mismatches, install dependencies, and launch the full local stack (MongoDB + Firebase Auth Emulator + Backend + Frontend) - Add local_development_run_guide.md: complete contributor guide covering prerequisites, quick-start commands for all platforms, env file setup, architecture diagram, documented bug fixes for local dev, and a full troubleshooting section - Update README.md Quick Start section with one-line commands for both Windows and macOS/Linux - Update backend/.example.env: pre-configured for local dev (NODE_ENV= development, local DB_URL, APP_MODULE=all, full Firebase emulator config) so new contributors can cp .example.env .env and start immediately - Add frontend/.env.example: new file with safe local dev placeholder values (Firebase Auth Emulator accepts any API key) - Fix backend/.gitignore to track .env.example and .example.env template files while still ignoring real .env files - Fix cli/src/commands/start.ts: add pretty terminal UI with ASCII art banner, colored step logger, service status board, and styled ready messages using new cli/src/ui.ts helper (zero extra dependencies) - Fix backend/src/shared/classes/BaseService.ts: add dev-mode fallback for MongoDB transactions on standalone instances (avoids crash on mongodb-memory-server which does not support replica-set transactions) - Fix backend/src/modules/auth/controllers/AuthController.ts: route login requests to Firebase Auth Emulator when FIREBASE_AUTH_EMULATOR_HOST is set, instead of calling the real Firebase API
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a one-command local development experience for the ViBe monorepo, aiming to help new contributors run the full stack locally (MongoDB, Firebase Auth emulator, backend API, and frontend) with minimal manual setup.
Changes:
- Add cross-platform startup scripts (
run-all.ps1,run-all.sh) plus a detailed local development guide and README quick-start updates. - Enhance the CLI
vibe startexperience (MongoDB Memory Server auto-start, emulator bootstrapping, and terminal UI/status output). - Fix local-dev backend issues: MongoDB transaction fallback for standalone instances and routing login to the Firebase Auth emulator when configured.
Reviewed changes
Copilot reviewed 10 out of 11 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| run-all.sh | New macOS/Linux startup script that validates prerequisites, bootstraps backend env, installs deps, and starts the stack. |
| run-all.ps1 | New Windows startup script with the same responsibilities as run-all.sh. |
| README.md | Replaces “Documentation in progress” with concrete local quick-start commands and a link to the local dev guide. |
| local_development_run_guide.md | Adds a comprehensive contributor-facing local development guide and troubleshooting notes. |
| frontend/.env.example | Adds a frontend env template with emulator-friendly placeholder Firebase values and local API base URL. |
| cli/src/ui.ts | Adds terminal UI helpers (banner, step logging, and a “service board”). |
| cli/src/commands/start.ts | Expands vibe start to auto-start MongoDB Memory Server, run emulators/services, and show UI output. |
| backend/src/shared/classes/BaseService.ts | Adds a standalone MongoDB transaction fallback for local dev. |
| backend/src/modules/auth/controllers/AuthController.ts | Routes login to the Firebase Auth emulator when FIREBASE_AUTH_EMULATOR_HOST is set; otherwise uses real Identity Toolkit. |
| backend/.example.env | Updates backend env template for local dev defaults (local MongoDB, emulator config, and placeholders). |
| .gitignore | Adjusts ignore rules to allow committing *.env.example and .example.env templates. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+65
to
+68
| if [ -f "$BACKEND_FIREBASERC" ]; then | ||
| # Extract the "default" project using basic shell parsing (no jq required) | ||
| EMULATOR_PROJECT_ID=$(grep -o '"default": *"[^"]*"' "$BACKEND_FIREBASERC" | sed 's/"default": *"\([^"]*\)"/\1/') | ||
| fi |
Comment on lines
+45
to
+54
| if ( | ||
| typeof error?.message === 'string' && | ||
| error.message.includes(REPLICA_SET_REQUIRED_MSG) | ||
| ) { | ||
| console.warn( | ||
| '[BaseService] Standalone MongoDB detected – running operation ' + | ||
| 'without a transaction (dev-mode only).', | ||
| ); | ||
| return operation(null as unknown as ClientSession); | ||
| } |
Comment on lines
+196
to
+200
| // After a delay, refresh the board showing services as "up" | ||
| const markUp = (name: string) => { | ||
| const svc = services.find((s) => s.name === name); | ||
| if (svc) svc.status = "up"; | ||
| }; |
Comment on lines
+171
to
+174
| const name = clr.bwhite(svc.name.padEnd(22)); | ||
| const row = ` │ ${name} ${statusStr.padEnd(6)} ${urlStr}`; | ||
| const padding = " ".repeat(Math.max(0, 52 - stripAnsi(row).length + 2)); | ||
| console.log(col(C.cyan + C.bold, ` │`) + ` ${name} ${statusStr} ${urlStr}${padding}` + col(C.cyan + C.bold, `│`)); |
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds a complete local development setup so new contributors can clone the repo and get the full stack running with a single command — no manual MongoDB install, no real Firebase project needed.
Problem
Right now, a new contributor who clones this repo has no clear path to run it locally:
README.mdQuick Start says only "Documentation in progress"backend/.example.envhasNODE_ENV=productionand points to MongoDB AtlasWhat's Included
One-command startup scripts
run-all.ps1run-all.shBoth scripts automatically:
backend/.envfrom.example.envif it does not existbackend/.envandbackend/.firebasercFIREBASE_AUTH_EMULATOR_HOSTis set so login routes to the local emulatorlocal_development_run_guide.md(new)Complete contributor guide covering:
README.md— Quick Start updatedReplaced "Documentation in progress" with actual one-line commands for both Windows and macOS/Linux.
backend/.example.env(updated)Was broken for local development:
NODE_ENVproductiondevelopmentDB_URLmongodb+srv://...(Atlas)mongodb://localhost:27017/vibeAPP_MODULEauthallfrontend/.env.example(new)Pre-filled with safe local dev placeholder values. The Firebase Auth Emulator ignores the API key, so contributors do not need a real Firebase project.
cli/src/ui.ts(new) +cli/src/commands/start.ts(updated)Pretty terminal UI for
vibe start:Bug Fixes for Local Dev
Fix 1 — Signup fails: MongoDB transaction error
Error:
mongodb-memory-serverruns a standalone instance that does not support transactions. Added a dev-mode fallback inBaseService._withTransaction()that retries the operation without a transaction when a standalone instance is detected.Fix 2 — Login fails: backend calls real Firebase instead of emulator
Error: Backend fetches
https://identitytoolkit.googleapis.comwith no API key in dev mode.AuthController.login()now checksFIREBASE_AUTH_EMULATOR_HOSTand routes sign-in requests to the local emulator (http://127.0.0.1:9099) instead of the real Firebase API.Fix 3 — Firebase emulator project ID mismatch
Warning:
The startup scripts auto-detect and fix mismatches between
backend/.envandbackend/.firebasercon every run.Testing
Verified on Windows 11, Node.js v22, pnpm, Java 21, Firebase CLI:
Files Changed
run-all.ps1run-all.shlocal_development_run_guide.mdfrontend/.env.examplecli/src/ui.tsbackend/.example.envREADME.mdcli/src/commands/start.tsbackend/src/shared/classes/BaseService.tsbackend/src/modules/auth/controllers/AuthController.ts.gitignore.env.exampletemplate files