Skip to content

About

This web application simulates the Alcohol and Tobacco Tax and Trade Bureau (TTB) label approval process.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TTB Label Verification System

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.

🌟 Features

Authentication & User Management

  • πŸ‘€ User profiles with persistent data storage
  • πŸ”’ Protected routes for authenticated users only
  • πŸšͺ Session management with automatic redirects

Label Verification

  • πŸ“ 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%)

Product Categories Supported

  • 🍷 Wine - with sulfite declaration requirements
  • 🍺 Beer - with ingredient listing
  • πŸ₯ƒ Distilled Spirits - with age statement and distiller information

Past Submissions Management

  • πŸ“‹ 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

Lisa AI Assistant

  • πŸ’¬ 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

Onboarding & Help

  • 🎠 Interactive onboarding carousel for first-time users
  • πŸ“– "How It Works" guide accessible anytime
  • πŸ–ΌοΈ Step-by-step visual instructions with smooth transitions

πŸ› οΈ Tech Stack

Frontend

  • Framework: Next.js 16 (App Router)
  • Language: TypeScript
  • Styling: Tailwind CSS
  • Animations: Framer Motion
  • Icons: Lucide React

Backend & Services

  • 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

Development Tools

  • Build Tool: Turbopack (Next.js)
  • Linting: ESLint with Next.js config
  • Package Manager: npm

πŸ“ Project Structure

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

πŸš€ Getting Started

Prerequisites

  • 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

Installation

  1. Clone the repository:
git clone <repository-url>
cd label-verification
  1. Install dependencies:
npm install
  1. 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_...
  1. 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;
        }
      }
    }
  2. Run the development server:

npm run dev

Open http://localhost:3000 in your browser.

πŸ“– Usage

For First-Time Users:

  1. Sign Up - Create an account with first name, last name, username, and password
  2. Tutorial - View the automatic onboarding carousel
  3. Dashboard - You'll be redirected to the new submission form

Submitting a Label:

  1. Select your product category (Wine, Beer, or Distilled Spirits)
  2. Fill out all required product information fields
  3. Upload a clear photo of your label
  4. Click "Submit for Verification"
  5. Wait for AI-powered verification (typically 10-30 seconds)
  6. Review detailed results with pass/fail indicators

Viewing Past Submissions:

  1. Click "Past Submissions" in the sidebar
  2. Search or filter submissions by status, brand, or product type
  3. Click the eye icon to view detailed verification results
  4. Click the download icon to get a PDF report

Using Lisa AI Assistant:

  1. Click the Lisa button (bottom-right corner)
  2. Ask questions about TTB labeling requirements
  3. Get help understanding verification results
  4. Conversation history is automatically saved

πŸ” How Verification Works

  1. Image Upload β†’ Stored in Firebase Storage
  2. OCR Processing β†’ Cloud Vision AI extracts text from the image
  3. Data Comparison β†’ Compares extracted text with submitted form data
  4. 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.)
  5. Scoring β†’ Generates a 0-100% verification score
  6. Results β†’ Provides detailed pass/fail/warning messages for each field

πŸ“¦ Dependencies

Core

  • next - React framework
  • react & react-dom - UI library
  • typescript - Type safety

Firebase

  • firebase - Backend services

πŸ“„ License

This is a demonstration project for educational purposes.

Built with ❀️ for the Alcohol and Tobacco Tax and Trade Bureau

About

This web application simulates the Alcohol and Tobacco Tax and Trade Bureau (TTB) label approval process.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages