A fully functional, responsive, and visually appealing frontend for a Gemini-style conversational AI chat application built with Next.js 15, TypeScript, Tailwind CSS, and Zustand.
- OTP-based Login/Signup with country code selection
- Country Data Integration from REST Countries API
- Form Validation using React Hook Form + Zod
- Simulated OTP generation and validation
- Chatroom Management - Create, delete, and manage chatrooms
- Search Functionality - Debounced search to filter chatrooms
- Toast Notifications for user feedback
- Responsive Design for mobile and desktop
- Real-time Messaging with simulated AI responses
- Message Features:
- Timestamps and message grouping
- Copy-to-clipboard on hover
- Image upload support (base64)
- Typing indicator ("Gemini is typing...")
- Infinite Scroll for loading older messages
- Auto-scroll to latest messages
- Dark Mode Toggle with persistent theme
- Mobile Responsive design
- Loading Skeletons for better UX
- Keyboard Accessibility for all interactions
- LocalStorage Persistence for auth and chat data
This project follows security best practices:
- No environment files in version control: All
.env*files are excluded from git - API key protection: Sensitive credentials are only stored locally
- Documentation over examples: Setup instructions provided without exposing actual keys
Important: Never commit your .env.local file or any files containing API keys to version control.
- Framework: Next.js 15 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS
- State Management: Zustand
- Form Validation: React Hook Form + Zod
- Icons: Lucide React
- Notifications: React Hot Toast
-
Clone the repository:
git clone <repository-url> cd MuseAI
-
Install dependencies:
npm install
-
Set up environment variables: Create a
.env.localfile in the root directory and add the following variables:# Gemini AI Configuration NEXT_PUBLIC_GEMINI_API_KEY=your_gemini_api_key_here GEMINI_API_KEY=your_gemini_api_key_here # CometChat Configuration NEXT_PUBLIC_COMETCHAT_APP_ID=your_cometchat_app_id NEXT_PUBLIC_COMETCHAT_REGION=your_cometchat_region NEXT_PUBLIC_COMETCHAT_AUTH_KEY=your_cometchat_auth_key
β οΈ Security Note: Never commit environment files to version control. SeeENVIRONMENT.mdfor detailed setup instructions.Getting API Keys:
- Gemini API: Get your API key from Google AI Studio
- CometChat: Sign up at CometChat and create an app to get your credentials
-
Start the development server:
npm run dev
-
Open http://localhost:3000 in your browser.
src/
βββ app/ # Next.js app router
β βββ globals.css # Global styles
β βββ layout.tsx # Root layout
β βββ page.tsx # Home page
βββ components/
β βββ auth/ # Authentication components
β β βββ AuthPage.tsx
β β βββ PhoneForm.tsx
β β βββ OTPForm.tsx
β βββ dashboard/ # Dashboard components
β β βββ Dashboard.tsx
β β βββ Header.tsx
β β βββ Sidebar.tsx
β β βββ ChatInterface.tsx
β β βββ MessageList.tsx
β β βββ MessageBubble.tsx
β β βββ MessageInput.tsx
β β βββ TypingIndicator.tsx
β βββ providers/ # Context providers
β β βββ ThemeProvider.tsx
β βββ ui/ # Reusable UI components
β βββ LoadingSkeleton.tsx
βββ lib/ # Utilities and configurations
β βββ utils.ts # Helper functions
β βββ validations.ts # Zod schemas
βββ stores/ # Zustand stores
βββ authStore.ts # Authentication state
βββ chatStore.ts # Chat state
βββ themeStore.ts # Theme state
- Phone Number Entry with country selection
- OTP Generation and display (for demo purposes)
- OTP Validation with error handling
- Persistent Login state
- Chatroom Creation with validation
- Message Sending with image support
- AI Response Simulation with throttling
- Message History with pagination
- Real-time UI Updates
- Responsive Design for all screen sizes
- Dark/Light Mode toggle
- Loading States and skeletons
- Error Handling with user feedback
- Keyboard Navigation support
The application now features real AI integration with Google's Gemini AI API for intelligent responses instead of hardcoded messages.
-
Get a Gemini API Key:
- Visit Google AI Studio
- Sign in with your Google account
- Create a new API key
-
Configure the API Key:
# Create a .env.local file in the root directory # See ENVIRONMENT.md for detailed setup instructions # Add your API key to .env.local GEMINI_API_KEY=your_actual_api_key_here
-
Restart the development server:
npm run dev
- Contextual Responses: The AI considers conversation history for more natural interactions
- Intelligent Conversations: Responses are generated based on the actual content of your messages
- Fallback System: If the API is unavailable, the app gracefully falls back to enhanced mock responses
- Security: API calls are made server-side to protect your API key
The application works perfectly without a Gemini API key! It will use enhanced mock responses that simulate intelligent AI behavior, including:
- Context-aware greetings
- Topic-specific responses
- Conversation continuity
- Helpful and engaging interactions
The application is fully responsive with:
- Mobile-first Design approach
- Touch-friendly interface elements
- Collapsible Sidebar for mobile
- Optimized Typography for readability
- Gesture Support for navigation
- Push your code to GitHub
- Connect your repository to Vercel
- Deploy with default Next.js settings
npm run build
npm start-
Authentication:
- Enter any phone number with country code
- Use the displayed OTP (shown in toast notification)
- Successfully log in to access the dashboard
-
Chat Features:
- Create a new chatroom
- Send text messages and images
- Watch for AI responses with typing indicator
- Test search functionality
- Try dark mode toggle
-
Responsive Design:
- Test on mobile and desktop
- Check sidebar behavior
- Verify touch interactions
This project is created for demonstration purposes.
This is a demo project showcasing modern React/Next.js development practices. Feel free to use it as a reference for your own projects.
For questions or issues, please refer to the code comments and implementation details within the source files.