Skip to content

VyacheslavShrot/messenger

Repository files navigation

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