The Chat API, developed in Ruby and utilizing the Roda framework, enables the creation and management of chatrooms with real-time communication capabilities. It facilitates chatroom operations through HTTP requests, with JSON data exchange, and includes a simple file-based persistent data storage.
- Chatroom Creation: Users can initiate new chatrooms.
- Retrieving Chatroom Details: Users can request the information of a chatroom
- Listing All Chatrooms: Users can get a list of all available chatrooms
- Persistent Storage: Chatrooms and messages are stored in a file system for durability.
- Ruby environment
- Bundler for Ruby dependency management
git clone https://github.com/yourusername/chats-api.git
cd chats-api
bundle install
rake run:dev
To create a chatroom, send a POST request with the chatroom's name and initial members:
http POST /api/v1/chatrooms name="Chatroom Example" members:='["user1","user2"]'
Positive Response:
{
"message": "Chatroom created"
"id" : "<the assigned id of the chatroom>"
}
Retrieve the details of a specific chatroom by its ID:
http GET /api/v1/chatrooms/chatroom_id
List the IDs of all chatrooms:
http GET /api/v1/chatrooms
Response Example:
{
"chatroom_ids": ["generated_chatroom_id1", "generated_chatroom_id2"]
}
Chatroom:
{
"id": "generated_chatroom_id",
"name": "Chatroom Example",
"members": [
"user1",
"user2"
],
"message_count": 2,
"messages": [
{
"id": 1,
"content": "Hello, World!",
"sender_id": "user1",
"timestamp": "2024-04-16T12:34:56+00:00"
},
{
"id": 2,
"content": "Hi there!",
"sender_id": "user2",
"timestamp": "2024-04-16T12:35:01+00:00"
}
]
}
Message:
{
"id": 1,
"content": "Hello, World!",
"sender_id": "user1",
"timestamp": "2024-04-16T12:34:56+00:00"
}
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.