Skip to content

AI-Powered Chatbot with Gemini API, User Login, and Persistent Memory – A streamlined question-answering system with user authentication, real-time chat using Gemini Pro, and buffered memory for seamless conversational context.

License

Notifications You must be signed in to change notification settings

Md-Emon-Hasan/Chatbot-with-User-Login

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧠 Chatbot with User Login (MySQL)

A secure, memory-augmented Generative AI Chatbot powered by Google Gemini Pro using LangChain, with full user login/registration backed by XAMPP-based MySQL database. The chatbot remembers conversations using LangChain’s ConversationBufferMemory, enabling contextual follow-up questions.


🚀 Demo

Image

📌 Key Features

✅ Gemini-Pro API integration via LangChain ✅ Secure login & registration with MySQL (via XAMPP/phpMyAdmin) ✅ Per-user conversation memory (LangChain's ConversationBufferMemory) ✅ Fully interactive chatbot built with Streamlit ✅ Modular codebase for easy extension ✅ Environment-variable based secret management (.env) ✅ Extendable for LangGraph or multi-agent agentic workflows


🛠️ Tech Stack

Layer Technology
💬 LLM Gemini-2.5-Pro via LangChain
🧠 Memory LangChain ConversationBufferMemory
🌐 UI Streamlit
🔐 Auth MySQL (XAMPP) + SHA256 hashing
🔌 Backend Python + LangChain + mysql-connector-python

🧱 Project Structure

chatbot/
├── app.py                 # Main Streamlit App
├── db.py                  # MySQL login/register functions
├── langchain_gemini.py    # LLM + memory integration
├── .env                   # Secure Gemini API key
├── requirements.txt       # Python dependencies

⚙️ Setup Instructions

1. ✅ Clone Repository

git clone https://github.com/your-username/Chatbot-with-User-Login.git
cd Chatbot-with-User-Login

2. ✅ Install Requirements

pip install -r requirements.txt

3. ✅ Configure Gemini API Key

Create a .env file:

GEMINI_API_KEY=your_actual_gemini_api_key

4. ✅ Setup MySQL DB via XAMPP

  1. Launch XAMPP → Start Apache & MySQL
  2. Visit: http://localhost/phpmyadmin
  3. Run SQL:
CREATE DATABASE chatbot;
USE chatbot;

CREATE TABLE users (
  id INT AUTO_INCREMENT PRIMARY KEY,
  username VARCHAR(50) UNIQUE,
  password VARCHAR(255)
);

▶️ Run the App

streamlit run app.py

👤 User Flow

  1. User registers/login via MySQL database.
  2. On successful login, a personalized LangChain memory session starts.
  3. Gemini LLM answers the user queries with context.
  4. Chat memory persists for the session (can be extended for long-term storage).
  5. User can logout anytime.

🔒 Security Notes

  • Passwords are hashed with SHA256 (upgradeable to bcrypt/argon2).
  • Gemini API key is stored in .env file (never commit this).
  • No chat history is stored in database (unless you extend memory to MySQL).

📈 Possible Extensions

Feature Status
LangGraph orchestration 🔜 Planned
Multi-agent Planner-Executor 🔜 Planned
Chat history storage (MySQL) 🔜 Optional
Admin dashboard 🔜 Optional
Tool-augmented answers (PDF/API) 🔜 Future
Multi-user chat insights 🔜 Future

🤝 Contribution

Pull requests, feature suggestions, and feedback are welcome!


📄 License

MIT License


📬 Contact

👤 Developed by: Md Emon Hasan 📧 Email: iconicemon01@gmail.com 💬 WhatsApp: +8801834363533 💻 GitHub: Md-Emon-Hasan


About

AI-Powered Chatbot with Gemini API, User Login, and Persistent Memory – A streamlined question-answering system with user authentication, real-time chat using Gemini Pro, and buffered memory for seamless conversational context.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages