Skip to content

About

A fully Dockerized Flask-based API system for recognizing both Western and Devanagari handwritten digits. It features isolated containers for each model, managed via Docker Compose, and served through a unified UI with Nginx reverse proxy. Designed for local development and easy deployment on AWS EC2, the project supports RESTful API interaction.

Resources

Stars

1 star

Watchers

1 watching

Forks

Latest commit

 

History

9 Commits

Folders and files

Repository files navigation


🧮 Unified Digit Recognition API (Flask + Docker + TensorFlow + AWS)

This project offers a unified interface to recognize handwritten digits in both:

  • 🔢 Western Decimal Digits (0–9)
  • 🕉️ Devanagari Digits (०–९)

It consists of three independent Flask APIs—each containerized with its own TensorFlow version—and a unified interface served via Nginx reverse proxy. All services are orchestrated using Docker Swarm and hosted on a single AWS EC2 instance.

🧪 Note: Local development uses Docker Compose, while deployment on EC2 uses Docker Swarm.


🚀 Features

  • 🧠 Deep learning models using TensorFlow
  • 🐳 Each API containerized with isolated environments
  • ⚡ Unified Flask API interface for model selection
  • 🔁 Nginx reverse proxy to unify routes
  • 🔀 Supports both curl and Postman for requests
  • 🛠️ Orchestrated with Docker Swarm
  • ☁️ Production-ready deployment on AWS EC2

📂 Folder Structure

UnifiedApi/
├── decimal-api/
├── devanagari-api/
├── unified-api/
├── nginx/
├── docker-compose.yml
├── deployment.yml
└── README.md

🧪 Local Development

1. Clone the repository

git clone https://github.com/Bit-Nest/UnifiedApi.git
cd UnifiedApi

2. Build and run locally (development)

docker-compose up --build

3. Access APIs locally

🔌 Port Mappings (Local Only)

Service Port
Unified UI 5300
Decimal API 5100
Devanagari API 5200

📮 Unified API Usage

Endpoint:

POST http://localhost:5300/predict

Form-Data Fields:

Field Type Description
image File Upload a digit image
model_type String decimal or devanagari

Example JSON Response:

{
  "prediction": "204"
}

🧠 Model Requirements

API TensorFlow Version
decimal-api 2.13.0
devanagari-api 2.19.0
unified-api N/A (acts as a router)

☁️ Deployment on AWS EC2 (Docker Swarm + Nginx)

1. SSH into your EC2 instance

ssh -i your-key.pem ubuntu@<EC2_IP>

2. Install Docker, Compose & Swarm

sudo apt update
sudo apt install docker.io docker-compose -y
docker swarm init

3. Clone the project

git clone https://github.com/Bit-Nest/UnifiedApi.git
cd UnifiedApi

4. Deploy with Docker Swarm

docker stack deploy -c deployment.yml unifieddigitapi

5. Access Services via Nginx (on EC2)

  • Unified UI: http://<EC2_IP>/
  • Unified Prediction Endpoint: http://<EC2_IP>/predict
  • Decimal API: http://<EC2_IP>/decimal/api/predict
  • Devanagari API: http://<EC2_IP>/devanagari/api/predict

Nginx handles internal routing and load balancing between services.


🔐 Optional: Enable HTTPS for Production

Use Let's Encrypt with Certbot or a Cloudflare proxy to secure your deployment with SSL certificates.


📤 Pushing Docker Images (CI/CD Optional)

1. Build and test locally

docker-compose build

2. Tag and push to Docker Hub

docker tag decimal-api youruser/decimal-api:latest
docker push youruser/decimal-api:latest

3. Update image source in production YAML

# In deployment.yml
image: youruser/decimal-api:latest

4. Pull and deploy on EC2

docker-compose pull
docker-compose up -d

🤝 Contributing

Pull requests are welcome! Feel free to contribute to:

  • 📈 Improving model accuracy
  • 🎨 Enhancing UI/UX
  • 🐳 Optimizing Docker & deployment flow

About

A fully Dockerized Flask-based API system for recognizing both Western and Devanagari handwritten digits. It features isolated containers for each model, managed via Docker Compose, and served through a unified UI with Nginx reverse proxy. Designed for local development and easy deployment on AWS EC2, the project supports RESTful API interaction.

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages