- Next.js App Router, Server and Client Components
- Authentication with NextAuth (Credentials provider) and MongoDB Adapter
- MongoDB via official Node driver
- Styling with Tailwind CSS and components via shadcn/ui
- Friends management and session requests
- Realtime chat between friends with embedded session requests
- Unread message badges and live updates via Server‑Sent Events (SSE)
- Copy
.env.exampleto.env.local(create one if missing) and set:
MONGODB_URI=mongodb+srv://<user>:<pass>@<cluster>/<db>?retryWrites=true&w=majority
NEXTAUTH_SECRET=your-long-random-secret
NEXTAUTH_URL=http://localhost:3000
DAILY_API_KEY=your-daily-api-key
DAILY_DOMAIN=your-subdomain.daily.co
- Install deps and run dev server
npm install
npm run dev
App runs at http://localhost:3000.
# development
npm run dev
# typecheck + lint + production build
npm run build
# start production server (after build)
npm run start
- Registration happens via
POST /api/auth/registerand stores a hashed password inusers. - Login uses NextAuth Credentials at
/auth/login. - Friends and Sessions APIs are backed by MongoDB.
- Settings page includes a Logout button that redirects to
/.
- Chat messages are stored in
messages(MongoDB). New messages setread_at: nullfor the recipient. - Unread counts endpoint:
GET /api/chat/unread-countsreturns per‑friend counts. - Mark as read:
POST /api/chat/[friendId]/readmarks messages from that friend as read. - Realtime transport uses SSE:
- Per‑conversation events:
GET /api/chat/[friendId]/events - Per‑user unread events:
GET /api/chat/events
- Per‑conversation events:
- Chat UI (
app/(product)/components/FriendChat.tsx):- Compose text or send session requests (datetime, duration, message)
- Accept/decline incoming requests with optional message; delete your own pending requests
- Realtime updates via EventSource; unread counts update in friends list
- Create:
POST /api/session-requestswith{ to_user_id, start, durationMin, message? } - List:
GET /api/session-requests?type=incoming|outgoing&status=... - Respond:
POST /api/session-requests/[id]with{ action: 'accept'|'decline', message? }- Accept creates a session with both users
- Delete (requester only, pending):
DELETE /api/session-requests/[id]
- Session calls use Daily prebuilt rooms and meeting tokens.
- Required server env vars:
DAILY_API_KEY(server-only secret; never expose in client code)DAILY_DOMAIN(for examplerefocus.daily.co)
- Get a free Daily account and API key at daily.co.
Deploy to Vercel or your platform of choice. Ensure env vars above are set in the hosting environment.
Please open issues and PRs in this repository.