Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’¬ CommuniHub - Real-Time Chat Application

Next.js React TypeScript Tailwind Framer Motion

A modern, feature-rich real-time chat application with beautiful UI/UX, built with Next.js 15, React 19, and WebSocket technology.

Features β€’ Tech Stack β€’ Getting Started β€’ Structure β€’ API


πŸ”— Backend Server

This frontend connects to a high-performance Go backend:

πŸš€ Server Realtime Chat App


✨ Features

🎨 Modern Landing Page

  • βœ… Stunning hero section with animated gradients
  • βœ… Interactive feature showcase
  • βœ… Pricing plans with smooth animations
  • βœ… Responsive design for all devices
  • βœ… Newsletter subscription
  • βœ… Modern footer with social links

πŸ’¬ Real-Time Messaging

  • βœ… Instant message delivery via WebSocket
  • βœ… Private 1-on-1 conversations
  • βœ… Group chat rooms with multiple participants
  • βœ… Message read receipts (delivered/read status)
  • βœ… Typing indicators
  • βœ… Online/offline/away status
  • βœ… Message reactions and emojis
  • βœ… File sharing support
  • βœ… Image preview

πŸ‘₯ User Management

  • βœ… User registration with validation
  • βœ… Secure login with JWT authentication
  • βœ… User profile with avatar
  • βœ… User discovery and search
  • βœ… Friend requests
  • βœ… User status management

🎯 Chat Features

  • βœ… Create and manage chat rooms
  • βœ… Group creation with member selection
  • βœ… Channel sidebar with conversations
  • βœ… Message history and pagination
  • βœ… Unread message counter
  • βœ… Notification center
  • βœ… Emote panel
  • βœ… User discovery panel

🎨 UI/UX Excellence

  • βœ… Beautiful gradient animations
  • βœ… Smooth transitions with Framer Motion
  • βœ… Dark mode optimized
  • βœ… Responsive mobile design
  • βœ… Skeleton loaders for better UX
  • βœ… Toast notifications
  • βœ… Modal dialogs
  • βœ… Custom scrollbars

πŸ› οΈ Tech Stack

Frontend Framework

Styling & UI

State & Data Management

Real-Time Communication

  • WebSocket - Bi-directional real-time communication
  • Custom WebSocket hooks for chat functionality
  • Event-driven architecture

Additional Libraries


πŸš€ Getting Started

Prerequisites

Make sure you have the following installed:

Installation

  1. Clone the repository
git clone https://github.com/dinhdev-nu/chat_app_ui.git
cd chat_app_ui
  1. Install dependencies
pnpm install
  1. Set up environment variables

Create a .env.local file in the root directory:

# API Configuration
NEXT_PUBLIC_API_URL=http://localhost:8080/api/v1
NEXT_PUBLIC_WS_URL=ws://localhost:8080/ws

# Local Storage Keys
NEXT_PUBLIC_SESSION_KEY=chat_session
NEXT_PUBLIC_USER_KEY=chat_user

# App Configuration
NEXT_PUBLIC_APP_NAME=CommuniHub
NEXT_PUBLIC_APP_URL=http://localhost:3000
  1. Run the development server
pnpm dev

Open http://localhost:3000 in your browser.

Build for Production

# Create production build
pnpm build

# Start production server
pnpm start

πŸ“ Project Structure

chat_app_ui/
β”‚
β”œβ”€β”€ πŸ“‚ app/                          # Next.js App Router
β”‚   β”œβ”€β”€ πŸ“‚ (auth)/                   # Authentication routes
β”‚   β”‚   β”œβ”€β”€ layout.tsx               # Auth layout
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ login/                # Login page
β”‚   β”‚   └── πŸ“‚ signup/               # Signup page
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“‚ chat/                     # Chat application
β”‚   β”‚   β”œβ”€β”€ page.tsx                 # Main chat interface
β”‚   β”‚   β”œβ”€β”€ πŸ“‚ conversation/         # Conversation routes
β”‚   β”‚   └── πŸ“‚ discord/              # Discord-style chat
β”‚   β”‚
β”‚   β”œβ”€β”€ layout.tsx                   # Root layout
β”‚   β”œβ”€β”€ page.tsx                     # Landing page
β”‚   β”œβ”€β”€ globals.css                  # Global styles
β”‚   └── client-wrapper.tsx           # Client-side wrappers
β”‚
β”œβ”€β”€ πŸ“‚ components/                   # React components
β”‚   β”œβ”€β”€ πŸ“‚ chat/                     # Chat-specific components
β”‚   β”‚   β”œβ”€β”€ chat-header.tsx          # Chat header
β”‚   β”‚   β”œβ”€β”€ chat-messages.tsx        # Message list
β”‚   β”‚   β”œβ”€β”€ chat-sidebar.tsx         # Sidebar with conversations
β”‚   β”‚   β”œβ”€β”€ conversation-item.tsx    # Conversation list item
β”‚   β”‚   β”œβ”€β”€ emote-panel.tsx          # Emoji/emote selector
β”‚   β”‚   β”œβ”€β”€ group-chat-messages.tsx  # Group chat messages
β”‚   β”‚   β”œβ”€β”€ group-creation-modal.tsx # Create group modal
β”‚   β”‚   β”œβ”€β”€ immersive-chat-interface.tsx # Main chat UI
β”‚   β”‚   β”œβ”€β”€ notification-center.tsx  # Notifications
β”‚   β”‚   β”œβ”€β”€ skeleton-loaders.tsx     # Loading states
β”‚   β”‚   └── user-discovery.tsx       # Find users
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“‚ ui/                       # shadcn/ui components
β”‚   β”‚   β”œβ”€β”€ button.tsx               # Button component
β”‚   β”‚   β”œβ”€β”€ card.tsx                 # Card component
β”‚   β”‚   β”œβ”€β”€ dialog.tsx               # Dialog/Modal
β”‚   β”‚   β”œβ”€β”€ input.tsx                # Input field
β”‚   β”‚   β”œβ”€β”€ avatar.tsx               # Avatar component
β”‚   β”‚   β”œβ”€β”€ badge.tsx                # Badge component
β”‚   β”‚   β”œβ”€β”€ toast.tsx                # Toast notifications
β”‚   β”‚   └── ...                      # 40+ UI components
β”‚   β”‚
β”‚   β”œβ”€β”€ navbar.tsx                   # Navigation bar
β”‚   β”œβ”€β”€ hero.tsx                     # Hero section
β”‚   β”œβ”€β”€ footer.tsx                   # Footer
β”‚   β”œβ”€β”€ chat-interface.tsx           # Landing chat demo
β”‚   β”œβ”€β”€ community-features.tsx       # Features section
β”‚   β”œβ”€β”€ join-community.tsx           # CTA section
β”‚   β”œβ”€β”€ login-form.tsx               # Login form
β”‚   β”œβ”€β”€ registration-form.tsx        # Signup form
β”‚   └── ...                          # Other components
β”‚
β”œβ”€β”€ πŸ“‚ config/                       # Configuration files
β”‚   └── axios.config.ts              # Axios instance with auth
β”‚
β”œβ”€β”€ πŸ“‚ hooks/                        # Custom React hooks
β”‚   β”œβ”€β”€ use-toast.ts                 # Toast hook
β”‚   β”œβ”€β”€ use-mobile.tsx               # Mobile detection
β”‚   └── use-media-query.ts           # Media query hook
β”‚
β”œβ”€β”€ πŸ“‚ lib/                          # Shared utilities
β”‚   β”œβ”€β”€ πŸ“‚ api/                      # API functions
β”‚   β”‚   └── chat.ts                  # Chat API calls
β”‚   β”‚
β”‚   β”œβ”€β”€ πŸ“‚ hooks/                    # Advanced hooks
β”‚   β”‚   β”œβ”€β”€ use-init-chat.ts         # Initialize chat
β”‚   β”‚   └── use-get-group.ts         # Fetch groups
β”‚   β”‚
β”‚   β”œβ”€β”€ utils.ts                     # Utility functions
β”‚   β”œβ”€β”€ mock-data.ts                 # Mock data for demo
β”‚   └── mock-notifications-data.ts   # Mock notifications
β”‚
β”œβ”€β”€ πŸ“‚ types/                        # TypeScript type definitions
β”‚   β”œβ”€β”€ auth.ts                      # Auth types
β”‚   β”œβ”€β”€ chat.ts                      # Chat & message types
β”‚   └── user.ts                      # User types
β”‚
β”œβ”€β”€ πŸ“‚ public/                       # Static assets
β”‚   └── ...                          # Images, icons, etc.
β”‚
β”œβ”€β”€ πŸ“‚ styles/                       # Additional styles
β”‚   └── globals.css                  # Extra global styles
β”‚
β”œβ”€β”€ .env.local                       # Environment variables (local)
β”œβ”€β”€ .gitignore                       # Git ignore rules
β”œβ”€β”€ components.json                  # shadcn/ui config
β”œβ”€β”€ next.config.mjs                  # Next.js configuration
β”œβ”€β”€ package.json                     # Dependencies & scripts
β”œβ”€β”€ pnpm-lock.yaml                   # Lockfile
β”œβ”€β”€ postcss.config.mjs               # PostCSS config
β”œβ”€β”€ tailwind.config.ts               # Tailwind configuration
β”œβ”€β”€ tsconfig.json                    # TypeScript config
└── README.md                        # This file

🎨 Key Components

Main Chat Interface

The heart of the application with all chat features:

// components/chat/immersive-chat-interface.tsx
- WebSocket connection management
- Real-time message handling
- User status tracking
- Typing indicators
- Message read receipts
- Group & private conversations

Authentication

Secure login and registration:

// components/login-form.tsx & registration-form.tsx
- Form validation with Zod
- JWT token management
- Protected routes
- Auto-redirect after login

Landing Page

Beautiful, animated landing page:

// components/hero.tsx, community-features.tsx, join-community.tsx
- Framer Motion animations
- Gradient effects
- Responsive design
- Interactive elements

🌐 API Integration

Authentication Endpoints

POST /api/v1/auth/register  // User registration
POST /api/v1/auth/login     // User login
GET  /api/v1/auth/me        // Get current user

Chat Endpoints

POST /api/v1/chat/create-room        // Create chat room
GET  /api/v1/chat/get-messages       // Fetch messages
POST /api/v1/chat/set-status         // Update read status
GET  /api/v1/chat/search-user        // Search users
GET  /api/v1/chat/get-groups         // Fetch user groups

WebSocket Events

// Client -> Server
message      // Send message
typing       // Typing indicator
read         // Mark as read
subscribe    // Subscribe to user updates
status       // Update user status

// Server -> Client
message      // Receive message
typing       // User typing
read         // Message read
status       // User status update
ack          // Message acknowledgment
room_created // New room notification

🎯 Environment Variables

Variable Description Example
NEXT_PUBLIC_API_URL Backend API base URL http://localhost:8080/api/v1
NEXT_PUBLIC_WS_URL WebSocket server URL ws://localhost:8080/ws
NEXT_PUBLIC_SESSION_KEY LocalStorage key for session chat_session
NEXT_PUBLIC_USER_KEY LocalStorage key for user data chat_user
NEXT_PUBLIC_APP_NAME Application name CommuniHub
NEXT_PUBLIC_APP_URL Frontend URL http://localhost:3000

πŸ“± Responsive Design

The application is fully responsive across all devices:

  • πŸ“± Mobile (< 768px) - Optimized touch interface
  • πŸ“± Tablet (768px - 1024px) - Adaptive layout
  • πŸ’» Desktop (> 1024px) - Full feature set

🎨 Customization

Colors

Edit tailwind.config.ts to customize the color scheme:

colors: {
  primary: '#6366f1',    // Indigo
  secondary: '#a855f7',  // Purple
  accent: '#ec4899',     // Pink
}

Fonts

Modify app/layout.tsx to change fonts:

import { Inter } from 'next/font/google'

Animations

Adjust animation timings in app/globals.css:

.animate-gradient {
  animation: gradient-shift 15s ease infinite;
}

πŸ§ͺ Development Scripts

# Development
pnpm dev              # Start dev server
pnpm dev --turbo      # Start with Turbopack

# Building
pnpm build            # Create production build
pnpm start            # Start production server

# Code Quality
pnpm lint             # Run ESLint

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


πŸ‘¨β€πŸ’» Author

dinhdev-nu


πŸ™ Acknowledgments


πŸ“ž Support

If you have any questions or need help, feel free to:


⭐ Star this repo if you find it helpful!

Made with ❀️ by dinhdev-nu

About

Modern real-time chat UI built with Next.js 15 and TypeScript. Designed to work seamlessly with the chat-app-realtime backend and authentication system.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages