This is a Flask-based chatbot application that uses Google's Gemini API to provide algorithmic explanations and approaches for DSA problems. The application includes a history panel for accessing past conversations and uses MongoDB for data storage, along with NumPy and Pandas for data analysis.
- Text-based interface for inputting DSA problems
- Algorithmic approach explanations using Google Gemini API
- Focus on explaining time/space complexity and data structures
- Step-by-step approach explanation without full code solutions
- History panel for accessing past conversations (like ChatGPT/Gemini)
- MongoDB database for storing conversations and user sessions
- Data analysis using NumPy and Pandas
- Python 3.8+
- Flask
- Google Generative AI SDK
- MongoDB
- PyMongo
- NumPy
- Pandas
- HTML/CSS/JavaScript
- Bootstrap 5
- Clone or download the project files
- Create a virtual environment (optional but recommended):
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
- Install the required dependencies:
pip install -r requirements.txt
- Get a Google Gemini API key from Google AI Studio
- Rename
.env.exampleto.envand fill in your configuration:GEMINI_API_KEY=your_gemini_api_key_here MONGO_URI=mongodb://localhost:27017/chatbot_db SECRET_KEY=your_secret_key_here - Make sure MongoDB is running on your system
- Run the application:
python app.py
- Open your browser and go to
http://localhost:5000
- Type your DSA problem or question in the input field at the bottom
- The chatbot will provide algorithmic explanations without code
- Access your conversation history in the left sidebar
- Click on any previous conversation to continue from where you left off
- Use the "New Chat" button to start a fresh conversation
- Use the "Clear All" button to delete all conversations
The application includes analytics features that use NumPy and Pandas to analyze:
- User engagement patterns
- Message length statistics
- Conversation frequency
- Activity time trends
Analytics can be accessed via the /api/analytics/usage endpoint.
chatbot/
├── app/
│ ├── __init__.py
│ ├── models/
│ │ ├── database.py
│ │ └── models.py
│ ├── routes/
│ │ ├── main.py
│ │ ├── history.py
│ │ ├── api.py
│ │ └── analytics.py
│ ├── static/
│ │ └── css/
│ │ └── style.css
│ └── templates/
│ ├── base.html
│ ├── index.html
│ └── history.html
├── app.py
├── requirements.txt
├── .env
└── README.md
GET /- Main chat interfacePOST /api/chat- Send a message and get a responseGET /api/conversations- Get all conversations for a userGET /api/conversation/<id>- Get a specific conversation with its messagesPOST /api/new_conversation- Start a new conversationGET /api/history/conversations- Get conversation history for the history panelDELETE /api/history/conversation/<id>- Delete a specific conversationDELETE /api/history/conversations- Delete all conversationsGET /api/analytics/usage- Get usage analytics
The application uses three collections:
users- Stores user informationconversations- Stores conversation metadata (title, timestamps)messages- Stores individual messages within conversations
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request