- The part of the backend that describes the basic functionality of the messenger
- I have described in detail how to use the APIs of this project in the Postman documentation :
- Also in the image on my Docker Hub is always the latest version of the code using the GitHub CD :
-
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
- the same PyTest tests are used
- CD:
- pushing an image to my Docker Hub
- pushing an image to my Docker Hub
- CI:
-
There are 2 main kinds of APIs here:
-
For User:
- APIs for registration and login with obtaining JWT token for user
authorization
- 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
- aiocache is also used to record and if available, take messages from
the cache
- APIs for creating chat, get messages, and sending messages
-
-
Also added a manifest for kubernetes (which I will still improve)
-
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 )
- 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)
- MONGO_INITDB_ROOT_USERNAME
- for this container we write:
-
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
- ME_CONFIG_MONGODB_ADMINUSERNAME ( use the same data as for image 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