Skip to the content.

Architecture

This page describes Quagga2’s code structure and design decisions.

Project Structure

quagga2/
├── src/
│   ├── quagga.ts           # Main entry point
│   ├── config/             # Configuration handling
│   ├── decoder/            # Barcode decoding
│   │   ├── barcode_decoder.ts
│   │   └── readers/        # Individual barcode readers
│   ├── locator/            # Barcode localization
│   │   ├── barcode_locator.ts
│   │   └── skeletonizer.ts
│   ├── input/              # Input handling
│   │   ├── camera_access.ts
│   │   └── frame_grabber.ts
│   └── common/             # Shared utilities
│       ├── cv_utils.ts     # Computer vision utilities
│       └── image_wrapper.ts
├── dist/                   # Browser builds
├── lib/                    # Node.js build
└── type-definitions/       # TypeScript types

Core Components

Quagga (Main API)

The main entry point (src/quagga.ts) exposes the public API:

Barcode Locator

Located in src/locator/, responsible for finding barcode regions in images:

Barcode Decoder

Located in src/decoder/, handles barcode decoding:

Input Handling

Located in src/input/:

Data Flow

Camera/Image
    ↓
FrameGrabber (captures frame)
    ↓
ImageWrapper (grayscale conversion)
    ↓
BarcodeLocator (finds barcode region)
    ↓
BarcodeDecoder (decodes barcode)
    ↓
Result callbacks

Design Decisions

Bundle Everything

All dependencies are bundled into the final build. This means:

Dual Build Targets

Reader Architecture

Readers are pluggable:

Build System


← Back to Explanation