CozyRoom is a full-stack chat app with authentication, profile management, room-based messaging, and room invitations.
This project is an MVP and a learning sketch.
- It is intentionally focused on exploring architecture and implementation ideas.
- Expect rough edges, incomplete flows, and evolving structure.
- The goal is learning and iteration, not production readiness.
This workspace contains two applications:
cozyroom/: Next.js frontend (App Router)thebackroom/: NestJS backend API
- Email/password auth (login, register, logout)
- Cookie-based session flow with access and refresh tokens
- Automatic token refresh in frontend middleware
- User profile page (display name, bio, phone, avatar upload)
- Room-based chat
- Realtime message updates via Supabase Realtime
- Room invitations (send, list pending, accept)
- Frontend: Next.js 16, React 19, TypeScript, Tailwind CSS 4
- Backend: NestJS 11, TypeScript
- Data/Auth/Storage/Realtime: Supabase
.
|- cozyroom/ # Next.js app
|- thebackroom/ # NestJS API
`- README.md # You are here
- User authenticates through frontend forms.
- Frontend server actions call backend auth endpoints.
- Tokens are set as HTTP-only cookies (
access_token,refresh_token). - Frontend middleware checks cookies and tries
/auth/refreshwhen needed. - Frontend calls internal Next.js API routes, which proxy requests to NestJS.
- Backend uses Supabase for auth, profile data, chat data, and avatar storage.
- Chat UI subscribes to Supabase realtime inserts for new messages.
- Node.js 20+
- npm 10+
- A Supabase project with auth enabled
Create .env.local in cozyroom/ and .env (or .env.local) in thebackroom/.
# Supabase
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY=your_supabase_anon_key
# Optional
NEXT_PUBLIC_SUPABASE_IMAGE_PATH=/storage/v1/object/public/**
NEXT_PUBLIC_API_URL=http://localhost:3001
API_URL=http://localhost:3001Notes:
NEXT_PUBLIC_SUPABASE_URLandNEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEYare required.NEXT_PUBLIC_API_URLis used in the browser.API_URLis used by server-side fetches.
# Supabase
NEXT_PUBLIC_SUPABASE_URL=https://your-project.supabase.co
NEXT_PUBLIC_SUPABASE_PUBLISHABLE_DEFAULT_KEY=your_supabase_anon_key
# Optional
PORT=3001Notes:
- Backend currently reads the same Supabase variables shown above.
- Default backend port is
3001.
The backend expects these Supabase resources to exist:
- Tables/views used by code:
profilespublic_profilesroomsroom_membersmessagesroom_invitations
- Storage bucket:
avatar
Open two terminals from the workspace root.
cd thebackroom
npm install
npm run start:devBackend runs on http://localhost:3001 by default.
cd cozyroom
npm install
npm run devFrontend runs on http://localhost:3000.
cd cozyroom
npm run build
npm run startcd thebackroom
npm run build
npm run start:prodnpm run devnpm run buildnpm run startnpm run lint
npm run start:devnpm run buildnpm run start:prodnpm run lintnpm run testnpm run test:e2e
Auth:
POST /auth/loginPOST /auth/registerGET /auth/mePOST /auth/refreshPOST /auth/logout
Users:
GET /users/search?q=...&limit=...GET /users/me/profilePATCH /users/me/profilePOST /users/me/avatar
Chat:
GET /chat/roomsPOST /chat/roomsGET /chat/rooms/:roomId/messagesPOST /chat/rooms/:roomId/messagesGET /chat/rooms/:roomId/membersPOST /chat/rooms/:roomId/inviteGET /chat/invitationsPATCH /chat/invitations/:invitationId/accept
/landing page/login/register/profile/chat/chat/[roomId]
- App fails at startup with missing Supabase vars:
- Confirm both frontend and backend env files contain required variables.
- Frontend cannot reach backend:
- Confirm backend is running on
3001. - Set
NEXT_PUBLIC_API_URLandAPI_URLexplicitly if needed.
- Confirm backend is running on
- Avatar image does not load:
- Check Next.js image host config and Supabase storage permissions.
- Realtime messages do not appear:
- Confirm Supabase Realtime is enabled for the
messagestable.
- Confirm Supabase Realtime is enabled for the
- Existing app-specific README files inside
cozyroom/andthebackroom/are starter templates. - Use this root README as the main project guide.