A modern, real-time AI chatbot interface powered by Google Gemini API
Features β’ Getting Started β’ Architecture β’ API Reference
Ops AI is a cutting-edge web application that brings intelligent conversational capabilities to your fingertips. Built with React and powered by Google's advanced Gemini AI model, Ops AI provides seamless, real-time conversations with an intelligent assistant.
Whether you need quick answers, assistance with tasks, or intelligent conversation - Ops AI delivers professional-grade AI interactions through an intuitive, modern interface.
- β‘ Lightning-Fast Responses - Real-time AI conversations with minimal latency
- π¨ Modern UI/UX - Clean, responsive design with smooth animations
- π Persistent Chat History - View entire conversation threads with context awareness
- π€ Powered by Google Gemini - State-of-the-art AI model for intelligent responses
- π± Fully Responsive - Works seamlessly on desktop, tablet, and mobile devices
- Real-Time Chat Interface - Send messages and receive intelligent responses instantly
- Message History Management - Track complete conversation threads with role-based message display
- Auto-Scrolling - Chat body automatically scrolls to the latest message
- Thinking State - Visual feedback with "Thinking..." indicator while AI processes requests
- Word Wrapping - Long messages gracefully wrap without overflow
- Intuitive Input Form - Easy message submission with text input and send button
- Visual Message Differentiation - Distinct styling for user vs. bot messages
- Icon Integration - Custom chatbot icon displays for AI responses
- Empty State Handling - Prevents submission of empty messages
- Material Design Icons - Professional icon system using Google Material Symbols
- Component-Based Architecture - Modular, reusable React components
- State Management - React Hooks (useState, useRef, useEffect) for efficient state handling
- API Integration - Seamless integration with Google Gemini API
- Error Handling - Robust error catching and user feedback
- Markdown Processing - Automatic removal of markdown formatting from API responses
- Node.js (v14 or higher)
- npm or yarn package manager
- Google Gemini API Key (Get it from Google AI Studio)
-
Clone the repository
git clone https://github.com/yourusername/ops-ai.git cd ops-ai -
Install dependencies
npm install
-
Set up environment variables Create a
.envfile in the root directory:VITE_API_URL=https://generativelanguage.googleapis.com/v1beta/models/gemini-3-flash-preview:generateContent?key=YOUR_API_KEY_HERE
-
Start the development server
npm run dev
-
Open in browser Navigate to
http://localhost:5173(or the URL shown in terminal)
npm run buildThe optimized build will be created in the dist/ directory.
ops-ai/
βββ src/
β βββ App.jsx # Main application component & chat logic
β βββ main.jsx # React root entry point
β βββ index.css # Global styling & component styles
β βββ Components/
β βββ ChatForm.jsx # Message input form component
β βββ ChatMessage.jsx # Individual message display component
β βββ ChatbotIcon.jsx # Chatbot visual icon component
βββ index.html # HTML entry point
βββ vite.config.js # Vite configuration
βββ package.json # Project dependencies
βββ .env # Environment variables (API key)
User Input
β
ChatForm (handles submission)
β
App.jsx (updates chat history)
β
generateBotResponse (calls Gemini API)
β
API Response Processing (remove markdown)
β
ChatMessage Component (renders messages)
β
Display in Chat UI
Endpoint: https://generativelanguage.googleapis.com/v1beta/models/gemini-3-flash-preview:generateContent
Request Format:
{
"contents": [
{
"role": "user|model",
"parts": [{ "text": "message content" }]
}
]
}Response Format:
{
"candidates": [
{
"content": {
"parts": [
{ "text": "AI response text" }
]
}
}
]
}- State Management: Maintains chat history and manages component references
- generateBotResponse(): Handles API calls to Gemini, formats history, and updates UI
- Auto-scroll: Uses useEffect to keep chat scrolled to the latest message
- Error Handling: Catches and logs API errors gracefully
- Message Submission: Processes form submission and validates input
- Chat History Update: Adds user message to conversation history
- Delayed Bot Response: Shows "Thinking..." state before API response
- Input Clearing: Clears input field after message submission
- Conditional Rendering: Displays bot icon only for AI messages
- Dynamic Styling: Applies different styles based on message role (user/model)
- Message Display: Renders text content with proper formatting
- SVG Icon: Custom bot icon displayed next to AI messages
- Fixed Sizing: Maintains consistent 28x28px dimension
- Bot Message Background:
#f3f1ff(Light Purple) - Bot Message Text:
#333(Dark Gray) - User Message Background:
#6f63c6(Purple) - User Message Text:
white - Icon Color:
#6f63c6(Purple) - Background: Neutral tone with chatbot popup container
- Max Message Width: 75% of container
- Flexible Layout: Flexbox for responsive message arrangement
- Word Wrapping: Prevents message overflow on narrow screens
- Touch-Friendly: Adequate button sizing for mobile interaction
| Technology | Purpose | Version |
|---|---|---|
| React | UI Library | 19.2.0 |
| Vite | Build Tool & Dev Server | 7.2.4 |
| Google Gemini API | AI Backend | v1beta |
| CSS3 | Styling | Latest |
| ES6+ JavaScript | Programming Language | Latest |
react@^19.2.0- UI libraryreact-dom@^19.2.0- React DOM rendering
vite@^7.2.4- Build tool@vitejs/plugin-react@^5.1.1- React plugin for Viteeslint@^9.39.1- Code quality- Additional ESLint plugins for React
Create a .env file in the root directory:
# Google Gemini API Configuration
VITE_API_URL=https://generativelanguage.googleapis.com/v1beta/models/gemini-3-flash-preview:generateContent?key=YOUR_API_KEY.env file to version control! Add it to .gitignore.
# Start development server
npm run dev
# Build for production
npm run build
# Preview production build locally
npm run preview
# Run ESLint for code quality
npm lint- Total Components: 4 main components
- Lines of Code: ~250 (excluding styling)
- External API Calls: Google Gemini API
- State Management: React Hooks
- Build Tool: Vite (Ultra-fast development experience)
Solution: Verify your API key is valid and correctly set in the .env file.
Solution:
- Check browser console for errors
- Ensure chatbot icon and message components are properly imported
- Verify API response structure matches expected format
Solution:
- Verify input ref is properly connected to the input element
- Check that ChatForm component receives required props
- Clear browser cache and restart dev server
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Google Gemini API - Powering the intelligent responses
- React Team - For the amazing UI library
- Vite Team - For the blazing-fast build tool
- Material Design - For beautiful icon system
For issues, questions, or suggestions:
- π§ Email: [email protected]
- π Report Issues
- π¬ Discussions
Made with β€οΈ using React & Google Gemini AI
β If you find this project helpful, please consider giving it a star!