- 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
- 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]
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.