{"id":26932316,"url":"https://github.com/zakigit1/chatapp-laravelapi","last_synced_at":"2025-04-02T08:19:08.802Z","repository":{"id":228685233,"uuid":"774655912","full_name":"zakigit1/ChatApp-LaravelAPI","owner":"zakigit1","description":"A scalable and efficient RESTful API for real-time chat applications, built using Laravel and Sanctum.","archived":false,"fork":false,"pushed_at":"2025-03-19T00:00:26.000Z","size":152,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-19T01:20:04.605Z","etag":null,"topics":["authentication","chat-application","laravel","messaging","notifications","pusher","real-time","restful-api"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zakigit1.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-19T23:44:35.000Z","updated_at":"2025-03-19T00:00:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"422f167f-6c73-4d44-9360-65fc922a447e","html_url":"https://github.com/zakigit1/ChatApp-LaravelAPI","commit_stats":null,"previous_names":["zakigit1/chat-app-laravel-api","zakigit1/chatapp-laravelapi"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakigit1%2FChatApp-LaravelAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakigit1%2FChatApp-LaravelAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakigit1%2FChatApp-LaravelAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zakigit1%2FChatApp-LaravelAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zakigit1","download_url":"https://codeload.github.com/zakigit1/ChatApp-LaravelAPI/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246777815,"owners_count":20832033,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["authentication","chat-application","laravel","messaging","notifications","pusher","real-time","restful-api"],"created_at":"2025-04-02T08:19:08.226Z","updated_at":"2025-04-02T08:19:08.797Z","avatar_url":"https://github.com/zakigit1.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Chat Application API with Laravel 📱\n\n  [![Laravel Version](https://img.shields.io/badge/Laravel-10.x-red.svg)](https://laravel.com)\n  [![PHP Version](https://img.shields.io/badge/PHP-8.1+-blue.svg)](https://php.net)\n  [![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE)\n  [![Contributors](https://img.shields.io/github/contributors/zakigit1/Chat-App-Laravel-API)](https://github.com/zakigit1/ZAKA-eCommerce/graphs/contributors)\n\nA robust and scalable **RESTful API** for building real-time chat applications powered by **Laravel**. This project provides the backend infrastructure for messaging systems, enabling seamless communication between users with features like real-time messaging and notifications, user authentication, and message history.\n\n\n---\n\n## Features\n\n### Core Functionalities\n- **Real-Time Messaging**: Leverages WebSockets (via Pusher) for instant message delivery.\n- **User Authentication**: Secure user registration and login using Laravel Sanctum.\n- **Message History**: Stores and retrieves chat history using a relational database (MySQL).\n- **RESTful Endpoints**: Well-defined API endpoints for sending, receiving, and managing messages.\n- **Scalable Architecture**: Designed to handle high concurrency and large-scale deployments.\n\n### Unique Selling Points\n- **Modular Design**: Easily extendable for custom features like group chats, file sharing, or chatbots.\n- **Real-Time Notifications**: Notify users of new messages or events in real time using OneSignal.\n- **Cross-Platform Compatibility**: Works seamlessly with web, mobile, and desktop clients.\n\n### Technical Highlights\n- Built with **Laravel 10.x** for robust backend development.\n- Uses **Pusher** for real-time communication.\n- Implements **OneSignal** for push notifications.\n- Implements **RESTful API** standards for easy integration.\n- Supports **MySQL** for reliable data storage.\n\n\u003c!--\n---\n\n## Visual Demonstration\n\n Add screenshots or GIFs here to showcase your project \n![Chat Interface](screenshots/chat-interface.png)  \n*Example of the chat interface.*\n\n![API Documentation](screenshots/api-docs.png)  \n*API documentation generated using Swagger.*\n--\u003e\n\n---\n\n## Installation Instructions\n\n### Prerequisites\n- PHP 8.1 or higher\n- Composer (for dependency management)\n- MySQL 5.7 or higher\n- Node.js and NPM (for front-end assets, if applicable)\n- Pusher account (for real-time messaging)\n- OneSignal account (for push notifications)\n\n### Step-by-Step Setup\n1. **Clone the Repository**:\n   ```bash\n   git clone https://github.com/zakigit1/Chat-App-Laravel-API.git\n   cd Chat-App-Laravel-API\n   ```\n\n2. **Install Dependencies**:\n   ```bash\n   composer install\n   npm install\n   ```\n\n3. **Configure Environment**:\n   - Copy `.env.example` to `.env`:\n     \n     ```bash\n     cp .env.example .env\n     ```\n   - Update `.env` with your database, Pusher, and OneSignal credentials:\n     \n     ```env\n     DB_CONNECTION=mysql\n     DB_HOST=127.0.0.1\n     DB_PORT=3306\n     DB_DATABASE=chat_app\n     DB_USERNAME=root\n     DB_PASSWORD=\n\n     BROADCAST_DRIVER=pusher\n     \n     PUSHER_APP_ID=your-pusher-app-id\n     PUSHER_APP_KEY=your-pusher-app-key\n     PUSHER_APP_SECRET=your-pusher-app-secret\n     PUSHER_APP_CLUSTER=mt1\n     ```\n\n4. **Generate Application Key**:\n   ```bash\n   php artisan key:generate\n   ```\n\n5. **Run Migrations**:\n   ```bash\n   php artisan migrate\n   ```\n\n6. **Start the Development Server**:\n   ```bash\n   php artisan serve\n   ```\n\n---\n\n## Usage Guide\n\n### Getting Started\n1. **Register a User**:\n   - Use the `/api/register-user` endpoint to create a new user.\n     \n   ```bash\n   curl -X POST http://localhost:8000/api/register-user \\\n        -H \"Content-Type: application/json\" \\\n        -d '{\"email\": \"john@example.com\", \"password\": \"password\", \"password_confirmation\": \"password\"}'\n   ```\n\n2. **Login**:\n   - Use the `/api/login-user` endpoint to authenticate.\n     \n   ```bash\n   curl -X POST http://localhost:8000/api/login-user \\\n        -H \"Content-Type: application/json\" \\\n        -d '{\"email\": \"john@example.com\", \"password\": \"password\"}'\n   ```\n\n3. **Create a Chat**:\n   - Use the `/api/chat` endpoint to create a new chat with another user.\n     \n   ```bash\n   curl -X POST http://localhost:8000/api/chat \\\n        -H \"Authorization: Bearer [token]\" \\\n        -H \"Content-Type: application/json\" \\\n        -d '{\"user_id\": 2, \"is_private\": true}'\n   ```\n\n4. **Send a Message**:\n   - Use the `/api/chat_message` endpoint to send a message.\n     \n   ```bash\n   curl -X POST http://localhost:8000/api/chat_message \\\n        -H \"Authorization: Bearer [token]\" \\\n        -H \"Content-Type: application/json\" \\\n        -d '{\"chat_id\": 2, \"message\": \"Hello!\"}'\n   ```\n\n### Example Workflow\n1. Register and log in as a user.\n2. Create a chat with another user.\n3. Send and receive messages in real-time.\n4. Integrate the API with a frontend application for a complete chat experience.\n\n---\n\n## API Documentation\n\nThis project includes comprehensive API documentation that details all available endpoints, request/response formats, and authentication methods.\n\n### Documentation Access\n- **Full Documentation**: See [API_DOCUMENTATION.md](API_DOCUMENTATION.md) for complete API reference.\n\n### Key API Features\n- **Authentication**: Secure token-based authentication using Laravel Sanctum.\n- **Real-time Communication**: WebSocket integration via Pusher for instant messaging.\n- **Push Notifications**: OneSignal integration for mobile and web notifications.\n- **RESTful Design**: Consistent and intuitive API structure.\n\n### Base URL \u0026 Versioning\n- **Base URL:** `http://localhost/api` (Changes based on deployment environment)\n- **Versioning:** All endpoints are prefixed with `/api`\n\n### Essential Endpoints\n\n#### User Management\n- **POST `/api/register-user`**: Register a new user and receive authentication token.\n  ```json\n  // Request\n  {\n    \"email\": \"user@example.com\",\n    \"password\": \"password\",\n    \"password_confirmation\": \"password\"\n  }\n  \n  // Response\n  {\n    \"data\": {\n      \"userData\": {\n        \"username\": \"user\",\n        \"email\": \"user@example.com\"\n      },\n      \"token\": \"1|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"\n    },\n    \"status\": \"sucess\",\n    \"message\": \"User has been register successfully.\"\n  }\n  ```\n\n- **POST `/api/login-user`**: Authenticate a user and receive token.\n- **POST `/api/login-user-WithToken`**: Authenticate using an existing token.\n- **POST `/api/logout-user`**: Invalidate user's authentication token.\n\n#### Chat Management\n- **GET `/api/chat`**: List all chats for the authenticated user.\n- **POST `/api/chat`**: Create a new chat.\n- **GET `/api/chat/{chat_id}`**: Get details of a specific chat.\n\n#### Messaging\n- **GET `/api/chat_message`**: Retrieve messages from a specific chat.\n- **POST `/api/chat_message`**: Send a message to a specific chat.\n\n### Authentication\n- All endpoints (except `/api/register-user` and `/api/login-user`) require a **Bearer Token** for authentication.\n- Include the token in the `Authorization` header of your API requests:\n  ```\n  Authorization: Bearer 1|XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\n  ```\n\n### Status Codes\n- `200 OK`: Request successful\n- `401 Unauthorized`: Authentication required or failed\n- `422 Unprocessable Entity`: Validation errors\n\n### For More Information\nRefer to the [API_DOCUMENTATION.md](API_DOCUMENTATION.md) file for detailed endpoint descriptions, request/response formats, and usage examples.\n\n\n---\n\n## Contributing Guidelines\n\n### Code Style\n- Follow [PSR-12](https://www.php-fig.org/psr/psr-12/) coding standards.\n- Write clear and concise commit messages.\n\n### Development Setup\n1. Fork the repository.\n2. Create a new branch for your feature or bug fix.\n3. Submit a pull request with a detailed description of your changes.\n\n\n\n---\n\n## Troubleshooting\n\n### Common Issues\n1. **Real-Time Messaging Not Working**:\n   - Ensure Pusher credentials are correctly configured in `.env`.\n   - Verify the `BROADCAST_DRIVER` is set to `pusher`.\n   - Check browser console for WebSocket connection errors.\n\n2. **Database Connection Errors**:\n   - Double-check your `.env` database credentials.\n   - Ensure MySQL is running.\n\n3. **Push Notifications Not Received**:\n   - Verify OneSignal configuration.\n   - Check if the user has granted notification permissions.\n\n### Debug Tips\n- Use `php artisan tinker` to interact with your application.\n- Check Laravel logs in `storage/logs/laravel.log`.\n- Enable debug mode in `.env` by setting `APP_DEBUG=true`.\n\n---\n\n## License\n\nThis project is licensed under the **MIT License**. See the [LICENSE](LICENSE) file for details.\n\n---\n\n## Contact and Support\n\n- **Maintainer**: [Mohammed Ilyes Zakarian Bousbaa](https://github.com/zakigit1)\n- **Email**: [mohammedilyeszakaria.bousbaa@gmail.com](mailto:mohammedilyeszakaria.bousbaa@gmail.com)\n- **Support Options**: Open an issue on GitHub or contact the maintainer directly.\n\n---\n\nThank you for using **Chat Application API**! We look forward to your contributions and feedback 💙.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzakigit1%2Fchatapp-laravelapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzakigit1%2Fchatapp-laravelapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzakigit1%2Fchatapp-laravelapi/lists"}