A modern, web-based database management and visualization platform built with Flask. ChatDB allows users to upload data, execute SQL queries, create interactive visualizations, and leverage AI-powered query suggestions.
- Multi-format Support: Upload CSV, JSON, and Excel files
- SQL Query Execution: Execute SELECT queries with real-time results
- Data Validation: Built-in SQL injection prevention and query validation
- Query History: Track and review all executed queries
- Interactive Charts: Create bar charts, line charts, and scatter plots
- Dynamic Plotting: Automatic data type detection and formatting
- Export Capabilities: Download visualizations as high-resolution images
- Real-time Updates: Instant chart generation from query results
- Smart Suggestions: AI-powered SQL query suggestions using Hugging Face
- Query Optimization: Get intelligent recommendations for better queries
- Error Analysis: AI assistance for debugging query issues
- Secure Authentication: User registration and login system
- Session Management: Persistent user sessions across the application
- User Dashboard: Personalized statistics and activity tracking
- Multi-user Support: Isolated data and queries per user
- Responsive Design: Works seamlessly on desktop and mobile devices
- Bootstrap UI: Clean, modern interface with intuitive navigation
- Real-time Feedback: Instant notifications and status updates
- Dark Theme: Professional dark mode interface
Application URL: https://chatdb-hcm5.onrender.com
Note: Hosted on Render's free tier — the first request after a period of inactivity may take 30–60 seconds while the instance wakes up.
- Python 3.10 or higher
- pip (Python package installer)
- Git
-
Clone the repository
git clone https://github.com/DHYEY166/ChatDB.git cd ChatDB -
Create a virtual environment
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
-
Install dependencies
pip install -r requirements.txt
-
Set up environment variables
cp .env.example .env # Edit .env and fill in SECRET_KEY and optionally HUGGINGFACE_API_KEY -
Run the application
python app.py
-
Access the application Open your browser and navigate to
http://localhost:5000
-
Fork or clone this repository to your GitHub account
-
Create a new Web Service on Render:
- Connect your GitHub repository
- Set the build command:
pip install -r requirements.txt - Set the start command:
gunicorn app:app
-
Configure environment variables:
SECRET_KEY: Generate a random secret keyHUGGINGFACE_API_KEY: Your Hugging Face API key
-
Deploy: Render will automatically deploy your application
# Install Railway CLI
npm install -g @railway/cli
# Login and deploy
railway login
railway init
railway up# Install Heroku CLI and deploy
heroku create your-app-name
git push heroku mainChatDB/
├── app.py # App factory (create_app)
├── extensions.py # SQLAlchemy instance
├── models.py # ORM models (User, QueryHistory, DatabaseConnection)
├── utils.py # Shared helpers (validate_sql, login_required, HF suggest)
├── blueprints/
│ ├── auth.py # /login /register /logout
│ ├── data.py # /manage /upload /connect /history
│ ├── visualize.py # /visualize /report
│ └── ai.py # /ai-suggest
├── tests/
│ ├── conftest.py # pytest fixtures
│ └── test_routes.py # Route and utility tests
├── templates/ # Jinja2 HTML templates
├── static/ # CSS and JS assets
├── requirements.txt # Python dependencies
├── render.yaml # Render deployment config
├── deploy.sh # Deploy helper script
└── .env.example # Environment variable template
| Variable | Description | Required |
|---|---|---|
SECRET_KEY |
Flask secret key for session management | Yes |
HUGGINGFACE_API_KEY |
Hugging Face API key for AI features | No |
PORT |
Port for the application (auto-set by platform) | No |
The application uses SQLite by default, which is perfect for development and small to medium deployments. For production with high traffic, consider:
- PostgreSQL: For better performance and concurrent users
- MySQL: For enterprise environments
- Cloud Databases: AWS RDS, Google Cloud SQL, etc.
- Register an account on the application
- Upload your data (CSV, JSON, or Excel files)
- Execute queries using the SQL interface
- Create visualizations from your query results
- Explore AI suggestions for query optimization
-- Basic SELECT query
SELECT * FROM your_table LIMIT 10;
-- Aggregation with GROUP BY
SELECT category, COUNT(*) as count
FROM your_table
GROUP BY category;
-- Complex joins
SELECT t1.name, t2.value
FROM table1 t1
JOIN table2 t2 ON t1.id = t2.id;- SQL Injection Prevention: Query validation and sanitization
- Input Validation: Comprehensive input checking
- Session Security: Secure session management
- Error Handling: Safe error messages without exposing internals
- File Upload Security: File type and size validation
pip install -r requirements.txt
pytest tests/- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Flask: Web framework
- Bootstrap: UI framework
- Pandas: Data manipulation
- Matplotlib: Data visualization
- Hugging Face: AI integration
- Render: Hosting platform
If you encounter any issues or have questions:
- Check the Issues page
- Create a new issue with detailed information
- Include error messages and steps to reproduce
Made by Dhyey Desai