Overview
Atomix QRGen uses a modern, component-based architecture powered by Astro, Preact, and Tailwind CSS. The application runs entirely client-side, ensuring privacy and security by never transmitting data to external servers.Technology Stack
- Astro - Static site generator with partial hydration
- Preact - Lightweight React alternative for interactive components
- Tailwind CSS - Utility-first CSS framework
- qr-code-styling - QR code generation library
Project Structure
Architectural Layers
1. Presentation Layer
The presentation layer consists of Astro pages and Preact components:Pages (src/pages/)
- index.astro - Entry point that renders the RootLayout with QrCodeGenerator
- Uses Astro’s file-based routing system
Layouts (src/layouts/)
- RootLayout.astro - Provides global HTML structure, metadata, and styling
- Includes SEO meta tags and favicon configuration
- Applies Tailwind CSS global styles
Components (src/components/)
Page Components (pages/)
- Bridge between Astro pages and Preact components
qr-code-generator.astrowraps the main Preact app
qr-code-app/)
qr-gen-app.tsx- Root component managing application state- Coordinates between QR type selection, form input, and preview
qr-code-app/cards/)
card-qr-type.tsx- QR type selector with 6 format optionscard-content-input.tsx- Dynamic form container using form registrycard-qr-preview.tsx- QR code display with download functionality
forms/)
- Type-specific forms (URL, Text, WiFi, vCard, Event, Payment)
form-input.tsx- Reusable input component with validation error display
2. Domain Layer
The domain layer contains business logic, separated from UI concerns:Types (src/domain/types/qr.ts)
Defines TypeScript interfaces for all QR data types:
Encoders (src/domain/encoders/encoders.ts)
Transforms form data into QR-compatible formats:
encodeText()- Plain text encodingencodeUrl()- URL encoding with protocol normalizationencodeWifi()- WiFi format:WIFI:T:WPA;S:NetworkName;P:password;;encodeVCard()- vCard 3.0 format for contact informationencodeEvent()- iCalendar (VEVENT) format for calendar eventsencodePayment()- Payment request formatencodeQrData()- Main encoder that routes to specific encoders
Validators (src/domain/validation/validators.ts)
Provides validation logic for each QR type:
- Required field checks
- Format validation (URLs, emails, phone numbers)
- Length constraints
- Type-specific business rules (e.g., WiFi password requirements)
Form Registry (src/domain/form/form-registry.ts)
Maps QR types to their corresponding form components:
Hooks (src/domain/hooks/use-form-data.ts)
Custom Preact hook for form state management:
- Generic type support for any form data structure
- Automatic validation on field updates
- Error state management
- Change callback propagation to parent components
UI Utilities (src/domain/ui/toast.ts)
Toast notification system for user feedback:
3. State Management
State flows unidirectionally through the component tree:- User selects QR type in
CardQrType QrGenAppupdatestypestateCardContentInputrenders corresponding form from registry- Form updates trigger
datastate changes CardQrPreviewreceives data and generates QR code
4. Data Flow
Configuration
Astro Configuration (astro.config.mjs)
- Preact for component reactivity
- Tailwind CSS via Vite plugin
TypeScript Configuration
The project uses TypeScript for type safety across all components and domain logic.Privacy & Security Architecture
The application follows a zero-server architecture:- All QR code generation happens client-side in the browser
- No data is transmitted to external servers
- No analytics or tracking scripts
- No cookies or local storage of sensitive data
- Static site generation ensures minimal attack surface
- Fast - No network requests for QR generation
- Private - User data never leaves the browser
- Secure - No backend to compromise
- Cheap - Static hosting (free on many platforms)
Build Output
Astro generates a static site:- HTML with inlined critical CSS
- JavaScript bundles for Preact components (client-side only)
- Minimal JavaScript - only what’s needed for interactivity
- Tree-shaken and minified production build
Performance Characteristics
- Partial Hydration: Only interactive components (Preact) are hydrated
- Islands Architecture: Astro renders static HTML, hydrating only
qr-gen-app.tsx - No SSR Needed: Everything is pre-rendered at build time
- Small Bundle Size: Preact is ~3KB vs React’s ~40KB
- Fast Time-to-Interactive: Static HTML loads instantly, JS enhances progressively