βββ ββββββ βββββββ βββ ββββββββββββββ
ββββββββββββββββββββββ ββββββββββββββ
ββββββββββββββββββββββ ββββββββββββββ
ββ βββββββββββββββββββββββ βββββββββββββββ
βββββββββββ ββββββ βββ βββββββ βββββββββββ
ββββββ βββ ββββββ βββ βββββ βββββββββββ
A production-ready AI chatbot interface built with clean architecture principles
Live Demo β’ Features β’ Quick Start β’ Architecture β’ Contributing
JARVIS is a modern, scalable AI chatbot application powered by Google's Gemini 2.5 Flash model with automatic fallback support. Built with React 19 and designed with clean architecture principles, this project demonstrates production-grade patterns for building AI-powered applications.
This project showcases:
- Real-time streaming responses with 60fps performance
- Automatic model fallback when quota limits are reached
- Clean code architecture and separation of concerns
- Modern React patterns (hooks, memo, RAF batching)
- Accessible and responsive JARVIS-themed UI design
- Extensible service layer for AI providers
- π§ AI-Powered Conversations - Leverages Google Gemini 2.5 Flash with model fallback
- β‘ Real-time Streaming - Token-by-token response streaming at 60fps
- π Auto Model Fallback - Switches models when quota limits are reached
- β¨οΈ Keyboard Shortcuts - Enter to send, Shift+Enter for new lines
- π Copy Messages - One-click message copying with syntax highlighting
- β Cancel Streaming - Stop responses mid-generation
- π¨ JARVIS Theme - Iron Man inspired UI with arc reactor animations
- π± Fully Responsive - Optimized for all screen sizes
- β‘ Markdown Rendering - Full markdown support with code highlighting
- π Error Handling - User-friendly error messages with retry options
- π Smart Auto-scroll - Respects user scroll position during streaming
- βΏ ARIA Labels - Full screen reader support
- β¨οΈ Keyboard Navigation - Complete keyboard accessibility
- π― Focus Management - Proper focus handling
- π Semantic HTML - Meaningful document structure
- ποΈ Clean Architecture - Services, hooks, and components separation
- π Pluggable AI Providers - Easy to swap AI backends
- π¦ Modular Components - Reusable, self-contained components
- β‘ 60fps Streaming - RAF batching, buffer strategy, isolated renders
- Node.js 18.0.0 or higher
- npm or yarn
- Google Gemini API Key (Get one here)
-
Clone the repository
git clone https://github.com/IronwallxR5/JARVIS--ChatBot.git cd JARVIS--ChatBot -
Install dependencies
npm install
-
Configure environment
# Create .env.local file echo "VITE_GEMINI_API_KEY=your_api_key_here" > .env.local
-
Start development server
npm run dev
-
Open in browser Navigate to
http://localhost:5173
npm run build
npm run preview # Preview production build locallysrc/
βββ components/ # React UI components
β βββ Chatbot/ # Main chat container
β βββ ChatMessage/ # Individual message component
β βββ ChatInput/ # Input field with send button
β βββ TypingIndicator/ # Loading animation
β βββ EmptyState/ # Welcome/error states
β βββ ErrorBanner/ # Error notification
β
βββ hooks/ # Custom React hooks
β βββ useChat.js # Chat state with streaming buffer
β βββ useStickyScroll.js # Smart auto-scroll during streaming
β βββ useLocalStorage.js # Persistent storage
β βββ useAutoResize.js # Textarea auto-resize
β
βββ services/ # Business logic layer
β βββ aiService.js # AI provider interface
β βββ geminiService.js # Gemini implementation
β βββ chatService.js # Chat operations
β
βββ constants/ # App configuration
β βββ index.js # App constants
β βββ prompts.js # AI system prompts
β
βββ utils/ # Utility functions
β βββ helpers.js # Pure helper functions
β
βββ styles/ # Global styles
β βββ variables.css # CSS custom properties
β βββ App.css # App layout styles
β
βββ App.jsx # Root component
βββ main.jsx # Entry point
- Components handle UI rendering only
- Hooks manage state and side effects
- Services contain business logic
- Utils provide pure helper functions
// Easy to swap AI providers
import { GeminiProvider } from './services/geminiService';
// Future: import { OpenAIProvider } from './services/openaiService';
const provider = new GeminiProvider();
const response = await provider.generateResponse(prompt);<Chatbot>
<ChatHeader />
<ErrorBanner />
<MessageList>
<ChatMessage />
</MessageList>
<TypingIndicator />
<ChatInput />
</Chatbot>| Variable | Description | Required |
|---|---|---|
VITE_GEMINI_API_KEY |
Google Gemini API key | Yes |
Edit src/constants/prompts.js to customize the AI personality:
export const SYSTEM_PROMPT = `Your custom instructions here...`;Edit src/constants/index.js:
export const QUICK_ACTIONS = [
{ label: 'π‘ Your Action', prompt: 'Your prompt' },
// Add more actions...
];-
Create a new service file:
// src/services/openaiService.js import { AIProvider } from './aiService'; export class OpenAIProvider extends AIProvider { async generateResponse(prompt) { // Your implementation } isConfigured() { return Boolean(this.apiKey); } getName() { return 'OpenAI'; } }
-
Register in the factory:
// src/services/aiService.js case 'openai': const { OpenAIProvider } = await import('./openaiService'); return new OpenAIProvider(config);
The modular architecture makes it easy to add:
- New commands - Extend the constants and handle in services
- Message reactions - Add to ChatMessage component
- Chat history - Enable in useChat hook options
- Themes - Modify CSS variables in
variables.css
- Buffer Strategy - Tokens accumulate in mutable refs, not React state
- RAF Batching - State flushes on requestAnimationFrame (~50ms intervals)
- Isolated Rendering - Streaming content separate from message list
- useStickyScroll - Passive scroll listeners, debounced position checks
- Plain Text During Stream - Markdown parsing only on completion
- React.memo on all components to prevent unnecessary re-renders
- useCallback for event handlers
- useTransition for non-blocking UI updates (React 19)
- CSS containment for isolated layout calculations
- Performance: 95+
- Accessibility: 100
- Best Practices: 100
- SEO: 100
# Coming soon
npm run test # Run unit tests
npm run test:e2e # Run E2E tests
npm run test:coverage| Command | Description |
|---|---|
npm run dev |
Start development server |
npm run build |
Build for production |
npm run preview |
Preview production build |
npm run lint |
Run ESLint |
npm run lint:fix |
Fix ESLint issues |
Contributions are welcome! Please read our contributing guidelines before submitting PRs.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Google Gemini for the AI API
- React for the UI framework
- Vite for the build tool
- OpenAI's ChatGPT for UI inspiration
Built with β€οΈ by Padam
If you find this project useful, please consider giving it a β