A web-based AI chatbot powered by Google Gemini 2.5 Flash, built with Node.js and Express. Supports multiple conversations, chat history, and a clean browser UI.
- Real-time AI responses via Google Gemini
- Multiple conversations with persistent history
- Auto-generated chat titles from the first message
- Rename and delete conversations
- Guest sessions (no login required)
- Rate-limit retry handling
- Markdown rendering in responses
chatbot/
├── server.js # Express server & API routes
├── package.json
├── .env # API keys (not committed)
├── public/
│ ├── index.html
│ ├── chat.html # Main chat UI
│ ├── css/
│ │ └── style.css
│ └── js/
│ ├── auth.js
│ └── chat.js
└── data/
├── users.json # User data
└── chats/ # Per-user conversation files
npm installCreate a .env file in the project root:
GEMINI_API_KEY=your_gemini_api_key_here
SESSION_SECRET=your_session_secret_here
PORT=3000Get a free Gemini API key at https://aistudio.google.com/app/apikey.
npm startOpen http://localhost:3000 in your browser.
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/auth/me |
Get current session user |
| GET | /api/chat/history |
List all conversations |
| POST | /api/chat/new |
Create a new conversation |
| GET | /api/chat/:id |
Get a conversation with messages |
| POST | /api/chat/send |
Send a message and get AI response |
| PUT | /api/chat/:id/rename |
Rename a conversation |
| DELETE | /api/chat/:id |
Delete a conversation |
- express — Web framework
- @google/generative-ai — Gemini API client
- express-session — Session management
- uuid — Unique ID generation
- dotenv — Environment variable loading
- bcryptjs — Password hashing
- marked — Markdown rendering