A modern, beautiful AI-powered chatbot built with React and Google Gemini AI.
Features β’ Demo β’ Installation β’ Usage β’ API β’ Contributing
- π€ AI-Powered Conversations - Powered by Google Gemini 2.5 Flash model
- π¨ Modern Dark Theme UI - Beautiful glassmorphism design with animated gradients
- β¨ Smooth Animations - Liquid blob backgrounds, message slide-ins, typing indicators
- π Markdown Support - Renders formatted responses with headers, lists, code blocks, tables
- π¬ Real-time Chat - Instant messaging with loading states
- π± Fully Responsive - Works beautifully on desktop and mobile
- π Quick Suggestions - Pre-built prompts for easy start
- π― Auto-scroll - Automatically scrolls to latest messages
The chatbot features a stunning dark theme with animated gradient blobs, glassmorphism effects, and smooth transitions.
- Header with status indicator and gradient text
- Chat Window with user/bot avatars and styled message bubbles
- Input Area with animated send button
- Typing Indicator with bouncing dots
- Suggestion Buttons for quick prompts
| Technology | Version | Purpose |
|---|---|---|
| React | 19.2.0 | UI Framework |
| Vite | 7.2.4 | Build Tool |
| react-markdown | 10.1.0 | Markdown Rendering |
| CSS3 | - | Styling & Animations |
| Technology | Version | Purpose |
|---|---|---|
| Node.js | - | Runtime |
| Express | 4.18.2 | Web Server |
| @google/genai | 1.34.0 | Gemini AI SDK |
| cors | 2.8.5 | Cross-Origin Requests |
| dotenv | 16.3.1 | Environment Variables |
- Node.js (v18 or higher)
- npm or yarn
- Google Gemini API Key (Get one here)
git clone https://github.com/yourusername/chatbot.git
cd chatbot# Navigate to backend directory
cd Backend
# Install dependencies
npm install
# Create environment file
cp .env.example .env
# Add your Gemini API key to .env
echo "GEMINI_API_KEY=your_api_key_here" > .env# Navigate to frontend directory
cd ../Frontend/chatbot
# Install dependencies
npm installTerminal 1 - Start Backend:
cd Backend
npm start
# or with nodemon for auto-reload
nodemon server.jsBackend runs on http://localhost:3000
Terminal 2 - Start Frontend:
cd Frontend/chatbot
npm run devFrontend runs on http://localhost:5173
Build Frontend:
cd Frontend/chatbot
npm run buildStart Server (serves both API and built frontend):
cd Backend
npm startAccess at http://localhost:3000
chatbot/
βββ π Backend/
β βββ π server.js # Express server & API routes
β βββ π package.json # Backend dependencies
β βββ π .env # Environment variables (not in git)
β βββ π public/ # Static files
β
βββ π Frontend/
β βββ π chatbot/
β βββ π src/
β β βββ π App.jsx # Main React component
β β βββ π App.css # Styles & animations
β β βββ π main.jsx # React entry point
β β βββ π assets/ # Static assets
β βββ π index.html # HTML template
β βββ π vite.config.js # Vite configuration
β βββ π package.json # Frontend dependencies
β
βββ π .gitignore # Git ignore rules
βββ π README.md # This file
Send a message to the AI and receive a response.
Request:
{
"message": "Hello, how are you?"
}Response:
{
"choices": [
{
"message": {
"role": "assistant",
"content": "Hello! I'm doing great, thank you for asking! How can I help you today?"
}
}
]
}Error Response:
{
"error": "Something went wrong"
}Create a .env file in the Backend/ directory:
# Required
GEMINI_API_KEY=your_gemini_api_key_here
# Optional
PORT=3000The frontend proxies API requests to the backend. Configuration in vite.config.js:
export default defineConfig({
plugins: [react()],
server: {
proxy: {
"/api": {
target: "http://localhost:3000",
changeOrigin: true,
},
},
},
});Edit the CSS variables in App.css:
/* Primary gradient colors */
background: linear-gradient(135deg, #7c3aed 0%, #ec4899 100%);
/* Background color */
background: #0f0f1a;
/* Accent color */
color: #a78bfa;Edit server.js:
const response = await ai.models.generateContent({
model: "gemini-2.5-flash", // Change model here
contents: userMessage
});Edit the suggestions array in App.jsx:
<div className="suggestions">
<button className="suggestion" onClick={() => handleSuggestionClick("Your prompt here")}>
π― Your Label
</button>
{/* Add more suggestions */}
</div>| Issue | Solution |
|---|---|
CORS error |
Ensure backend is running and CORS is configured |
API key invalid |
Check your .env file has correct Gemini API key |
Cannot connect to server |
Verify backend is running on port 3000 |
Module not found |
Run npm install in both Backend and Frontend |
Port already in use |
Kill the process or change PORT in .env |
Check browser console and terminal for error messages.
| Command | Description |
|---|---|
npm start |
Start the server |
nodemon server.js |
Start with auto-reload |
| 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 |
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some 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.
Ali
- GitHub: Ali1180-uni
- Google Gemini AI for the powerful AI model
- React for the amazing UI framework
- Vite for the blazing fast build tool
Made with β€οΈ by Ali
β Star this repo if you found it helpful!