A comprehensive demonstration project showcasing advanced Vue 3 development with TypeScript, focusing on A/B testing implementation for e-commerce applications. This project is designed for senior frontend developer interview preparation and demonstrates modern development practices.
This application demonstrates:
- Vue 3 Composition API patterns and best practices
- A/B Testing Framework with deterministic user bucketing
- TypeScript Integration with advanced type patterns
- E-commerce Functionality with conversion tracking
- Analytics System with comprehensive event tracking
- Node.js Backend for data collection and experiment management
- Python Analytics for statistical analysis and reporting
- Vue 3.5+ with Composition API
- TypeScript 5.0+ for type safety
- Vite 6.0+ for build tooling
- Vuetify 3 for Material Design UI
- Vue Router 4 for navigation
- Pinia for state management
- Vue I18n for internationalization
- Node.js + Express API server
- SQLite database for analytics storage
- Python for statistical analysis
- Better SQLite3 for high-performance database operations
- Node.js 18+
- Python 3.9+
- npm or yarn
-
Clone the repository
git clone <repository-url> cd vue-typescript-ab-testing
-
Install frontend dependencies
cd shop-app npm install -
Install backend dependencies
cd server npm install -
Set up Python analytics environment
cd ../analytics python -m venv venv source venv/bin/activate # On Windows: venv\\Scripts\\activate pip install -r requirements.txt
-
Start the backend server
cd server npm run dev -
Start the frontend development server
cd shop-app npm run dev -
Access the application
- Frontend: http://localhost:5173
- Backend API: http://localhost:3001
- Health check: http://localhost:3001/api/health
-
Homepage Hero Layout Test
- Variants: Centered vs Left-aligned layout
- Metrics: Click-through rate, conversion rate
- Traffic allocation: 50/50 split
-
Button Color Test
- Variants: Blue, Green, Red CTA buttons
- Metrics: Click rate, conversion impact
- Traffic allocation: 33/33/34 split
-
Product Showcase Layout
- Variants: Grid vs Carousel display
- Metrics: Product engagement, add-to-cart rate
- Deterministic User Bucketing: Consistent variant assignment
- Statistical Significance Testing: Proper hypothesis testing
- Conversion Tracking: Goal measurement and attribution
- Traffic Allocation: Percentage-based experiment inclusion
- Experiment Targeting: User segmentation rules
- Product Catalog - Browse products with filtering
- Product Details - Individual product pages with A/B tested layouts
- Shopping Cart - Add/remove items with persistent state
- Checkout Process - Multi-step checkout with conversion tracking
- Order Confirmation - Purchase completion and analytics
- Page views and navigation
- Product interactions
- Cart operations
- Purchase completions
- A/B experiment assignments and conversions
// A/B Testing Integration
const { variant, isLoading, trackConversion } = useABTest('button-color-test')
// Analytics Integration
const analytics = useAnalytics()
await analytics.track('product_view', { productId: '123' })
// Shopping Cart Management
const { cart, addItem, removeItem } = useShoppingCart()// Generic API responses
interface ApiResponse<T> {
data?: T
error?: ApiError
meta?: ResponseMeta
}
// Discriminated unions for state
type LoadingState<T> =
| { status: 'loading'; data: null; error: null }
| { status: 'success'; data: T; error: null }
| { status: 'error'; data: null; error: string }// Pinia store with TypeScript
export const useExperimentsStore = defineStore('experiments', () => {
const experiments = ref<Experiment[]>([])
const activeExperiments = computed(() =>
experiments.value.filter(e => e.isActive)
)
return { experiments, activeExperiments, loadExperiments }
})class HashAssignmentAlgorithm implements AssignmentAlgorithm {
assignVariant(user: User, experiment: Experiment): Variant | null {
// Deterministic traffic allocation
const trafficHash = this.hash(user.id + experiment.id + 'traffic')
const trafficBucket = trafficHash % 100
if (trafficBucket >= experiment.trafficAllocation) {
return null // User not included
}
// Consistent variant assignment
const variantHash = this.hash(user.id + experiment.id + 'variant')
// ... variant selection logic
}
}const experiment: Experiment = {
id: 'homepage-hero-test',
name: 'Homepage Hero Layout Test',
isActive: true,
trafficAllocation: 50, // 50% of users
variants: [
{
id: 'control',
name: 'Original Layout',
weight: 50,
isControl: true,
config: { layout: 'centered' }
},
{
id: 'variant-a',
name: 'Left Aligned',
weight: 50,
isControl: false,
config: { layout: 'left' }
}
]
}Run statistical analysis on experiment results:
# Basic experiment analysis
python analyze_experiments.py --experiment homepage-hero-test
# Generate comprehensive report
python analyze_experiments.py --experiment homepage-hero-test --report
# Create visualizations
python analyze_experiments.py --experiment homepage-hero-test --visualize
# Funnel analysis
python analyze_experiments.py --experiment checkout-flow-test --funnel- Conversion Rate: Primary success metric
- Statistical Significance: P-values and confidence intervals
- Effect Size: Practical significance measurement
- Sample Size: Power analysis and recommendations
- Revenue Impact: Business metrics and ROI
// Composable testing
describe('useABTest', () => {
it('should assign consistent variants', () => {
const { variant } = useABTest('test-experiment')
expect(variant.value).toBeDefined()
})
})// Vue component testing
describe('ProductCard', () => {
it('renders A/B tested button variant', () => {
const wrapper = mount(ProductCard, { props: { product } })
expect(wrapper.find('.cta-button')).toExist()
})
})// A/B testing validation
test('experiment assignment consistency', async ({ page }) => {
await page.goto('/')
const variant = await page.getAttribute('[data-experiment]', 'data-variant')
expect(['control', 'variant-a']).toContain(variant)
})This project demonstrates mastery of:
- Vue 3 Ecosystem: Composition API, TypeScript, tooling
- State Management: Reactive patterns, Pinia integration
- Testing: Unit, integration, E2E strategies
- Performance: Optimization and monitoring
- Build Tools: Vite configuration and optimization
- Experiment Design: Statistical rigor and methodology
- Implementation: Technical architecture and patterns
- Analysis: Statistical testing and interpretation
- Business Impact: Metrics definition and measurement
- Clean Code: SOLID principles and patterns
- Type Safety: Advanced TypeScript usage
- API Design: RESTful services and data modeling
- Documentation: Comprehensive technical documentation
vue-typescript-ab-testing/
βββ shop-app/ # Vue 3 frontend application
β βββ src/
β β βββ components/ # Vue components
β β βββ composables/ # Composition API hooks
β β βββ services/ # Business logic services
β β βββ stores/ # Pinia state management
β β βββ types/ # TypeScript definitions
β β βββ utils/ # Helper utilities
β β βββ views/ # Route components
β βββ server/ # Node.js backend
β β βββ src/
β β β βββ routes/ # API endpoints
β β β βββ database/ # Database management
β β β βββ models/ # Data models
β βββ package.json
βββ analytics/ # Python analytics tools
β βββ analyze_experiments.py
β βββ requirements.txt
βββ DOCUMENTS/ # Project documentation
βββ PLANNING.md # Development planning
βββ TECHNICAL_DOCUMENTATION.md
βββ README.md
This project is specifically designed for technical interviews and covers:
- Vue 3 Composition API patterns and best practices
- TypeScript advanced features and integration
- A/B testing implementation and statistical analysis
- State management with reactive patterns
- Performance optimization techniques
- Testing strategies and quality assurance
- Component architecture and reusability
- Type safety and error handling
- A/B testing integration patterns
- Analytics implementation and data flow
- Code organization and maintainability
- A/B testing statistical concepts
- Frontend performance optimization
- Vue.js ecosystem and tooling
- Modern JavaScript/TypeScript features
- Software architecture decisions
- Technical Documentation - Comprehensive technical guide
- Planning Documentation - Development planning and architecture
- API Documentation - Backend API reference
- Component Documentation - Vue component guide
This is an interview preparation project, but contributions are welcome:
- Fork the repository
- Create a feature branch
- Implement improvements with tests
- Submit a pull request with clear description
This project is for educational and interview preparation purposes. See LICENSE file for details.
For questions about this project or A/B testing implementation:
- Review the documentation files
- Check the code comments for detailed explanations
- Explore the example implementations in each module
Built with β€οΈ for senior frontend developer interview preparation
Demonstrating Vue 3, TypeScript, A/B Testing, and modern web development practices