Skip to content
This repository was archived by the owner on Jun 24, 2024. It is now read-only.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chat Application API Documentation

Overview

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.

Table of Contents

  1. API Endpoints
  2. Setup and Running the API
  3. Testing the API

API Endpoints

Chat Rooms

  • 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"
      }
  • 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"
      }
  • 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"
      }

Messages

  • 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"
      }
  • 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"
      }
  • 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"
      }
  • 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"
        }
      ]

Setup and Running the API

Prerequisites

  • Docker
  • Docker Compose
  • Poetry

Steps

  1. Clone the Repository:

    git clone https://github.com/basola21/ArkLeap-Chat.git
    cd chatapp
  2. Configure Environment Variables: Create a .env file 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
    
  3. Install Dependencies:

    poetry install
    
  4. Run the Application with Docker:

    docker compose up
    
  5. Access the API Documentation:

Testing the API

Running Tests

Run the tests using Django's test framework:

poetry run python manage.py test

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages