ByteChat is a Chrome extension that provides AI-powered chat capabilities with multiple model support, multimodal interactions, and context-aware conversations. Built with React, TypeScript, and modern web technologies.
├── manifest.json # Chrome extension manifest (v3)
├── src/
│ ├── components/ # React UI components
│ ├── services/ # API integrations and business logic
│ ├── utils/ # Utility functions and helpers
│ ├── types/ # TypeScript type definitions
│ ├── background.ts # Service worker for extension
│ ├── contentScript.ts # Content script for webpage interaction
│ └── index.tsx # Main React entry point
├── public/ # Static assets
└── icons/ # Extension icons
Purpose: Primary chat interface with full AI capabilities
Key Features:
- Multi-model selection (text, image, file, audio)
- File attachments (images, PDFs, Excel, Word, audio)
- Voice recording and transcription
- Session management
- Tool selection for specialized tasks
- Real-time streaming responses
State Management:
- Model management (categorized by capability)
- Chat session state
- File attachment handling
- Audio recording state
- UI control state
Purpose: Simplified interface for text transformation tasks
Key Features:
- Translation between languages
- Tone modification
- Text summarization
- Session restoration for interrupted requests
- Auto-detection of selected text from webpages
Purpose: Initial onboarding for new users
Key Features:
- API key validation
- Secure storage in Chrome extension storage
- User-friendly setup experience
- SessionSelector: Manages chat session switching
- ChatHistory: Displays conversation history with streaming support
- SettingsPanel: Configuration and preferences
- ModelSelector: AI model selection interface
Purpose: Primary AI model provider integration
Capabilities:
- Model discovery and caching
- Price calculation
- Balance checking
- Free model access
Purpose: Direct OpenAI API integration
Features:
- GPT model access
- Vision model support
- Audio transcription
Purpose: Anthropic Claude model integration
Features:
- Claude model access
- Long-context conversations
Purpose: Together AI platform integration
Features:
- Open-source model access
- Cost-effective alternatives
Purpose: Unified API communication layer
Responsibilities:
- Request routing to appropriate providers
- Error handling and retries
- Response formatting
- Streaming support
Purpose: User balance and usage tracking
Features:
- Real-time balance monitoring
- Usage analytics
- Free tier management
Purpose: Model classification and recommendation
Features:
- Automatic model categorization by capability
- Best model recommendations
- User preference storage
User Input → MainInterface → API Service → AI Provider → Streaming Response → UI Update
File Selection → Base64 Encoding → MessageContent Creation → Multimodal API Call → Response
User Message → Session Manager → Chrome Storage → UI State Update
Capability Detection → Model Categories → Best Model Selection → API Configuration
- Local Storage: API keys, user preferences, session data
- Sync Storage: Cross-device settings synchronization
- Session Storage: Temporary streaming state
- React State: Component-level UI state
- Context: Global application state
- Refs: Streaming response management
- Stored in Chrome extension local storage
- Never exposed in logs or network requests
- Validated before storage
- Local processing when possible
- Encrypted cloud storage for context layer
- On-demand decryption for context retrieval
- Strict CSP for extension security
- Limited external resource access
- Secure communication channels
- Model caching to reduce API calls
- Lazy loading of model lists
- Smart model recommendations
- Real-time UI updates during generation
- Chunked response processing
- Interruption and resumption support
- Efficient base64 encoding
- File type validation
- Size limitations
- chrome.storage: Data persistence
- chrome.identity: OAuth authentication
- chrome.tabs: Tab interaction
- chrome.contextMenus: Right-click integration
- chrome.sidePanel: Side panel interface
- Selected text extraction
- Context menu integration
- Page interaction capabilities
- Extension lifecycle management
- API request coordination
- Authentication handling
- Frontend: React 19, TypeScript, Tailwind CSS
- Build Tool: Webpack with TypeScript loader
- Package Manager: npm
- Extension API: Chrome Extension Manifest V3
npm run dev # Development build with watch mode
npm run build # Production build for distribution
npm start # Development server with hot reload- TypeScript for type safety
- ESLint for code standards
- Prettier for code formatting
- Component-based architecture
- Manifest V3 compliance
- Privacy policy compliance
- Store listing optimization
- Review process preparation
- Free tier with OpenRouter API key
- Premium tier with Gmail signup
- Pay-as-you-go for heavy users
- Microservice architecture for backend
- CDN for static assets
- Load balancing for API requests
- React Native app development
- Shared component library
- Cross-platform state management
- Real-time collaboration
- Advanced context management
- Plugin system for extensions
- API Key Validation Failures: Network connectivity, invalid keys
- Streaming Interruptions: Browser refreshes, network issues
- File Upload Failures: Size limits, format restrictions
- Model Loading Issues: API rate limits, service availability
- Console logging for development
- Error tracking and reporting
- Performance monitoring
- User feedback collection
This architecture supports the goal of providing free AI access through OpenRouter while enabling premium features through ByteBank's universal context layer and advanced model access.