Skip to content

Microservices using FastAPI, RabbitMQ, MySql, MongoDB. Converts video to audio and emails user with an id to download the file.

Notifications You must be signed in to change notification settings

nahid111/microservices-python

Repository files navigation

Microservices Architecture in Python


About

This is a FastApi implementation of the video to mp3 converter system demonstrated at Kantan Coding

Components

  • Gateway
    • Gateway to the system for handling all incoming requests from clients.
    • Stores uploaded videos in a MongoDB database.
    • Puts a message in RabbitMQ when a video is uploaded.
  • users-service
    • Responsible for user registration and user authentication.
    • Stores user data in a MySql database.
  • Converter-Service
    • Consumes message from RabbitMQ to get video file ID and downloads the video.
    • Converts the video to mp3 and stores in MongoDB.
    • Puts a message in RabbitMQ with the mp3 file ID.
  • Notification-Service
    • Consumes message from RabbitMQ to get mp3 file ID.
    • Sends email to the client with the mp3 file ID.
    • Client can then send a request to the Api-Gateway with the mp3 file id along with his/her jwt to download the mp3.

Running with docker compose

  • Required envs
    Create a .env file in project root with the values from example.env file
  • Run docker compose
    $ docker compose up
    
    Or run in detached mode
    $ docker compose up -d
    
  • Visit for Api Docs
    http://0.0.0.0:5000/docs
    
  • Cleanup
    $ docker compose down -v
    $ sudo rm -rf volMongo/ volMysql/ volRabbit/
    

Deploy to Kubernetes Cluster (minikube)

  • Build your images and push them to dockerhub
  • Set them appropriately in the deployment yaml files like so
    apiVersion: apps/v1
    ...
    spec:
      ...
      template:
        ...
          containers:
            - image: nahid111/py-micro-users
  • Populate envs properly
    MYSQL_HOST=mysql-service
    RABBITMQ_HOST=rabbitmq
    MONGODB_URL=mongodb://<YOUR_USER>:<YOUR_PASSWORD>@mongodb-service:27017/
  • Change permission for deployment scripts
    $ chmod +x deployment.sh
    $ chmod +x cleanup.sh
    
  • Run ./deployment.sh
  • Use the minikube service url outputted in the terminal
    |-----------|---------------|-------------|---------------------------|
    | NAMESPACE |     NAME      | TARGET PORT |            URL            |
    |-----------|---------------|-------------|---------------------------|
    | default   |gateway-service|        5000 | http://192.168.49.2:30312 |
    |-----------|---------------|-------------|---------------------------|
    
  • For cleaning up, run ./cleanup.sh

About

Microservices using FastAPI, RabbitMQ, MySql, MongoDB. Converts video to audio and emails user with an id to download the file.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published