Skip to content

Latest commit

 

History

History
148 lines (107 loc) · 6.01 KB

File metadata and controls

148 lines (107 loc) · 6.01 KB

Road Trip Explorer - Video Optimization Demo

Overview

Road Trip Explorer is a modern web application that showcases video optimization techniques for road trip content. The application demonstrates three different approaches to video delivery: plain HTML5 video, ImageKit-optimized video, and HLS adaptive streaming. Built with React, TypeScript, and Express, it provides an interactive comparison of various video optimization strategies.

User Preferences

Preferred communication style: Simple, everyday language.

System Architecture

Frontend Architecture

Framework & Build System

  • React with TypeScript for type-safe component development
  • Vite as the build tool and development server for fast HMR (Hot Module Replacement)
  • Wouter for lightweight client-side routing
  • TanStack Query for server state management and caching

UI Component System

  • shadcn/ui component library with Radix UI primitives
  • Tailwind CSS for utility-first styling with custom design tokens
  • Component architecture following the "New York" style from shadcn/ui
  • Custom CSS variables for theming (light theme configured)

Design Rationale: This stack provides a modern DX with minimal bundle size. Vite offers superior build performance compared to webpack-based solutions, while Wouter keeps routing simple without the overhead of React Router.

Backend Architecture

Server Framework

  • Express.js with TypeScript for API routes
  • ESM (ES Modules) configuration for modern JavaScript support
  • Custom middleware for request logging and JSON parsing with raw body preservation
  • Vite middleware integration for seamless development experience

Development vs Production

  • Development: Vite dev server with HMR and middleware mode
  • Production: Static file serving with esbuild-bundled server
  • Replit-specific plugins for development (cartographer, dev banner, runtime error overlay)

Design Rationale: Express provides flexibility for custom middleware while remaining lightweight. The Vite middleware integration allows serving the React app and API from a single server during development.

Data Layer

Storage Interface

  • Abstract IStorage interface defined in server/storage.ts
  • MemStorage implementation for in-memory data storage
  • Currently stores data in memory (no persistence between restarts)

Schema Definition

  • Zod schemas in shared/schema.ts for runtime validation
  • Type inference from Zod schemas for TypeScript types
  • RoadTrip schema defines the core data model
  • VideoOptimizationMode enum for video player selection

Design Rationale: The storage interface allows swapping implementations (e.g., from memory to database) without changing business logic. Zod provides both runtime validation and TypeScript types from a single source of truth.

Video Optimization Strategies

Three-Tier Approach

  1. Plain HTML5: Direct video file loading without optimization
  2. ImageKit Integration: CDN-based optimization with format conversion and compression
  3. HLS Adaptive Streaming: Quality adaptation based on network conditions

Player Components

  • PlainVideoPlayer: Basic HTML5 video element
  • ImageKitVideoPlayer: URL transformation for ImageKit CDN
  • HLSVideoPlayer: Adaptive bitrate streaming (simulated, requires hls.js installation)

Design Rationale: Multiple optimization modes demonstrate different trade-offs between implementation complexity, bandwidth usage, and user experience.

State Management

Client-Side State

  • React hooks for local component state
  • TanStack Query for server state caching and synchronization
  • Custom hooks (useVideoOptimization, useIntersectionObserver) for reusable logic

Query Client Configuration

  • Disabled automatic refetching (on window focus, intervals)
  • Infinite stale time for demo purposes
  • Custom 401 handling for unauthorized requests

External Dependencies

Database Configuration

Drizzle ORM Setup

  • Configured for PostgreSQL dialect (via @neondatabase/serverless)
  • Schema location: shared/schema.ts
  • Migrations directory: ./migrations
  • Connection via DATABASE_URL environment variable

Note: While Drizzle is configured, the current implementation uses in-memory storage. The database configuration is present but not actively used.

Third-Party Services

Neon Database

  • Serverless Postgres provider
  • Package: @neondatabase/serverless
  • Currently configured but not implemented in the storage layer

ImageKit React SDK (@imagekit/react)

  • Official React SDK for ImageKit CDN service
  • Used in ImageKitVideoPlayer with the Video component
  • Handles automatic format conversion and compression
  • Supports transformation arrays for advanced video optimization
  • No default transformations - relies on ImageKit's automatic optimization

HLS.js (Planned Integration)

  • JavaScript library for HTTP Live Streaming
  • Referenced in HLSVideoPlayer but not yet installed
  • Would enable adaptive bitrate streaming

UI Component Libraries

Radix UI

  • Comprehensive set of accessible UI primitives
  • Components: Dialog, Dropdown, Tooltip, Toast, Accordion, etc.
  • Provides WAI-ARIA compliant base components

shadcn/ui

  • Pre-built components using Radix UI and Tailwind
  • "New York" style variant selected
  • Path aliases configured for easy imports

Development Tools

Replit Integrations

  • @replit/vite-plugin-cartographer: Code navigation
  • @replit/vite-plugin-dev-banner: Development mode indicator
  • @replit/vite-plugin-runtime-error-modal: Enhanced error display

Build Tools

  • esbuild: Fast JavaScript bundler for server code
  • TypeScript: Type checking (noEmit mode, handled by Vite)
  • PostCSS with Autoprefixer: CSS processing

Fonts

Google Fonts Integration

  • Inter: Primary sans-serif font
  • JetBrains Mono: Monospace font for code
  • Architects Daughter: Decorative font
  • DM Sans, Fira Code, Geist Mono: Additional font options

Design Rationale: Multiple font families provide flexibility for different content types while maintaining consistent typography across the application.