I came across The Microsoft Azure Trial Hackathon on Dev.to and decided to participate in it by creating this small project.
Working of the bot
Memer Bot will let you search & create memes using thousands of templates & even your own custom images.
Basically, there are three major features -
*/search * command will let you search for a meme for a word/phrase (it will return the top meme if finds for that phrase)
/create command will let you create memes using two options - a Meme Template or a Custom Image
Instructions are fairly straightforward while using these bots.
At any point in time, if you feel, the bot is not responding, do try to use the /reset command and then try to do the operation again.
Submission Category:
Computing Captains
I have chosen Computing Captains category for this contest.
I have leveraged Azure's Azure Kubernetes Service for deploying this project.
Tech Stack
I have used below tech stack to build Memer
Main Stack
NodeJS
Express (using as the main server)
Redis (using as key-value database for user session management)
Telebot (library to interact with Telegram API)
Devops
Docker (for creating images of NodeJs express server)
Kubernetes (using kubernetes via Azure Kubernetes Service to manage containers)
Third Party
Telegram API (to communicate with users)
Imgflip (to search & create memes)
Architecture
Below is the basic architecture of the application:
As you can see there are multiple components here:
NodeJS Server - Communicates with Telegram API & all third party APIs along with managing user sessions using Redis. It is deployed as a Docker container in a kubernetes pod on AKS.
Redis - Used to manage user states & sessions via key value pairs model. It is deployed as a Docker container in a kubernetes pod on AKS.
Imgflip - Used to search & create memes. Actual logic to search and create memes can be found in the GitHub repository.
Telegram API - Used to listen to user's messages & respond to them via Telebot library for NodeJS.
Deployment
To deploy Memer's backend & redis, I created a Dockerfile for NodeJS like this:
apiVersion:apps/v1# API versionkind:Deploymentmetadata:name:redis-master# Unique name for the deploymentlabels:app:redis# Labels to be applied to this deploymentspec:selector:matchLabels:# This deployment applies to the Pods matching these labelsapp:redisrole:mastertier:backendreplicas:1# Run a single pod in the deploymenttemplate:# Template for the pods that will be created by this deploymentmetadata:labels:# Labels to be applied to the Pods in this deploymentapp:redisrole:mastertier:backendspec:# Spec for the container which will be run inside the Pod.containers:-name:masterimage:redisresources:requests:cpu:100mmemory:100Miports:-containerPort:6379---apiVersion:v1kind:Service# Type of Kubernetes resourcemetadata:name:redis-master# Name of the Kubernetes resourcelabels:# Labels that will be applied to this resourceapp:redisrole:mastertier:backendspec:ports:-port:6379# Map incoming connections on port 6379 to the target port 6379 of the PodtargetPort:6379selector:# Map any Pod with the specified labels to this serviceapp:redisrole:mastertier:backend
I created a kubernetes secret to store necessary environment variables' values
Create custom memes by uploading your image and adding text
Tech Stack
NodeJS
Express
Telebot
Redis
Devops
Application has deployed on Microsoft Azure using Azure Kubernetes Services (AKS).
Two deployments created, one for Redis & one for NodeJS express (which is deployed using the docker image)
All environment variables required are stored in the Kubernetes secrets.