-
Notifications
You must be signed in to change notification settings - Fork 0
Local Development
harshcode1 edited this page Jun 20, 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
cp .env.example .env.local # create and fill in (see below)
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).
# ── Required ───────────────────────────────
MONGODB_URI=mongodb://localhost:27017/bettermind
JWT_SECRET=a_long_random_string
ENCRYPTION_KEY=a_32_byte_key_for_aes
# ── 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/callbackThe 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 |
-
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 |