# abhijitshukla/automatic-numberplate-detection architecture

> Architecture diagram of the GitHub repository abhijitshukla/automatic-numberplate-detection, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abhijitshukla/automatic-numberplate-detection
- Repository: https://github.com/abhijitshukla/automatic-numberplate-detection

## Overview

##### Project type and purpose
- This is a full-stack Python application for Automatic Number Plate Detection.
- It captures video frames, detects license plates via YOLOv8, performs OCR with PaddleOCR, then sends results to a FastAPI backend which persists them in a MySQL database.

##### File structure
- Top-level scripts:
- main.py – orchestrates video input, detection, OCR, and API calls
- server.py – defines FastAPI routes and database logic
- Model assets:
- license_plate_detector.pt – YOLOv8 weights
- coco1.txt – class labels for YOLO
- Sample media:
- sample/sample.mp4 – test video input
- Config and dependencies:
- requirements.txt, .gitignore
- README.md describes setup and usage
- .env (not in file tree but mentioned) holds DB connection details

##### Key insights from README
- Real-time video processing with OpenCV and CVZone
- Detection via YOLOv8 (Ultralytics)
- OCR via PaddleOCR
- Backend: FastAPI + Uvicorn
- Database: MySQL accessed via environment variables

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Processing Pipeline
    subgraph "Processing Pipeline"
        direction TB
        VideoInput["Video Input Module<br/>(OpenCV & CVZone)"]:::processing
        SampleMedia["Sample Media<br/>(sample.mp4)"]:::processing
        Detection["Object Detection Module<br/>(YOLOv8)"]:::processing
        ClassLabels["YOLO Class Labels<br/>(coco1.txt)"]:::processing
        OCR["OCR Module<br/>(PaddleOCR)"]:::processing
        APIClient["API Client<br/>(HTTP requests)"]:::communication
    end

    %% Backend Service
    subgraph "Backend Service"
        direction TB
        FastAPIServer["FastAPI Server<br/>(server.py)"]:::backend
        EnvConfig["Environment Config<br/>(.env)"]:::config
        MySQLDB["MySQL Database"]:::backend
    end

    %% Documentation & Misc
    subgraph "Project Files"
        direction TB
        Requirements["Requirements<br/>(requirements.txt)"]:::config
        README["Documentation<br/>(README.md)"]:::docs
        Gitignore["Git Ignore Rules<br/>(.gitignore)"]:::config
    end

    %% Connections
    SampleMedia -->|provides video stream| VideoInput
    VideoInput -->|frames| Detection
    ClassLabels -->|loaded by| Detection
    Detection -->|bounding boxes| OCR
    OCR -->|recognized text & timestamp| APIClient
    APIClient -->|POST /store_plate/| FastAPIServer
    FastAPIServer -->|writes to| MySQLDB
    FastAPIServer -->|reads from| MySQLDB
    FastAPIServer -->|uses vars from| EnvConfig
    FastAPIServer -->|GET /plates/| APIClient

    %% External Files Mapping Click Events
    click VideoInput "https://github.com/abhijitshukla/automatic-numberplate-detection/blob/main/main.py"
    click SampleMedia "https://github.com/abhijitshukla/automatic-numberplate-detection/blob/main/sample/sample.mp4"
    click Detection "https://github.com/abhijitshukla/automatic-numberplate-detection/blob/main/license_plate_detector.pt"
    click ClassLabels "https://github.com/abhijitshukla/automatic-numberplate-detection/blob/main/coco1.txt"
    click OCR "https://github.com/abhijitshukla/automatic-numberplate-detection/blob/main/main.py"
    click APIClient "https://github.com/abhijitshukla/automatic-numberplate-detection/blob/main/main.py"
    click FastAPIServer "https://github.com/abhijitshukla/automatic-numberplate-detection/blob/main/server.py"
    click EnvConfig "https://github.com/abhijitshukla/automatic-numberplate-detection/blob/main/.env"
    click Requirements "https://github.com/abhijitshukla/automatic-numberplate-detection/blob/main/requirements.txt"
    click README "https://github.com/abhijitshukla/automatic-numberplate-detection/blob/main/README.md"
    click Gitignore "https://github.com/abhijitshukla/automatic-numberplate-detection/blob/main/.gitignore"

    %% Styles
    classDef processing fill:#E8F1F2,stroke:#333,stroke-width:1px
    classDef communication fill:#FDE8E8,stroke:#333,stroke-width:1px
    classDef backend fill:#E8F5DE,stroke:#333,stroke-width:1px
    classDef config fill:#F3E8FD,stroke:#333,stroke-width:1px
    classDef docs fill:#FFF4E8,stroke:#333,stroke-width:1px
```
