How vasteri/price-tag-recognizer works
1. This repository is a small distributed application for recognizing price tags from images. The architecture is split into three runtime areas: a Python backend API, a separate Python recognition worker, and a static browser frontend.
2. The backend directory is the orchestration layer. It contains main.py, config.py, and celery_app.py, which suggests the backend exposes the public API and also produces/consumes asynchronous jobs through Celery. scripts/start_server.sh is the container/startup entrypoint for that service.
3. The recognizer directory is the compute-heavy worker service. Its code is organized around OCR and post-processing: ocr.py for text extraction, tracker.py for tracking objects/regions, recognizer.py as the main recognition logic, and tasks.py as the Celery task entrypoint. download_model.py indicates the worker may fetch or initialize model assets at startup, and assets/ holds local model/data files.
4. The two Python services likely communicate through a Celery broker/backend rather than direct synchronous calls. Both backend/src/celery_app.py and recognizer/src/celery_app.py exist, which is a strong signal that the backend enqueues recognition jobs and the recognizer executes them asynchronously.
5. The frontend is purely static: index.html, script.js, and style.css. There is no frontend build system in the tree, so the browser UI is likely served as plain static files and talks to the backend over HTTP.
6. The infra/nginx.conf file indicates Nginx is used as the edge server/reverse proxy. In this setup, Nginx most likely serves the static frontend and forwards API requests to the backend container, keeping the browser-facing origin simple.
7. docker-compose.yml is the main deployment glue. It probably wires together the backend, recognizer, and Nginx containers, and may also define the Celery broker/service needed for task dispatch. The architecture is therefore container-first rather than monolithic.
8. The main data flow is: user interacts with the static UI → browser sends an image/request to the backend → backend submits a Celery job → recognizer processes the image with OCR/model logic → results return to the backend and are sent back to the UI. This separation keeps the request path lightweight while isolating expensive recognition work.
9. There is no obvious database or long-term persistence layer in the file tree. That suggests the system is either stateless or relies on Celery infrastructure and in-memory/model assets rather than a dedicated application datastore.
10. The key architectural boundary is between API/orchestration and ML/OCR execution. Anything user-facing or request-handling lives in backend and frontend; anything compute-intensive or model-specific lives in recognizer.
11. For an architecture diagram, the important external surfaces are: the browser, Nginx, the backend API container, the recognizer worker container, and the Celery messaging layer connecting the Python services.
Main entry points: main.py Server · docker-compose.yml Compose · recognizer.py Recognizer · nginx.conf Nginx
Components 16
Frontend
Static browser UI
- Browser · User-facing web client
- Static UI · Plain browser interface
frontend/static/index.html
Backend
API and orchestration service
- Server · Backend startup and request handling
backend/src/main.py - Backend config · Backend runtime configuration
backend/src/config.py - Backend Celery · Dispatches recognition jobs
backend/src/celery_app.py - Start script · Backend service bootstrap
backend/scripts/start_server.sh
Recognizer
Async OCR and recognition worker
- Worker · Recognition worker entrypoint
recognizer/src/tasks.py - Worker Celery · Celery integration for recognition jobs
recognizer/src/celery_app.py - Recognizer · Main image recognition pipeline
recognizer/src/recognizer.py - OCR · Extracts text from images
recognizer/src/ocr.py - Tracker · Tracks detected regions or objects
recognizer/src/tracker.py - Model setup · Downloads or initializes model assets
recognizer/src/download_model.py - Assets · Local worker assets and model data
recognizer/assets
Connections 20
- Browser → Nginx: HTTP · User requests enter through the edge proxy
- Nginx → Static UI: serve · Serves the static browser application
- Nginx → Server: route API · Forwards API calls to the backend service
- Start script → Server: launches · Container entrypoint starts the API process
- Server → Backend config: reads · Loads runtime settings
- Server → Backend Celery: enqueues · Submits recognition work asynchronously
- Backend Celery → Broker: publish · Sends Celery jobs to the message layer
- Broker → Worker Celery: deliver · Routes queued tasks to the worker
- Worker → Worker Celery: consumes · Worker process is driven through Celery
- Worker Celery → Recognizer: runs · Delegates jobs to the recognition pipeline
- Recognizer → OCR: uses · Performs OCR during recognition
- Recognizer → Tracker: uses · Tracks regions or detections
- Recognizer → Model setup: initializes · Bootstraps model dependencies
- Model setup → Assets: loads · Uses local assets and model files
- Worker → Assets: depends on · Worker runtime depends on bundled assets
- Server → Browser: response · Returns recognition results to the UI
- Compose → Nginx: orchestrates · Defines deployment of the edge proxy
- Compose → Server: orchestrates · Defines backend service container
- Compose → Worker: orchestrates · Defines recognizer worker container
- Compose → Broker: orchestrates · Includes the messaging service dependency