✨ This project is a real-time messaging application built with Next.js. It allows users to send and receive friend requests, chat in real-time, and view recent conversations. The app uses Redis for managing friend requests and Pusher for real-time messaging.
- Friend Requests: Users can send, accept, and reject friend requests.
- Real-Time Messaging: Chat in real-time with friends using Pusher for instant message delivery.
- User Authentication: Secure user authentication using NextAuth.js.
- Next.js: A React framework for building the application.
- Redis: Used for managing incoming friend requests and storing chat messages.
- Pusher: For real-time messaging functionality.
- NextAuth.js: For user authentication.
- Tailwind CSS: For styling the UI components.
Follow the steps below to set up the project locally.
Before you begin, ensure you have the following installed:
- Node.js (version 16 or higher)
- Redis (installed and running)
- Pusher account (for real-time messaging)
git clone https://github.com/lvnh2003/moodchat.git
cd moodchatRun the following command to install the necessary dependencies:
npm installCreate a .env.local file in the root of your project and add the following environment variables:
# NextAuth.js
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your-nextauth-secret
# Redis
NEXT_PUBLIC_UPSTASH_REDIS_REST_URL=your-redis-url
NEXT_PUBLIC_UPSTASH_REDIS_REST_TOKEN=your-redis-token
NEXT_PUBLIC_GOOGLE_CLIENT_ID=your-google-client-id
NEXT_PUBLIC_GOOGLE_CLIENT_SECRET=your-google-client-secret
#Github
NEXT_PUBLIC_GITHUB_CLIENT_ID=your-github-client-id
NEXT_PUBLIC_GITHUB_CLIENT_SECRET=your-github-client-secret
# Pusher
NEXT_PUBLIC_PUSHER_APP_ID=your-pusher-app-id
NEXT_PUBLIC_PUSHER_APP_KEY=your-pusher-key
NEXT_PUBLIC_PUSHER_APP_SECRET=your-pusher-secret
NEXT_PUBLIC_PUSHER_CLUSTER=your-pusher-cluster
OPENAI_API_KEY=your-api-key
OPENAI_ENDPOINT=your-api-endpoint
OPENAI_MODEL=your-model
Replace the values with your actual Redis and Pusher credentials.
Run the following command to start the development server:
npm run devThis will start the application on http://localhost:3000.
Ensure that Redis is running on your machine. You can download and install Redis from the official website or use a Redis service provider like RedisLabs.
- Sign up for a Pusher account.
- Create a new app and get your App ID, Key, Secret, and Cluster.
- Add these credentials to your
.env.localfile as shown in step 3.
Once everything is set up and the development server is running, you can open the app in your browser:
- Homepage: Displays the list of friends and recent chats.
- Add Friend: Send friend requests to other users.
- Real-Time Chat: Send and receive messages instantly using Pusher.
You can deploy the app to platforms like Vercel or Netlify for production. For Redis, you can use managed Redis services like RedisLabs or Heroku Redis.
- Redis connection issues: Ensure Redis is running locally or connected to a Redis cloud service.
- Pusher not working: Double-check your Pusher credentials and ensure you're using the correct cluster.
- Authentication issues: If you encounter authentication problems, verify that the
NEXTAUTH_SECRETis set correctly in your.env.local.
👤 If you'd like to contribute to the project, feel free to fork the repository and submit pull requests. Please make sure to follow the code style and add tests for new features.