-
Notifications
You must be signed in to change notification settings - Fork 0
Local Development
harshcode1 edited this page Jun 21, 2026
·
3 revisions
- Node.js 18+
- A MongoDB instance (local
mongodor a free MongoDB Atlas cluster) - (Optional) an OpenAI API key for live AI chat
- (Optional) Google OAuth credentials for Calendar sync
git clone https://github.com/harshcode1/BetterMind.git
cd BetterMind
npm install
# Create .env.local and fill in the values below
# Then optionally seed demo doctors:
node scripts/seed-doctors.mjs
npm run devApp runs at http://localhost:3000. The fastest way to see everything is the ”Explore as Guest” button — no DB writes required (see Guest-Mode).
Create a .env.local file in the project root (there is no .env.example — create from scratch):
# ── Required ───────────────────────────────
MONGODB_URI=mongodb+srv://<user>:<password>@<cluster>.mongodb.net/bettermind
JWT_SECRET=a_long_random_string
# Required for AES-GCM encryption of sensitive health data
ENCRYPTION_SECRET=a_long_random_string
ENCRYPTION_SALT=any_short_string
# ── Optional (features degrade gracefully) ──
OPENAI_API_KEY=sk-... # AI chat → keyword fallback if absent
GOOGLE_CLIENT_ID=... # Calendar sync
GOOGLE_CLIENT_SECRET=...
GOOGLE_REDIRECT_URI=http://localhost:3000/api/auth/google/callback
ENCRYPTION_SECRETandENCRYPTION_SALThave development fallbacks but must be set in production or data encrypted in dev will be unreadable in prod.
The MongoDB URI check is deferred to request time, so the app boots even if some optional vars are missing — handy for UI-only work.
| Command | Purpose |
|---|---|
npm run dev |
Start the dev server (hot reload) |
npm run build |
Production build (also runs lint/type checks) |
npm run start |
Serve the production build |
npm run lint |
ESLint |
node scripts/seed-doctors.mjs |
Seed 6 demo doctors into MongoDB (idempotent — safe to re-run) |
-
Patient — sign up at
/signup. -
Doctor — sign up at
/signup/doctor(lands as pending verification). -
Admin — set a user's
roletoadmindirectly in MongoDB, then visit/admin/dashboardto approve the doctor.
| Flow | How |
|---|---|
| 2FA |
/settings/security → enable → scan QR in an authenticator app → confirm → log out → log back in and complete the challenge |
| AI chat | Set OPENAI_API_KEY, open /chat, send a message (without the key you'll get the keyword fallback) |
| Calendar sync | Configure Google OAuth, connect on /appointments, book an appointment, confirm the event appears |
| Reviews | Complete an appointment, leave a review, confirm the doctor's averageRating updates |
| Rate limiting | Hit /api/auth/register or /api/chat rapidly → expect HTTP 429 |
| Symptom | Fix |
|---|---|
| Port 3000 in use | Stop the other process or run next dev -p 3001
|
MONGODB_URI errors at request time |
Ensure Mongo is running and the URI is correct |
| AI replies look like canned keyword matches |
OPENAI_API_KEY is missing/invalid — that's the intended fallback |
Build warnings about react-hooks/exhaustive-deps
|
Non-blocking; pre-existing intentional effect deps |