A full-stack web application that simulates the Alcohol and Tobacco Tax and Trade Bureau (TTB) label approval process. The system allows users to submit alcohol beverage labels along with product information, then uses Google OCR and automated verification to ensure the label matches the submitted data and complies with TTB regulations.
- π€ User profiles with persistent data storage
- π Protected routes for authenticated users only
- πͺ Session management with automatic redirects
- π Multi-step product information form with dynamic fields based on product category
- πΈ Image upload with drag-and-drop support
- π€ Automated OCR text extraction using Google Cloud Vision AI
- β Intelligent verification against TTB labeling requirements
- π― Real-time verification results with detailed discrepancy reports
- π Verification scoring system (0-100%)
- π· Wine - with sulfite declaration requirements
- πΊ Beer - with ingredient listing
- π₯ Distilled Spirits - with age statement and distiller information
- π View all previous label submissions
- π Search and filter by brand name, product type, or status
- ποΈ Detailed verification results modal with color-coded discrepancies
- π PDF report generation and download
- π Auto-refresh functionality
- π¬ AI-powered chatbot integrated with OpenAI Assistants API
- π Helps with TTB labeling rules and requirements
- π§ Persistent conversation history per user
- β‘ Real-time responses with typing indicators
- π Interactive onboarding carousel for first-time users
- π "How It Works" guide accessible anytime
- πΌοΈ Step-by-step visual instructions with smooth transitions
- Framework: Next.js 16 (App Router)
- Language: TypeScript
- Styling: Tailwind CSS
- Animations: Framer Motion
- Icons: Lucide React
- Authentication: Firebase Authentication (Email/Password)
- Database: Cloud Firestore (NoSQL)
- File Storage: Firebase Storage
- OCR: Google Cloud Vision AI (via Firebase Extension)
- AI Assistant: OpenAI Assistants API
- PDF Generation: jsPDF
- Build Tool: Turbopack (Next.js)
- Linting: ESLint with Next.js config
- Package Manager: npm
label-verification/
βββ src/
β βββ app/ # Next.js App Router pages
β β βββ constants/
β β β βββ ttb-rules.ts # TTB verification rules
β β βββ dashboard/
β β β βββ page.tsx # New submission form
β β βββ login/
β β β βββ page.tsx # Login page
β β βββ signup/
β β β βββ page.tsx # Registration page
β β βββ profile/
β β β βββ page.tsx # User profile settings
β β βββ submissions/
β β β βββ page.tsx # Past submissions history
β β βββ layout.tsx # Root layout with auth provider
β β βββ page.tsx # Root redirect to login
β β βββ globals.css # Global styles
β βββ components/
β β βββ forms/
β β β βββ ImageUpload.tsx # Image upload component
β β βββ layout/
β β β βββ AppSidebar.tsx # Sidebar navigation
β β β βββ Header.tsx # Page header
β β βββ shared/
β β β βββ OnboardingCarousel.tsx # Tutorial carousel
β β β βββ StatusBanner.tsx # Status messages
β β βββ ui/
β β βββ fluid-dropdown.tsx # Animated category selector
β β βββ sidebar.tsx # Sidebar primitives
β βββ features/
β β βββ auth/
β β β βββ AuthContext.tsx # Auth state management
β β β βββ ProtectedRoute.tsx # Route protection
β β βββ verification/
β β βββ LisaAssistant.tsx # AI chatbot
β β βββ VerificationForm.tsx # Main submission form
β β βββ VerificationResultsPanel.tsx
β βββ services/
β βββ firebase.ts # Firebase initialization
β βββ openaiService.ts # OpenAI API integration
β βββ uploadService.ts # Image upload & OCR
β βββ verificationLogic.ts # Label verification rules
βββ public/
β βββ Logo.png # TTB logo
β βββ lisa.png # AI assistant avatar
β βββ step[1-4].png # Onboarding tutorial images
βββ .env.local # Environment variables
βββ next.config.ts # Next.js configuration
βββ tailwind.config.ts # Tailwind CSS config
βββ tsconfig.json # TypeScript config
βββ package.json # Dependencies
- Node.js 18+ and npm
- Firebase project with:
- Authentication enabled (Email/Password provider)
- Firestore database
- Firebase Storage
- Cloud Vision AI Extension installed
- OpenAI API key and Assistant ID
- Clone the repository:
git clone <repository-url>
cd label-verification- Install dependencies:
npm install- Set up environment variables:
Create a .env.local file in the root directory:
# Firebase Configuration
NEXT_PUBLIC_FIREBASE_API_KEY=your_api_key
NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN=your_project.firebaseapp.com
NEXT_PUBLIC_FIREBASE_PROJECT_ID=your_project_id
NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET=your_project.firebasestorage.app
NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
NEXT_PUBLIC_FIREBASE_APP_ID=your_app_id
# OpenAI Configuration
NEXT_PUBLIC_OPENAI_API_KEY=sk-...
NEXT_PUBLIC_OPENAI_ASSISTANT_ID=asst_...-
Configure Firebase:
a. Install Cloud Vision AI Extension:
- Go to Firebase Console β Extensions
- Install "Extract Text from Images with Cloud Vision API"
- Set image path to:
labels - Set output collection to:
extractedText
b. Set up Firestore Security Rules:
rules_version = '2'; service cloud.firestore { match /databases/{database}/documents { // Public read for OCR results match /extractedText/{document=**} { allow read: if true; } // User-specific data match /users/{userId} { allow read, write: if request.auth != null && request.auth.uid == userId; // Nested submissions match /submissions/{submissionId} { allow read, write: if request.auth != null && request.auth.uid == userId; } // Nested AI conversations match /conversations/{conversationId} { allow read, write: if request.auth != null && request.auth.uid == userId; } } } }
c. Set up Storage Security Rules:
rules_version = '2'; service firebase.storage { match /b/{bucket}/o { match /labels/{fileName} { allow read, write: if true; } } }
-
Run the development server:
npm run devOpen http://localhost:3000 in your browser.
- Sign Up - Create an account with first name, last name, username, and password
- Tutorial - View the automatic onboarding carousel
- Dashboard - You'll be redirected to the new submission form
- Select your product category (Wine, Beer, or Distilled Spirits)
- Fill out all required product information fields
- Upload a clear photo of your label
- Click "Submit for Verification"
- Wait for AI-powered verification (typically 10-30 seconds)
- Review detailed results with pass/fail indicators
- Click "Past Submissions" in the sidebar
- Search or filter submissions by status, brand, or product type
- Click the eye icon to view detailed verification results
- Click the download icon to get a PDF report
- Click the Lisa button (bottom-right corner)
- Ask questions about TTB labeling requirements
- Get help understanding verification results
- Conversation history is automatically saved
- Image Upload β Stored in Firebase Storage
- OCR Processing β Cloud Vision AI extracts text from the image
- Data Comparison β Compares extracted text with submitted form data
- Rule Checking β Validates against TTB regulations:
- Brand name match
- Product type verification
- Alcohol content accuracy
- Net contents validation
- Health warning presence and correctness
- Category-specific requirements (sulfites, ingredients, etc.)
- Scoring β Generates a 0-100% verification score
- Results β Provides detailed pass/fail/warning messages for each field
next- React frameworkreact&react-dom- UI librarytypescript- Type safety
firebase- Backend services
Built with β€οΈ for the Alcohol and Tobacco Tax and Trade Bureau