This is a Next.js-based Chat Application that connects to a backend API built with FastAPI, supporting real-time messaging, user presence updates, and multimedia content (text, image, audio). It also integrates WebSockets for real-time updates and ensures a seamless user experience.
- ⚙️ Prerequisites
- 🛠️ Installation
- 🚀 Running the Project
- 📡 WebSocket Integration
- 💻 Available Scripts
- 📖 Project Features
- 📝 API Reference
- 🙌 Contributing
- 📜 License
Make sure you have the following tools installed:
- Node.js v18+
- npm v8+
- Docker (optional but recommended for backend API)
- Backend API running on
http://localhost:8000(follow backend setup instructions if not already running)
Clone the repository:
git clone <repository-url>
cd <repository-folder>Install the project dependencies:
npm install
# or
yarn install
# or
pnpm install
Start the development server:
npm run dev
# or
yarn dev
# or
pnpm devOpen your browser and visit:
Environment Variables
Ensure you have the following environment variables in a .env.local file:
NEXT_PUBLIC_API_URL=http://localhost:8000The application supports real-time updates via WebSockets. The WebSocket server must be accessible at:
ws://localhost:8000/ws/{chat_id}Replace {chat_id} with the appropriate chat identifier.
npm run dev:Starts the development server.npm run build:Builds the application for production.npm start:Starts the production server.npm run lint:Runs ESLint for code quality checks.
- Create and join chat rooms.
- Real-time messaging (text, image, audio).
- User presence indicators: Online, Offline, Typing.
- Message read receipts.
- Interactive design with TailwindCSS.
- Smooth animations for chat events.
- Responsive layout for mobile and desktop.
- Real-time updates via WebSocket for:
- Messages
- User presence
- Read receipts
- Modular architecture.
- Clean and reusable components.
- TypeScript for robust typing and maintainability.
The application communicates with a FastAPI backend. Below are the key endpoints:
- Method:
POST - Endpoint:
/chats - Body:
{ "participants": ["user1", "user2"] }
- Method:
GET - Endpoint:
/chats
- Method:
GET - Endpoint:
/chats/{chat_id}/messages
- Method:
POST - Endpoint:
/chats/{chat_id}/messages - Body:
{ "user_id": "user1", "type": "text", "content": "Hello!" }
- Method:
POST - Endpoint:
/chats/{chat_id}/presence - Body:
{ "user_id": "user1", "status": "online" }
- Method:
POST - Endpoint:
/chats/{chat_id}/read - Body:
{ "user_id": "user1", }
📚 Refer to the backend documentation for more details.
We welcome contributions! Follow these steps to contribute:
-
Fork the Repository
Click on the Fork button at the top-right corner of this repository. -
Clone Your Fork
git clone https://github.com/your-username/project-name.git
-
Create a New Branch
git checkout -b feature/new-feature
-
Make Your Changes Implement your feature or fix.
-
Commit Your Changes
git commit -m "Add new feature" -
Push to Your Fork
git push origin feature/new-feature
-
Submit a Pull Request Open a Pull Request from your branch to the main repository.
This project is licensed under the MIT License.
