This project is a cloud-based Optical Character Recognition (OCR) system designed to process images and extract text in multiple languages. It is built using a microservices architecture and deployed on Kubernetes. The system leverages React for the frontend, Flask for the backend, and Tesseract for OCR processing.
- Features
- Architecture
- Prerequisites
- Setup Instructions
- Scaling and Monitoring
- Troubleshooting
- Contributing
- License
- Multi-language OCR processing (English, Hindi, Chinese, and Spanish).
- Scalable architecture using Kubernetes.
- Frontend for image upload and text display.
- Google Cloud Storage for image management.
- MongoDB for result storage.
- RabbitMQ for asynchronous task handling.
-
Frontend:
- Built with React.
- Users can upload images and retrieve processed text.
-
Backend:
- Flask-based API.
- Manages image uploads, queues tasks, and fetches results.
-
Worker:
- Python-based processing service.
- Retrieves images from Google Cloud Storage, performs OCR, and stores results in MongoDB.
-
Database:
- MongoDB stores extracted text and metadata.
-
Queue:
- RabbitMQ handles asynchronous task distribution.
-
Storage:
- Google Cloud Storage stores uploaded images.
-
Tools and Dependencies:
- Docker
- Kubernetes (Minikube for local setup)
- Node.js (18+)
- Python (3.10+)
- Google Cloud SDK
- MongoDB Community Edition
- RabbitMQ
-
Environment Configuration:
- Service account JSON for Google Cloud Storage.
- Kubernetes cluster setup (local or cloud).
git clone https://github.com/your-repo/ocr-system.git
cd ocr-systemNode.js
sudo apt update
sudo apt install -y nodejs npmInstall Python and dependencies:
sudo apt update
sudo apt install -y python3 python3-pip
pip install flask pymongo pika google-cloud-storage pytesseractInstall Docker following the official guide.
Install Minikube:
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikubedocker build -t ocr-frontend ./frontenddocker build -t ocr-backend ./backenddocker build -t ocr-worker ./workerdocker tag ocr-backend gcr.io/<project-id>/ocr-backend
docker push gcr.io/<project-id>/ocr-backendIf your project includes a Makefile, you can use the following commands to build and push the images:
make build
make push- Navigate to Google Cloud Console.
- Create a service account with "Storage Admin" permissions.
- Download the service account key as a JSON file.
gsutil mb -p <your-project-id> gs://<bucket-name>kubectl create secret generic google-credentials \
--from-file=key.json=/path/to/your-service-account-key.jsonkubectl get secretskubectl apply -f k8s/mongodb-deployment.yaml
kubectl apply -f k8s/rabbitmq-deployment.yaml
kubectl apply -f k8s/backend-deployment.yaml
kubectl apply -f k8s/worker-deployment.yaml
kubectl apply -f k8s/frontend-deployment.yamlkubectl get pods
kubectl get servicesminikube startminikube service ocr-frontendkubectl port-forward service/ocr-frontend 8080:80kubectl scale deployment ocr-worker --replicas=3kubectl logs <pod-name>kubectl autoscale deployment ocr-worker --cpu-percent=50 --min=1 --max=5Check pod status:
kubectl get podsView logs:
kubectl logs <pod-name>Use Minikube service:
minikube service ocr-frontendVerify frontend build:
npm run buildCheck RabbitMQ logs:
kubectl logs <rabbitmq-pod-name>- Fork the repository.
- Create a new branch:
git checkout -b feature-name
- Commit changes:
git commit -m "Added feature-name" - Push changes and open a pull request.
This project is licensed under the MIT License. See LICENSE for details.