A modern, responsive chat application built with Next.js, React, and TypeScript. Features real-time messaging, file uploads, user authentication, and a clean modular architecture.
-
Real-time Chat: Instant messaging with smooth user experience
-
File Upload: Support for file attachments with Cloudinary integration
-
User Authentication: Secure authentication with Clerk
-
Responsive Design: Mobile-first design with collapsible sidebar
-
Message Management: Edit and delete messages
-
Memory Integration: AI-powered chat with Mem0 integration
-
Modern UI: Clean, dark theme with smooth animations
-
Frontend: Next.js 14, React 18, TypeScript
-
Styling: Tailwind CSS
-
Authentication: Clerk
-
Database: MongoDB
-
File Storage: Cloudinary
-
AI: Google Generative AI
-
Memory: Mem0
-
Package Manager: Bun
Before you begin, ensure you have the following installed:
git clone https://github.com/Tushar98644/wordsy.git
bun install
Create a .env.local file in the root directory and add the following environment variables:
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=
CLERK_SECRET_KEY=
MEM0_API_KEY=
CLOUDINARY_CLOUD_NAME=
CLOUDINARY_API_KEY=
CLOUDINARY_API_SECRET=
GOOGLE_GENERATIVE_AI_API_KEY=
MONGODB_URI=
NEXT_PUBLIC_BASE_URL=
-
Sign up at Clerk.com
-
Create a new application
-
Copy the publishable key and secret key to your .env.local
-
Sign up at Cloudinary.com
-
Get your cloud name, API key, and API secret from the dashboard
-
Add them to your .env.local
-
Local MongoDB: Install MongoDB locally or use MongoDB Compass
-
MongoDB Atlas: Create a free cluster at MongoDB Atlas
-
Add the connection string to your .env.local
-
Go to Google AI Studio
-
Create an API key
-
Add it to your .env.local
-
Sign up at Mem0.ai
-
Get your API key
-
Add it to your .env.local
bun dev
The application will be available at http://localhost:3000
src
β βββ app
β β βββ api # Versioned API routes
β β β βββ v1
β β β βββ chat
β β β β βββ route.ts
β β β βββ chats
β β β β βββ create
β β β β β βββ route.ts
β β β β βββ list
β β β β β βββ route.ts
β β β β βββ messages
β β β β β βββ route.ts
β β β β βββ route.ts
β β β βββ memory
β β β β βββ route.ts
β β β βββ recall
β β β β βββ route.ts
β β β βββ upload
β β β βββ route.ts
β β βββ chat # Chat page
β β β βββ page.tsx
β β βββ globals.css
β β βββ landing # Landing page
β β β βββ page.tsx
β β βββ layout.tsx
β β βββ page.tsx
β β βββ sign-in # Sign in page
β β βββ page.tsx
β βββ components # Components grouped by feature
β β βββ chat-window
β β β βββ chat-area.tsx
β β β βββ chat-interface.tsx
β β β βββ empty-state.tsx
β β β βββ header.tsx
β β β βββ main-content.tsx
β β β βββ mobile-sidebar-toggle.tsx
β β β βββ mobile-sidebar.tsx
β β β βββ top-controls.tsx
β β βββ icons # Custom Icons
β β β βββ GptsIcon.tsx
β β β βββ LibraryIcon.tsx
β β β βββ LogoIcon.tsx
β β β βββ NewChatIcon.tsx
β β β βββ SearchIcon.tsx
β β β βββ SettingsIcon.tsx
β β β βββ SoraIcon.tsx
β β βββ input # Input components
β β β βββ chat-control.tsx
β β β βββ chat-input.tsx
β β β βββ editing-banner.tsx
β β β βββ file-card.tsx
β β β βββ file-preview.tsx
β β β βββ loading-indicator.tsx
β β β βββ submit-button.tsx
β β β βββ voice-control.tsx
β β βββ login-form.tsx
β β βββ messages # Message components
β β β βββ document-file.tsx
β β β βββ file-attachment.tsx
β β β βββ image-file.tsx
β β β βββ message-action.tsx
β β β βββ message-container.tsx
β β β βββ message-content.tsx
β β β βββ message-files.tsx
β β β βββ message.tsx
β β βββ sidebar # Sidebar components
β β β βββ bottom-section.tsx
β β β βββ chat-item.tsx
β β β βββ chat-list.tsx
β β β βββ quick-actions.tsx
β β β βββ sidebar.tsx
β β β βββ top-section.tsx
β β βββ ui # External UI components
β β β βββ button.tsx
β β β βββ input.tsx
β β βββ welcome-modal.tsx
β βββ config # Configuration files for services
β β βββ cloudinary-config.ts
β β βββ gemini.ts
β βββ context # Contexts for the application
β β βββ chat-context.tsx
β β βββ ui-context.tsx
β βββ hooks # Custom hooks for the application
β β βββ index.ts
β β βββ useAutoScroll.ts
β β βββ useChatInput.ts
β β βββ useChatManager.ts
β β βββ useClickOutside.ts
β β βββ useChats.ts
β β βββ useFileUpload.ts
β β βββ useKeyboardHandlers.ts
β β βββ useMessageActions.ts
β β βββ useMessageContainer.ts
β β βββ useMobileSidebar.ts
β βββ lib # Major business logic
β β βββ chat
β β β βββ chat-service.ts
β β β βββ memory-service.ts
β β β βββ message-processor.ts
β β βββ cloudinary.ts
β β βββ db.ts
β β βββ memory
β β β βββ client.ts
β β β βββ service.ts
β β β βββ validation.ts
β β βββ memory.ts
β β βββ utils.ts
β βββ middleware.ts # Auth middleware (Clerk)
β βββ models # MongoDB models
β β βββ chat.ts
β βββ types # TypeScript types
β β βββ chat.ts
β β βββ file.ts
β β βββ index.ts
β β βββ input.ts
β β βββ memory.ts
β β βββ message.ts
β βββ utils # Utility functions
β βββ chatApi.ts
β βββ clipboard.ts
β βββ file.ts
β βββ memory.ts
-
Sign Up/Login: Use Clerk authentication to create an account
-
Start Chatting: Type messages in the input field
-
Upload Files: Click the attachment button to upload files
-
Mobile Navigation: Use the hamburger menu on mobile devices
-
Message Actions: Edit or delete your messages using the action buttons
# Start development server bun dev
# Build for production bun run build
# Start production server bun start
# Run type checking bun run type-check
# Run linting bun run lint
-
Contexts: React Context for state management (no prop drilling)
-
Components: Modular, reusable UI components
-
Hooks: Custom hooks for business logic
-
TypeScript: Full type safety throughout the application
-
Push your code to GitHub
-
Import your repository on Vercel
-
Add your environment variables in the Vercel dashboard
-
Deploy!
The application can be deployed on any platform that supports Next.js:
-
Netlify
-
Railway
-
DigitalOcean App Platform
-
AWS Amplify
| Variable | Description | Required | Example |
|---|---|---|---|
| NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY | Clerk public key | β | pk_test_... |
| CLERK_SECRET_KEY | Clerk secret key | β | sk_test_... |
| MEM0_API_KEY | Mem0 AI memory API key | mem0_... | |
| CLOUDINARY_API_KEY | Cloudinary API key | β | 123456789... |
| CLOUDINARY_API_SECRET | Cloudinary API secret | β | abc123... |
| GOOGLE_GENERATIVE_AI_API_KEY | Google AI API key | β | AIza... |
| MONGODB_URI | MongoDB connection string | β | mongodb://... |
| NEXT_PUBLIC_BASE_URL | Application base URL | β | http://localhost:3000 |
-
Dependencies not installing
rm -rf node_modules rm bun.lockbbun install -
Environment variables not loading
-
Ensure
.env.localis in the root directory -
Restart the development server after changes
-
Check for typos in variable names
-
-
Database connection issues
-
Verify MongoDB is running (if using local)
-
Check MongoDB URI format
-
Ensure network access for MongoDB Atlas
-
-
Authentication not working
-
Verify Clerk keys are correct
-
Check domain settings in Clerk dashboard
-
Ensure
NEXT_PUBLIC_BASE_URLmatches your domain
-
-
Fork the repository
-
Create a feature branch
git checkout -b feature/amazing-feature -
Commit your changes
git commit -m 'Add 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.
If you have any questions or need help with setup, please:
-
Check the troubleshooting section above
-
Search existing issues on GitHub
-
Create a new issue with detailed information
Built with β€οΈ using Next.js, vercel AI sdk, Clerk, MongoDB, Cloudinary, Google Gemini, Mem0, TypeScript