Sign inSign up

vyacheslavshrot/messenger

By vyacheslavshrot

•Updated over 2 years ago

The part of the backend that describes the basic functionality of the messenger

Image
0

870

vyacheslavshrot/messenger repository overview

⁠This Image contains the latest changes from the https://github.com/VyacheslavShrot/messenger⁠ repository

⁠Messenger CI/CD Pulls

⁠Structure

  • This project is written in the latest version of Python 3.11 along with the FastAPI framework

  • All code is asynchronous like my previous projects

  • NoSQL database MongoDB is connected via official images

  • Written easy PyTest tests for a simple notion that everything is working properly

  • CI/CD actions on pull request:

    • CI:
      • the same PyTest tests are used

    • CD:
      • pushing an image to my Docker Hub

  • There are 2 main kinds of APIs here:

    • For User:

      • APIs for registration and login with obtaining JWT token for user authorization

    • For Messages:

      • APIs for creating chat, get messages, and sending messages
        • aiocache is also used to record and if available, take messages from the cache

        • WebSocket is used to implement chat functionality

  • Also added a manifest for kubernetes (which I will still improve)

⁠Launch in Docker-Compose

  • You need to create an .env file at the docker-compose file level and write the variables

  • For this purpose, a ready-made Docker-Compose file has already been built using:

    • image vyacheslavshrot/messenger:latest:

      • for this container, write a SECRET_KEY variable for the JWT token ( it can be a random value )

    • image mongo:

      • for this container we write:
        • MONGO_INITDB_ROOT_USERNAME

        • MONGO_INITDB_ROOT_PASSWORD

        • MONGO_DB_AUTH_SOURCE ( for this variable usually admin value is used)

    • image mongo-express:

      • ME_CONFIG_MONGODB_ADMINUSERNAME ( use the same data as for image mongo )

      • ME_CONFIG_MONGODB_ADMINPASSWORD ( use the same data as for image mongo )

      • ME_CONFIG_MONGODB_SERVER=mongo

  • After installing the environment, we run

docker-compose up -d


  • Go to the mongo-admin panel ( mongo-express container ):

    • Create the base messenger

    • Create 3 collections:

      • users

      • chat

      • messages

  • And at the level of docker-compose.yml create a folder mongodb_data where our data from the database will be stored

Tag summary

Content type

Image

Digest

sha256:914d382c1…

Size

395.5 MB

Last updated

over 2 years ago

docker pull vyacheslavshrot/messenger