A modern, real-time chat application built with Next.js and Phoenix WebSocket.
For a maintainer-oriented overview (stack, env vars, API/WebSocket shape, deployment), see doc/project_analysis.md.
- Real-time Messaging: Instant message delivery using WebSocket technology
- Room Management: Create and join chat rooms with unique codes
- User Authentication: Secure login and registration system
- Persistent Sessions: Access + refresh tokens in local storage; the client renews expired access tokens via the API’s refresh endpoint before retrying failed requests
- Modern UI: Clean, dark-themed interface with smooth animations
- Responsive Design: Works seamlessly on desktop and mobile devices
- User Colors: Each user gets a unique color for better message distinction
- Auto-scroll: Smart scrolling that respects user's reading position
- Mobile / background: Unread badges need JavaScript + WebSocket. If the browser suspends the tab (app switcher, another app in front), messages are not received until you open Kumpel again; the client then reconnects. For alerts while away you’d add Web Push (service worker + server) or fetch message history from the API after reconnect.
- Back vs logout: Auth uses
router.replace('/dashboard')and auto-redirect from/and/loginwhen a token exists, so the system back button does not strand you on login while still logged in. Logout still clears the session.
Details: doc/project_analysis.md → Background delivery, auth navigation, and long-lived sessions.
-
Frontend:
- Next.js 15 (App Router)
- React
- TypeScript
- Tailwind CSS
- shadcn/ui
- Zustand (State Management)
-
Backend:
- Phoenix WebSocket
- Elixir
- Bun (recommended: match
packageManagerinpackage.json, e.g. 1.2.x) - Access to the Kumpel backend server
Bun bundles a JavaScript runtime compatible with Next.js; you do not need a separate Node install for local dev unless you prefer it.
-
Clone the repository
git clone https://github.com/MarcosFlavioGS/Kumpel_client.git cd kumpel_app -
Install dependencies
bun install
Commit
bun.lockwith the repo so CI and Vercel stay reproducible. -
Environment Setup With
bun run dev, the app defaults to the local API athttp://localhost:4000and WebSocket atws://localhost:4000(run the Phoenix backend withmix phx.serveron port 4000).Important: the dev server speaks plain HTTP, not TLS. For localhost you must use
http://andws://. Usinghttps://orwss://againstlocalhost:4000makes the browser send TLS on a non-TLS port; the backend may log a warning like "Connection that looks like TLS received on a clear channel" and requests will fail.Optional: create a
.env.localto override (e.g. point at production while developing the UI):NEXT_PUBLIC_API_URL=https://kumpel-back.fly.dev NEXT_PUBLIC_WS_URL=wss://kumpel-back.fly.dev
For local backend explicitly (same as defaults):
NEXT_PUBLIC_API_URL=http://localhost:4000 NEXT_PUBLIC_WS_URL=ws://localhost:4000
-
Run the development server
bun run dev
-
Open your browser Visit
http://localhost:3000
Installs use Bun via vercel.json → bun install --frozen-lockfile (with bun.lock committed). Vercel detects Bun when a Bun lockfile is present. Set NEXT_PUBLIC_API_URL and NEXT_PUBLIC_WS_URL in the Vercel project to your production API if needed.
kumpel_app/
├── src/
│ ├── app/ # Next.js app directory
│ │ ├── stores/ # Zustand stores
│ │ ├── hooks/ # Custom hooks
│ │ └── ... # App routes
│ ├── components/ # React components
│ │ ├── ui/ # shadcn/ui components
│ │ ├── chatRoom.tsx # Chat room interface
│ │ └── ... # Other components
│ └── type/ # TypeScript type definitions
├── doc/ # Architecture notes (see project_analysis.md)
├── public/ # Static assets
└── ... # Configuration files
- Chat Room: Real-time messaging interface with auto-scroll
- Dashboard: Room management and navigation
- Authentication: Secure login and registration
- State Management: Persistent user sessions with Zustand
- User registers with email and password
- Receives JWT token for authentication
- Token is stored in localStorage for persistence
- Protected routes check for valid token
POST /api/auth/login- User loginPOST /api/users- User registrationPOST /api/rooms- Create a room (body:{ "name": "<name>" }; authenticated). The API assigns a random access code and returns it in the response.POST /api/rooms/subscribe- Join a chat room (body:{ "name": "<room name>", "code": "<access code>" }; authenticated)GET /api/currentUser- Get user's rooms and data
User and room identifiers in API responses are UUID strings. WebSocket channel topics use chat_room:<room_uuid> with join payload { "code": "<access code>" }.
- Discord-inspired dark UI: blurple accent (
#5865F2), layered greys (kumpel.*tokens in Tailwind), soft panel shadows, and glass-style auth cards (kumpel-auth-bg/kumpel-auth-panelinglobals.css). - Dashboard: channel sidebar with selection states, skeleton loading, empty-state guidance, accessible channel rows (buttons). On small screens, the list and chat stack: you get a full-width channel list, then full-width chat with a back control to return to the list (
mdand up keeps the split sidebar + chat). - Chat: connection status per room, join-error banner, message bubbles, “jump to latest” when scrolled up. Per-room history and unread badges on the sidebar (multi-room WebSocket subscriptions + persisted
kumpel-chatstore). - Shared form styling lives in
src/lib/kumpel-ui.ts; full design notes are indoc/project_analysis.md(section UI & design system).
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.