How codesparadox/dockerproject works
Project Type and Purpose
• This is a containerized microservices project (“Polybot Service”) that implements a Telegram chatbot for image processing.
• It consists of three primary services:
• polybot – a Telegram bot that accepts images, manages uploads and orchestrates requests
• yolo5 – an object‐detection microservice based on the YOLOv5 AI model
• mongo – a MongoDB replica‐set cluster for persisting results and metadata
File‐Structure Analysis
• Top‐level files/directories:
• .github/workflows – CI/CD workflows (auto test, deploy, Slack notifications)
• docker-compose.yaml / docker-compose-dev.yaml – orchestrates the three services locally/in dev
• polybot/ – bot code, Dockerfile, Python modules (app.py, bot.py, img_proc.py)
• yolo5/ – object‐detection service code, Dockerfile, requirements
• test/ – end-to-end automation script for compose project
• Patterns/Components:
• Each service is self‐contained with its own Dockerfile and requirements.txt
• docker-compose defines services, networks, volumes, and environment variables via a .env file
• CI/CD uses GitHub Actions to build images, push to registry, and deploy to an EC2 via SSH
Insights from README
• The README describes multi-container microservices, S3 as external storage for images, and MongoDB HA cluster for persistence.
• polybot interacts with Telegram API, uploads to S3, then calls yolo5’s HTTP /predict endpoint.
• yolo5 downloads the image from S3, runs inference, stores results (images & JSON) locally, returns JSON.
• polybot then records results in MongoDB and replies to the Telegram client.
• Deployment targets: Docker Compose on EC2, secrets managed via .env and GitHub Actions secrets, CI/CD pipeline for automated builds & deployment.
Main Components
a. Telegram Client & Bot Platform (external)
b. polybot Service
– Processes Telegram webhooks
– Downloads images from Telegram
– Uploads to AWS S3
– Calls yolo5 /predict
– Writes metadata / results to MongoDB
– Sends responses back to Telegram
c. yolo5 Service
– Flask HTTP server
– Retrieves images from S3
– Runs YOLOv5 model
– Saves annotated image & JSON locally
– Returns detection JSON
d. MongoDB Replica Set
– Three containerized nodes with persistent volumes
e. AWS S3 Bucket (external storage)
f. CI/CD Pipeline (GitHub Actions)
– project_auto_testing.yaml – runs automated tests
– service-deploy.yaml – builds Docker images, pushes to DockerHub/ECR, SSH-deploys Docker Compose to EC2
g. Docker Compose Orchestrator on EC2
h. Docker Registry (DockerHub or ECR)
Relationships and Data Flow
1. User → Telegram API → polybot webhook
2. polybot downloads image → S3 (PUT)
3. polybot → HTTP POST → yolo5 /predict (imgName param)
4. yolo5 → S3 (GET image) → YOLO inference → writes outputs → HTTP response JSON
5. polybot parses JSON → Writes to MongoDB → Replies to user via Telegram API
6. Developer → git push → GitHub Actions → build & push images → SSH → EC2: docker-compose pull & up
Architectural Patterns and Principles
• Microservices: each component in its own container with a single responsibility
• Event/request flow via HTTP REST calls and external storage (S3)
• Data persistence via a replicated NoSQL database (MongoDB replica set)
• Composition + orchestration with Docker Compose
• Infrastructure as code + GitOps via GitHub Actions
Technologies, Frameworks, Libraries
• Python & Flask (polybot.app.py, yolo5.app.py)
• python‐telegram-bot library (polybot/bot.py)
• ultralytics/yolov5 model (via base Docker image)
• MongoDB 5.x with replica sets (docker-compose)
• AWS S3 for object storage
• Docker, Docker Compose
• GitHub Actions for CI/CD