Frontend UI for a real-time chat application built with React and Vite. It provides authentication screens, a responsive chat interface, profile management, theme switching, and live conversation updates through Socket.IO.
- User signup and login flows
- Protected routes for authenticated users
- Real-time private chat UI
- Sidebar with contacts and online indicators
- Profile page with profile picture upload
- Message sending with text and image attachments
- Live online user presence
- Theme persistence using localStorage
- Responsive layout for desktop and mobile
- React 19
- Vite
- React Router
- Zustand
- Axios
- Socket.IO Client
- Tailwind CSS
- DaisyUI
- react-hot-toast
- Lucide React icons
frontend/
├── src/
│ ├── components/
│ ├── constants/
│ ├── lib/
│ ├── pages/
│ ├── store/
│ ├── App.jsx
│ ├── index.css
│ └── main.jsx
├── public/
├── package.json
└── README.md- Install dependencies
cd frontend
npm install- Make sure the backend is running first
The frontend expects the backend API to be available locally at:
http://localhost:5001- Start the development server
npm run devnpm run dev- Start the Vite development servernpm run build- Build the app for productionnpm run preview- Preview the production build locallynpm run lint- Run ESLint checks
/- Main chat dashboard, shown only for authenticated users/login- Login page/signup- Sign up page/profile- Profile page for updating user avatar/settings- Settings page
Auth state is managed in Zustand using useAuthStore.
checkAuth()verifies the current session on app loadlogin()signs the user insignup()creates a new accountlogout()clears the session
Chat state is managed in Zustand using useChatStore.
getUsers()loads sidebar contactssetSelectedUser()opens a conversationgetMessages(userId)loads a chat threadsendMessage()sends text or image messagessubscribeToMessages()listens for realtime messages via Socket.IO
Theme selection is stored in localStorage via useThemeStore, so the selected theme persists across reloads.
The frontend talks to the backend API and socket server at http://localhost:5001.
Make sure the backend is configured with CORS to allow the frontend origin:
- Frontend dev server:
http://localhost:5173
Navbar- Top navigation and auth actionsSidebar- Contact list and online statusChatContainer- Active conversation viewChatHeader- Selected user header and presenceMessageInput- Text and image message composerProfilePage- Profile image upload screenAuthImagePattern- Authentication page illustration panel
The app uses Zustand stores instead of Redux:
useAuthStore- Auth user, session state, socket connection, online usersuseChatStore- Selected user, messages, contacts, and message actionsuseThemeStore- UI theme persistence
- File uploads are sent as
multipart/form-data. - Profile image uploads use the
profilePicfield name. - Chat image uploads use the
imagefield name. - The chat UI expects the backend to return user and message objects with
profilePic,image,createdAt, and MongoDB_idfields.
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
Currently, two official plugins are available:
- @vitejs/plugin-react uses Babel for Fast Refresh
- @vitejs/plugin-react-swc uses SWC for Fast Refresh