This API provides endpoints for managing chat rooms and messages. It allows users to create, update, read, and search within chat rooms and messages. The API is built using Django Rest Framework and PostgreSQL, and it is containerized using Docker.
-
Create Chat Room
- URL:
/api/chatrooms/ - Method:
POST - Description: Create a new chat room.
- Request Body:
{ "name": "string" } - Response:
{ "number": "integer", "name": "string", "created_at": "datetime" }
- URL:
-
Update Chat Room
- URL:
/api/chatrooms/{number}/ - Method:
PUT - Description: Update details of an existing chat room.
- Request Body:
{ "name": "string" } - Response:
{ "number": "integer", "name": "string", "created_at": "datetime" }
- URL:
-
Read Chat Room
- URL:
/api/chatrooms/{number}/ - Method:
GET - Description: Retrieve details of a specific chat room.
- Response:
{ "number": "integer", "name": "string", "created_at": "datetime" }
- URL:
-
Create Message
- URL:
/api/messages/ - Method:
POST - Description: Create a new message within a chat room.
- Request Body:
{ "chat_room": "integer", "content": "string" } - Response:
{ "number": "integer", "chat_room": "integer", "content": "string", "created_at": "datetime" }
- URL:
-
Update Message
- URL:
/api/messages/{number}/ - Method:
PUT - Description: Update content of an existing message.
- Request Body:
{ "content": "string" } - Response:
{ "number": "integer", "chat_room": "integer", "content": "string", "created_at": "datetime" }
- URL:
-
Read Message
- URL:
/api/messages/{number}/ - Method:
GET - Description: Retrieve details of a specific message within a chat room.
- Response:
{ "number": "integer", "chat_room": "integer", "content": "string", "created_at": "datetime" }
- URL:
-
Search Messages
- URL:
/api/messages/{chat_room_id}/search?q=query - Method:
GET - Description: Search messages within a specific chat room by partial match of the message content.
- Response:
[ { "number": "integer", "chat_room": "integer", "content": "string", "created_at": "datetime" } ]
- URL:
- Docker
- Docker Compose
- Poetry
-
Clone the Repository:
git clone https://github.com/basola21/ArkLeap-Chat.git cd chatapp -
Configure Environment Variables: Create a
.envfile in the root directory and add the following:IN_DOCKER=True POSTGRES_DB=chatapp POSTGRES_USER=postgres POSTGRES_PASSWORD=postgres POSTGRES_HOST=db POSTGRES_PORT=5432
-
Install Dependencies:
poetry install
-
Run the Application with Docker:
docker compose up
-
Access the API Documentation:
- Defualt UI: http://localhost:8000/api/
Run the tests using Django's test framework:
poetry run python manage.py test