Skip to content

Tushar98644/Wordsy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

99 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Wordsy

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.

πŸš€ Features

  • 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

Live Demo

Wordsy

πŸ› οΈ Tech Stack

  • 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

πŸ“‹ Prerequisites

Before you begin, ensure you have the following installed:

πŸ—οΈ Installation & Setup

1. Clone the Repository

git clone https://github.com/Tushar98644/wordsy.git

2. Install Dependencies

bun install

3. Environment Configuration

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=

4. Set Up Required Services

Clerk Authentication

  1. Sign up at Clerk.com

  2. Create a new application

  3. Copy the publishable key and secret key to your .env.local

Cloudinary (File Storage)

  1. Sign up at Cloudinary.com

  2. Get your cloud name, API key, and API secret from the dashboard

  3. Add them to your .env.local

MongoDB Database

  1. Local MongoDB: Install MongoDB locally or use MongoDB Compass

  2. MongoDB Atlas: Create a free cluster at MongoDB Atlas

  3. Add the connection string to your .env.local

Google Generative AI

  1. Go to Google AI Studio

  2. Create an API key

  3. Add it to your .env.local

Mem0 (Optional)

  1. Sign up at Mem0.ai

  2. Get your API key

  3. Add it to your .env.local

5. Start the Development Server

bun dev  

The application will be available at http://localhost:3000

πŸ“ Project Structure

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

🎯 Usage

  1. Sign Up/Login: Use Clerk authentication to create an account

  2. Start Chatting: Type messages in the input field

  3. Upload Files: Click the attachment button to upload files

  4. Mobile Navigation: Use the hamburger menu on mobile devices

  5. Message Actions: Edit or delete your messages using the action buttons

πŸ”§ Development

Available Scripts

# 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   

Code Organization

  • 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

πŸš€ Deployment

Vercel (Recommended)

  1. Push your code to GitHub

  2. Import your repository on Vercel

  3. Add your environment variables in the Vercel dashboard

  4. Deploy!

Other Platforms

The application can be deployed on any platform that supports Next.js:

  • Netlify

  • Railway

  • DigitalOcean App Platform

  • AWS Amplify

πŸ” Environment Variables Guide

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

πŸ› Troubleshooting

Common Issues

  1. Dependencies not installing

    rm -rf node_modules
    rm bun.lockb
    
    bun install
    
  2. Environment variables not loading

    • Ensure .env.local is in the root directory

    • Restart the development server after changes

    • Check for typos in variable names

  3. Database connection issues

    • Verify MongoDB is running (if using local)

    • Check MongoDB URI format

    • Ensure network access for MongoDB Atlas

  4. Authentication not working

    • Verify Clerk keys are correct

    • Check domain settings in Clerk dashboard

    • Ensure NEXT_PUBLIC_BASE_URL matches your domain

πŸ“ Contributing

  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.

🀝 Support

If you have any questions or need help with setup, please:

  1. Check the troubleshooting section above

  2. Search existing issues on GitHub

  3. Create a new issue with detailed information

Built with ❀️ using Next.js, vercel AI sdk, Clerk, MongoDB, Cloudinary, Google Gemini, Mem0, TypeScript