How jatin-mehra119/barcode-gen works
Project Type and Purpose
• This is a single-service, full-stack Streamlit web application whose sole purpose is to generate professional, print-ready Code128 barcodes in bulk for office/workplace operations.
• It has no separate database or external microservices; all logic runs in a single Python process, producing PDF output for printing.
File Structure
Top-level files:
• app.py – the Streamlit-based UI entrypoint
• utils.py – core business logic (barcode generation, labeling, PDF composition)
• requirements.txt – dependency listing (streamlit, python-barcode, Pillow, pandas)
• Dockerfile & .gitignore – containerization and VCS settings
• streamlit_barcode_app_backup.py – backup of main app, not part of main flow
• test_app.py, test_titles.py – automated tests for UI flows and title-label features
• test_app.py imports app.py UI functions; test_titles.py validates custom label logic
README for Additional Insights
• Streamlit for rapid office-friendly UI
• python-barcode + Pillow for Code128 image generation
• pandas for tabular input management
• Output: A4-sized PDF at 300 DPI, optimized for office printers
Main Components & Their Interactions
a. User Interface (Streamlit)
• Presents form for item numbers, quantities, titles
• Triggers “Generate” action
b. Business Logic (utils.py)
• Receives UI inputs
• Invokes python-barcode to generate barcode images
• Formats titles and aligns labels
• Uses Pillow to compose images into PDF pages
• Uses pandas if batch data operations are needed
c. Output Module
• Writes and returns a PDF buffer to Streamlit for download
• Uses Streamlit’s file‐download component
d. Testing Suite
• test_app.py validates that UI callbacks produce correct outputs
• test_titles.py ensures labeling logic correctness
e. Environment & Deployment
• Dockerfile encapsulates all dependencies
• requirements.txt pins library versions
Architectural Patterns and Design Principles
• Monolithic, layered architecture: UI layer → Business logic layer → Output layer
• Single responsibility modules: utils.py holds all generation logic, app.py handles only UI
• Test-driven design: tests verify each layer’s functionality
• Dependency injection pattern (passing parameters from UI to utils)
1. Streamlit UI Layer (app.py)
2. QR & Barcode Engine (python-barcode library)
3. Image Processing (Pillow)
4. Data Management (pandas)
5. PDF Assembly (utils.py subprocess)
6. Output Delivery (Streamlit download widget)
7. Test Harness (test_app.py & test_titles.py)
8. Docker Container (deployment boundary)
b. Relationships & Flow:
• UI → utils.py (input pass)
• utils.py → Barcode Engine & Pillow & pandas (library calls)
• Barcode Engine & Pillow → utils.py (image objects)
• utils.py → PDF Assembly → Streamlit Output
c. Architectural Patterns:
• Layered flow: top to bottom (UI → Logic → Libraries → Output)
• Single-process monolith with clear separation of concerns
d. Key Technologies:
• Python 3.7+ runtime
• Streamlit (UI)
• python-barcode (Code128 generation)
• Pillow (image composition)
• pandas (optional data handling)
• pytest (testing)
• Docker (deployment)
Diagramming Conventions
• Blue for UI (Streamlit)
• Green for Business Logic (utils.py)
• Orange for External Libraries (python-barcode, Pillow, pandas)
• Gray for Deployment (Docker)
• Purple for Testing