Git Product home page Git Product logo

hedwig's Introduction

Hedwig ๐Ÿฆ‰๐Ÿ’ฌ

Hedwig, the messenger is an asynchronus web-server to support chat-applications having multiple rooms/groups, each having two or more participants.

Hedwig is built using FastAPI and websockets. MongoDB is used as the persistent storage, whereas Redis is used as the caching layer for messages - its Pub/Sub feature is used for triggering sending/receiving of messages.

Flow-Diagram

Use-Case

Ideal use-case of Hedwig would be when you have to add chat-rooms in various parts of your app or website, which is not chatting platform per se.
Hedwig opens a new webosocket connection for every chat room. This has been done intentionally so that resources are not wasted (in maintaining websocket-connections) when chatting features are not being used.

Usage

  • Install the dependencies (mentioned in pyproject.toml and poetry.lock)
    If you're using poetry, just run poetry install
  • The project needs a mongoDB server and a Redis server running.
    Hedwig picks up these environment variables: MONGODB_URI, REDIS_URL
    You can also just create a .env file and add them like these so you don't have to set them again and again
MONGODB_URI=...
REDIS_URL=...
  • Run the server
uvicorn main:app
  • Create a chat-room by making a POST request on /chat-room/create
  • Open a websocket connection and chat on /chat-room/{chat_room_id}/chat?user_id={user_id}
    • Incoming Messages Format:
      {
        "time": timestamp,
        "text": "text message"
      }
    • Outgoing Messages Format:
      {
        "user": "user_id",
        "time": timestamp,
        "text": "text message"
      }

hedwig's People

Contributors

vibhu-agarwal 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.