A quick barcode generation tool built with Swift, for the web on both server and client.
Check out the live version at https://generator.getbarc.app/
Barc Generator is a modular monorepo with four separate pieces:
┌─────────────────────────────────────────┐
│ Frontend (Preact + TypeScript) │
│ Web interface with WASM integration │
└─────────────────────────────────────────┘
│
┌─────────┴──────────┐
│ │
┌──────▼──────┐ ┌────────▼──────┐
│ WebAssembly │ │ Server │
│ (SwiftWasm) │ │ (Hummingbird) │
└──────┬──────┘ └────────┬──────┘
│ │
└────────┬───────────┘
│
┌──────────────▼──────────────┐
│ Core Swift Modules │
│ Reusable barcode libraries │
└─────────────────────────────┘
This is a set of Swift frameworks, largely taken directly from the Barc iOS app and built to compile on Swift for Linux and Swift Embedded (for SwiftWasm).
Barcodes: Standard barcode models, defining supported formatsBarcodeEncoding: Encodes barcode values into a representation suitable for renderingBarcodeImageRendering: Renders encoded barcodes to SVG and PNG formatsBarcodeFormats: Helper models for communicating between SwiftWasm and server-side SwiftGeometryandBase64: Replacement libraries for functionality missing in Embedded Swift
A WASM bundle for running Swift code in the browser. It provides a small shim between user input and the framework modules. WASM code doesn't naturally have ways to send data like strings between JavaScript and non-JavaScript code (like our Swift code), so this project handles that conversion.
A server-side Swift application built with the Hummingbird framework. It's responsible for hosting the frontend, as well as producing exported SVG and PNG files for download.
The SwiftWasm code is only used to calculate and render the barcode displayed to the user. All of the rest of the user-facing UI is done in this project, built with Preact and Vite.
This project is built and hosted as a Docker image. Building is done in multiple stages:
build-backend: Builds the Hummingbird serverbuild-wasm: Builds the WASM bundle and runs the Binaryen optimizer to optimize bundle sizebuild-frontend: Builds the Vite project, including the output ofbuild-wasm- Final: Creates a minimal runtime image for the server with necessary dependencies
This project is licensed under the GNU Affero General Public License v3.0 or later (AGPL-3.0-or-later).
See LICENSE for the full license text.