Chat system API built with Ruby on Rails, containerized using Docker, and utilizing MySQL, Elasticsearch, and Redis. The system supports creating applications, chats, and messages, with features such as unique identifiers, message search capabilities, race condition handling, and background job processing using a queue system.
The Chat System API app is designed to handle the creation of applications, chats, and messages, with the following key features:
- Each application has a unique token for identification.
- Chats and messages within an application are uniquely numbered.
- Messages can be searched using Elasticsearch.
- Background jobs are used to update chat and message counts.
- The system is containerized for easy setup and deployment.
-
Start the application using Docker:
docker-compose up
-
The API will be accessible at
http://localhost:3000.
-
Create Application
POST /applications
Request Body:
{ "name": "Application Name" } -
Get Applications
GET /applications
-
Create Chat
POST /applications/:application_token/chats
-
Get Chats
GET /applications/:application_token/chats
-
Create Message
POST /applications/:application_token/chats/:chat_number/messages
-
Get Messages
GET /applications/:application_token/chats/:chat_number/messages
-
Search Messages
GET /applications/:application_token/chats/:chat_number/messages/search?query='your text'
Query Parameters:
query: The search query string to partially match messages' bodies.
To facilitate testing, a Postman collection is provided. This collection includes pre-configured requests for all available endpoints, making it easier to test and verify the functionality of the API.
- Open Postman.
- Click on the
Importbutton. - Select the provided Postman collection file (
Chat_system_challenge.postman_collection.json). - Once imported, you will see a collection named "Chat_system_challenge" with all the endpoints ready for testing.