π An AI-powered database management system that optimizes query performance and safeguards data integrity using Flask, SQLAlchemy, and Scikit-learn.
The AI-Based Cloud Database Management System is a Flask-powered API that allows users to manage simulated cloud database transactions while utilizing a basic AI model to suggest query optimizations. The project enables storing, retrieving, and analyzing database transactions while providing automated AI-based recommendations to improve performance.
This system simulates a real-world cloud database where AI-driven analytics optimize query execution times based on historical transaction data.
β
Flask REST API for handling database transactions.
β
SQLite Integration to store and retrieve transactions.
β
Basic AI Module to analyze and suggest query optimizations.
β
Automated Transaction Simulation for testing system behavior.
β
Postman & cURL Support for easy API interaction.
β
Error Handling & Debugging to prevent unexpected crashes.
| Technology | Purpose |
|---|---|
| Flask | Lightweight web framework for API development. |
| Flask-SQLAlchemy | ORM for managing database interactions. |
| SQLite | Simple and efficient local database. |
| Scikit-learn | AI module for performance optimization. |
| pandas | Data handling and preprocessing. |
| python-dotenv | Securely managing environment variables. |
- Flask is easy to use and lightweight, perfect for building RESTful APIs.
- SQLAlchemy simplifies database operations without complex SQL queries.
- SQLite provides a lightweight, embedded database for local testing.
- Scikit-learn enables simple AI-based performance tuning using regression models.
git clone https://github.com/Vaskar71/AI-Driven-Cloud-Database-Performance-Optimizer.git
cd AI-Cloud-DB-Managementpython -m venv venv
source venv/bin/activate # On macOS/Linux
venv\Scripts\activate # On Windowspip install -r requirements.txtCreate a .env file and add the following configuration:
FLASK_APP=app.py
FLASK_DEBUG=1
DATABASE_URL=sqlite:///cloud_db.sqlite3
SECRET_KEY=your_secret_keypython -c "from app import db; db.create_all()"python app.pyVisit http://127.0.0.1:5000/ in your browser. You should see:
Welcome to the AI-Based Cloud Database Management System!
Use Postman or cURL to send a request:
curl -X POST http://127.0.0.1:5000/transaction -H "Content-Type: application/json" \
-d '{"operation":"INSERT","data":"Sample data","performance_metric":2.0}'curl http://127.0.0.1:5000/transactionspython simulation.py| Environment Variable | Description |
|---|---|
FLASK_APP |
Defines the Flask entry point. |
FLASK_DEBUG |
Enables debugging mode. |
DATABASE_URL |
Sets the database connection URL. |
SECRET_KEY |
Used for session security. |
To modify AI behavior, adjust the training dataset inside ai_optimizer.py.
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Welcome message. |
| POST | /transaction |
Adds a new database transaction. |
| GET | /transactions |
Retrieves all stored transactions. |
Example Request (POST /transaction):
{
"operation": "INSERT",
"data": "Sample entry",
"performance_metric": 2.5
}Example Response (201 Created):
{
"message": "Transaction added successfully.",
"id": 1
}- Uses Linear Regression (Scikit-learn) to predict the best database optimization level based on performance metrics.
- Called automatically after every transaction to suggest improvements.
- Can be tested manually by running:
python ai_optimizer.py
Expected Output:
For a performance metric of 1.8, Suggested optimization level: 3.10
π [Attach relevant screenshots here]
- β
Flask API running (
python app.py)

- β
Postman API test (
POST /transaction)
- β
AI Optimization Output (
python simulation.py)
- β
Database Structure in SQLite

We welcome contributions! To contribute:
- Fork this repository.
- Create a new branch (
git checkout -b feature-branch). - Commit your changes (
git commit -m "Added new feature"). - Push the branch (
git push origin feature-branch). - Create a Pull Request.
For issues and feedback, create a GitHub Issue or contact:
π§ Email: [email protected]
