A modern sleep wellness tracker with AI insights, journaling, and technique coaching. Built with React (Vite) + Tailwind on the frontend and Node.js + Express + MongoDB on the backend. Deployed to Vercel (frontend) and Render (backend).
- Sleep logging: duration, quality, mood, tags, notes
- Calendar + trends: weekly stats and patterns
- AI Coach: weekly analysis and recommendations
- Journal: write, tag, and browse a gallery of entries
- Techniques library: guided breathing/relaxation sequences
- Auth: signup/login, password reset via email
- Theme + UX polish: tokens, animations, z-index layering, toasts
- Frontend: React (Vite), Tailwind, Framer Motion, React Router, react-hot-toast
- Backend: Node.js, Express, MongoDB Atlas, JWT
- Deployment: Vercel (frontend), Render (backend)
DimLight/
dimlight-backend/
server.js
package.json
config/
controllers/
middleware/
models/
routes/
seed/
utils/
dimlight-frontend/
src/
package.json
vite.config.js
tailwind.config.js
index.html
- Node.js v18+
- MongoDB Atlas account (free tier)
- Create
dimlight-backend/.envwith:PORT=5000 NODE_ENV=development MONGO_URI=mongodb+srv://<user>:<pass>@<cluster>/dimlight?retryWrites=true&w=majority JWT_SECRET=change_this_secret FRONTEND_URL=http://localhost:5173 SMTP_HOST=smtp.gmail.com SMTP_PORT=465 SMTP_EMAIL=your_email@gmail.com SMTP_PASSWORD=your_gmail_app_password FROM_EMAIL=your_email@gmail.com FROM_NAME=DimLight CORS_ORIGINS=http://localhost:5173 ALLOW_SEED=false
- Install & run:
cd dimlight-backend npm install npm run dev - Health check:
curl http://localhost:5000/health
- Create
dimlight-frontend/.envwith:VITE_API_URL=http://localhost:5000
- Install & run:
cd dimlight-frontend npm install npm run dev - Open: http://localhost:5173
MONGO_URI: Atlas connection stringJWT_SECRET: strong random secretNODE_ENV:productionPORT: Render sets automatically; safe to keep your valueFRONTEND_URL: your Vercel URL (e.g., https://dimlight-xxxx.vercel.app)SMTP_HOST:smtp.gmail.comSMTP_PORT:465(SSL/TLS)SMTP_EMAIL: sender addressSMTP_PASSWORD: Gmail App Password (not account password)FROM_EMAIL: sender address (same as above)FROM_NAME:DimLightGEMINI_API_KEY: your Gemini key (if AI is enabled)GOOGLE_CLIENT_ID/GOOGLE_CLIENT_SECRET/GOOGLE_CALLBACK_URL: OAuth settingsCORS_ORIGINS: comma-separated allowed origins (e.g., your Vercel domain)ALLOW_SEED:falsein prod
VITE_API_URL: backend root URL (no/api), e.g.,https://dimlight-backend.onrender.com
- Service root:
dimlight-backend - Start:
npm start - Add env vars as above
- Root directory:
dimlight-frontend - Build:
npm run build - Output:
dist - Env:
VITE_API_URL=https://<your-backend>.onrender.com
POST /auth/signup– create accountPOST /auth/login– loginPOST /auth/forgot-password– send reset emailPUT /auth/reset-password/:resettoken– reset passwordGET /sleep/logs– list logsPOST /sleep/log– create logPATCH /sleep/log/:id– update logDELETE /sleep/log/:id– delete logGET /insights/weekly– weekly statsGET /ai/weekly-coach– AI analysis (rate-limited)GET /techniques– list techniquesGET /techniques/:id– technique detailGET /trends/...– trend endpoints
- 404 on signup: ensure frontend
VITE_API_URLpoints to backend root and the request hits/auth/signup. - CORS blocked: set
CORS_ORIGINSto your Vercel domain; backend logs will show CORS errors. - SMTP timeout: use
SMTP_PORT=465withsecure: true; provide a Gmail App Password. - Rate limit warning (X-Forwarded-For): backend sets
app.set('trust proxy', 1); ensure it’s deployed. - AI request limits: weekly coach route is rate-limited; cached insights mitigate tab switching.
- Seed endpoints are disabled in production (
ALLOW_SEED=false). - Health endpoint:
GET /healthreturns status and uptime. - Password policy: 8+ chars including upper, lower, digit, and symbol.
PRs are welcome. Please open an issue to discuss major changes.


