# igorkovbel/anpr architecture

> Architecture diagram of the GitHub repository igorkovbel/anpr, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/igorkovbel/anpr
- Repository: https://github.com/igorkovbel/anpr

## Overview

#### Purpose and Entry Points
ANPR is a Python service for automatic number-plate recognition across uploaded images, uploaded videos, and live camera streams. The application entry point is `app/main.py`; it serves the browser interface in `templates/index.html` and exposes processing/API paths backed by detection, tracking, OCR, and WebRTC modules.

#### HTTP/API and UI Layer
`app/main.py` is the orchestration boundary for request handling. It routes image/video submissions into offline processing and connects real-time clients to the WebRTC pipeline. `templates/index.html` is the client-facing interface for upload and/or camera interaction.

#### Detection and Recognition Models
Vehicle/plate detection uses a YOLOv10 model, while plate text is recognized with an ONNX OCR model. Model artifacts are packaged with the application at:
- `app/models/model.pt`
- `app/models/VT_ep1500.onnx`
- `app/models.py`

This layer turns frames or images into plate regions and recognized plate strings; model loading/inference utilities are likely centralized in `app/models.py`.

#### Image and Video Processing Pipeline
`app/processing.py` implements the shared media-processing flow: decode input, run detection, crop plate candidates, invoke OCR, and annotate or emit results. For video, detection is performed periodically (per README, every 15 frames) and tracker state fills intervening frames, producing a processed MP4 result such as `result.mp4`.

#### Real-Time WebRTC Pipeline
`app/webrtc.py` adapts the same inference pipeline to incoming browser camera frames. It is the latency-sensitive boundary between WebRTC media transport and GPU/CUDA-backed frame processing, returning processed frames to the client rather than requiring an uploaded file.

#### Tracking and Third-Party Vision Code
Tracking is supplied by the HiT implementation, reducing detector frequency while maintaining object identity/position between detections. Detector, tracker, and OCR dependencies are vendored or referenced under:
- `libs/HiT`
- `libs/yolov10`
- `libs/fast`

These libraries form the external ML boundary; application modules should keep their APIs behind model/processing abstractions.

#### Runtime and Deployment Boundaries
The service is Python-based with dependencies declared in `requirements.txt` and container packaging in `Dockerfile`. The intended performance profile relies on CUDA/GPU execution for real-time tracking and inference. TLS assets at `certs/server.crt` and `certs/server.key` are materially relevant because browser WebRTC camera access commonly requires HTTPS.

Main entry points: [`app/main.py`](https://github.com/igorkovbel/anpr/blob/main/app/main.py) (Service entry point), [`app/models.py`](https://github.com/igorkovbel/anpr/blob/main/app/models.py) (Model inference), [`app/webrtc.py`](https://github.com/igorkovbel/anpr/blob/main/app/webrtc.py) (WebRTC frame pipeline), [`app/processing.py`](https://github.com/igorkovbel/anpr/blob/main/app/processing.py) (Offline media pipeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Application"]
  node_browser["Browser UI<br/>HTML client<br/>[index.html]"]
  node_main["Service entry point<br/>Python API orchestration<br/>[main.py]"]
  node_processing["Offline media pipeline<br/>Python processing<br/>[processing.py]"]
  node_webrtc["WebRTC frame pipeline<br/>Python media adapter<br/>[webrtc.py]"]
end

subgraph group_ml["ML Pipeline"]
  node_models["Model inference<br/>Python ML facade<br/>[models.py]"]
  node_yolo_model["YOLOv10 weights<br/>vehicle/plate model<br/>[model.pt]"]
  node_ocr_model["ONNX OCR weights<br/>plate text model<br/>[VT_ep1500.onnx]"]
  node_hit["HiT tracker<br/>vendored tracker"]
  node_yolov10["YOLOv10 library<br/>vendored detector"]
  node_fast["FAST OCR library<br/>vendored OCR"]
end

subgraph group_runtime["Runtime &amp; Deployment"]
  node_docker["Container image<br/>deployment packaging"]
  node_dependencies["Python dependencies<br/>dependency manifest<br/>[requirements.txt]"]
  node_tls_cert["TLS certificate<br/>HTTPS asset<br/>[server.crt]"]
  node_tls_key["TLS private key<br/>HTTPS asset<br/>[server.key]"]
end

node_browser -->|"uploads and API requests"| node_main
node_browser -->|"camera media session"| node_webrtc
node_main -->|"image/video jobs"| node_processing
node_main -->|"real-time session setup"| node_webrtc
node_processing -->|"detects and reads plates"| node_models
node_processing -->|"tracks between detections"| node_hit
node_webrtc -->|"per-frame inference"| node_models
node_webrtc -->|"real-time tracking"| node_hit
node_models -->|"loads weights"| node_yolo_model
node_models -->|"loads weights"| node_ocr_model
node_models -->|"uses detector"| node_yolov10
node_models -->|"uses OCR"| node_fast
node_docker -->|"runs service"| node_main
node_docker -->|"installs"| node_dependencies
node_main -->|"serves HTTPS with"| node_tls_cert
node_main -->|"uses TLS key"| node_tls_key

click node_browser "https://github.com/igorkovbel/anpr/blob/main/templates/index.html"
click node_main "https://github.com/igorkovbel/anpr/blob/main/app/main.py"
click node_processing "https://github.com/igorkovbel/anpr/blob/main/app/processing.py"
click node_webrtc "https://github.com/igorkovbel/anpr/blob/main/app/webrtc.py"
click node_models "https://github.com/igorkovbel/anpr/blob/main/app/models.py"
click node_yolo_model "https://github.com/igorkovbel/anpr/blob/main/app/models/model.pt"
click node_ocr_model "https://github.com/igorkovbel/anpr/blob/main/app/models/VT_ep1500.onnx"
click node_hit "https://github.com/igorkovbel/anpr/tree/main/libs/HiT"
click node_yolov10 "https://github.com/igorkovbel/anpr/tree/main/libs/yolov10"
click node_fast "https://github.com/igorkovbel/anpr/tree/main/libs/fast"
click node_docker "https://github.com/igorkovbel/anpr/blob/main/Dockerfile"
click node_dependencies "https://github.com/igorkovbel/anpr/blob/main/requirements.txt"
click node_tls_cert "https://github.com/igorkovbel/anpr/blob/main/certs/server.crt"
click node_tls_key "https://github.com/igorkovbel/anpr/blob/main/certs/server.key"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_browser,node_main,node_processing,node_webrtc toneBlue
class node_models,node_yolo_model,node_ocr_model,node_hit,node_yolov10,node_fast toneAmber
class node_docker,node_dependencies,node_tls_cert,node_tls_key toneMint
```

## Components

### Application

- [Browser UI](https://github.com/igorkovbel/anpr/blob/main/templates/index.html): HTML client · Uploads media and connects camera sessions. · `templates/index.html`
- [Service entry point](https://github.com/igorkovbel/anpr/blob/main/app/main.py): Python API orchestration · Routes offline jobs and real-time sessions. · `app/main.py`
- [Offline media pipeline](https://github.com/igorkovbel/anpr/blob/main/app/processing.py): Python processing · Decodes, detects, tracks, OCRs, and annotates images or videos. · `app/processing.py`
- [WebRTC frame pipeline](https://github.com/igorkovbel/anpr/blob/main/app/webrtc.py): Python media adapter · Processes incoming camera frames and returns annotated frames. · `app/webrtc.py`

### ML Pipeline

- [Model inference](https://github.com/igorkovbel/anpr/blob/main/app/models.py): Python ML facade · Centralizes model loading and detection/OCR inference. · `app/models.py`
- [YOLOv10 weights](https://github.com/igorkovbel/anpr/blob/main/app/models/model.pt): vehicle/plate model · `app/models/model.pt`
- [ONNX OCR weights](https://github.com/igorkovbel/anpr/blob/main/app/models/VT_ep1500.onnx): plate text model · `app/models/VT_ep1500.onnx`
- [HiT tracker](https://github.com/igorkovbel/anpr/tree/main/libs/HiT): vendored tracker · Maintains object identity between periodic detections. · `libs/HiT`
- [YOLOv10 library](https://github.com/igorkovbel/anpr/tree/main/libs/yolov10): vendored detector · `libs/yolov10`
- [FAST OCR library](https://github.com/igorkovbel/anpr/tree/main/libs/fast): vendored OCR · `libs/fast`

### Runtime & Deployment

- [Container image](https://github.com/igorkovbel/anpr/blob/main/Dockerfile): deployment packaging · Packages the CUDA-capable Python service. · `Dockerfile`
- [Python dependencies](https://github.com/igorkovbel/anpr/blob/main/requirements.txt): dependency manifest · `requirements.txt`
- [TLS certificate](https://github.com/igorkovbel/anpr/blob/main/certs/server.crt): HTTPS asset · Enables secure browser camera access. · `certs/server.crt`
- [TLS private key](https://github.com/igorkovbel/anpr/blob/main/certs/server.key): HTTPS asset · `certs/server.key`

## Connections

- Browser UI → Service entry point: uploads and API requests
- Browser UI → WebRTC frame pipeline: camera media session
- Service entry point → Offline media pipeline: image/video jobs
- Service entry point → WebRTC frame pipeline: real-time session setup
- Offline media pipeline → Model inference: detects and reads plates
- Offline media pipeline → HiT tracker: tracks between detections
- WebRTC frame pipeline → Model inference: per-frame inference
- WebRTC frame pipeline → HiT tracker: real-time tracking
- Model inference → YOLOv10 weights: loads weights
- Model inference → ONNX OCR weights: loads weights
- Model inference → YOLOv10 library: uses detector
- Model inference → FAST OCR library: uses OCR
- Container image → Service entry point: runs service
- Container image → Python dependencies: installs
- Service entry point → TLS certificate: serves HTTPS with
- Service entry point → TLS private key: uses TLS key
