Giter Club home page Giter Club logo

chat-api's Introduction

chat-api

概要

これはチャットアプリケーションのサンプルAPIです。以下の機能が含まれています。

  • 1対1のチャット
  • 複数人のグループチャット
  • メッセージの一覧取得、投稿、削除
  • メッセージの未読、既読の確認
  • 新着メッセージの通知
  • 通知設定
    • Push通知
    • メール通知
    • 通知しない

インストール方法

以下の手順でインストールできます。

# リポジトリをクローンします
git clone https://github.com/dai175/chat-api.git

# ディレクトリに移動します
cd chat-api

# 環境変数ファイルを作成し、必要に応じて更新します
cp .env.develop .env

# Dockerコンテナを起動します
docker compose up -d

# データベースをセットアップします
docker compose exec api python setup_db.py

Push通知の設定

Push通知にPusherを利用しています。以下の手順で設定が必要です。

  1. Pusherのアカウントを作成します。以下のURLにアクセスしてください。
    https://pusher.com/beams/
  2. インスタンスを作成してください。
  3. Overview画面からWebの通知設定を行ってください。
  4. Key画面からInstance ID、Primary Keyを確認し、.envファイルに以下の内容を追記してください。
    PUSHER_INSTANCE_ID=xxxxxx(Instance ID)
    PUSHER_SECRET_KEY=xxxxxx(Primary Key)
    

動作確認

  1. ユーザーを作成します。以下のURLにアクセスし、POST /registerから作成してください。
    http://localhost:8000/docs#
  2. ログイン画面からメールアドレスとパスワードを入力してログインします。以下のURLにアクセスしてください。
    http://localhost:8000
  3. チャット画面からチャットを開始します。具体的な手順は以下の通りです。
    • グループチャット
      1. Chat TypeからGroup Chatを選択します。
      2. Room IDに部屋番号(任意の文字列)を入力します。
      3. Connectボタンをクリックします。
      4. Messageにメッセージを入力し、Sendボタンで送信します。
    • ダイレクトチャット
      1. Chat TypeからDirect Chatを選択します。
      2. Receiver IDに相手のユーザーID(UUID)を入力します。
      3. Connectボタンをクリックします。
      4. Messageにメッセージを入力し、Sendボタンで送信します。
  4. 開発用メールサーバーとしてMailHogを利用しています。メール通知を確認するには、以下のURLにアクセスしてください。
    http://localhost:8025

その他

テストコードは未作成です。

chat-api's People

Contributors

dai175 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.