Skip to content

AI-Based Cloud Database Management System that uses Flask, SQLAlchemy, and AI to manage and optimize database transactions. It automates data operations, analyzes query performance, and provides AI-powered optimization suggestions. Includes API endpoints, a simulation script, and error handling for efficient cloud database management.

Notifications You must be signed in to change notification settings

Vaskar71/AI-Driven-Cloud-Database-Performance-Optimizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

AI-Based Cloud Database Management System

πŸš€ An AI-powered database management system that optimizes query performance and safeguards data integrity using Flask, SQLAlchemy, and Scikit-learn.

Image

πŸ“– Description

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.


⭐ Features

βœ… 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.


πŸ›  Tech Stack & Why

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.

πŸ— Installation & Setup

πŸ”Ή 1. Clone the Repository

git clone https://github.com/Vaskar71/AI-Driven-Cloud-Database-Performance-Optimizer.git
cd AI-Cloud-DB-Management

πŸ”Ή 2. Create a Virtual Environment

python -m venv venv
source venv/bin/activate  # On macOS/Linux
venv\Scripts\activate     # On Windows

πŸ”Ή 3. Install Dependencies

pip install -r requirements.txt

πŸ”Ή 4. Set Up Environment Variables

Create 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_key

πŸ”Ή 5. Initialize the Database

python -c "from app import db; db.create_all()"

πŸ”Ή 6. Run the Flask Application

python app.py

πŸš€ Usage

1️⃣ Check if the API is Running

Visit http://127.0.0.1:5000/ in your browser. You should see:

Welcome to the AI-Based Cloud Database Management System!

2️⃣ Adding a New Transaction (POST Request)

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}'

3️⃣ Retrieving All Transactions (GET Request)

curl http://127.0.0.1:5000/transactions

4️⃣ Run the AI Optimization Simulation

python simulation.py

βš™οΈ Configuration

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.


πŸ”₯ API Endpoints

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
}

πŸ€– AI Optimization Module

  • 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

πŸ“Έ Screenshots

πŸ“Œ [Attach relevant screenshots here]

  • βœ… Flask API running (python app.py) Image Image
  • βœ… Postman API test (POST /transaction) Image
  • βœ… AI Optimization Output (python simulation.py) Image
  • βœ… Database Structure in SQLite
    Image

🀝 Contributing

We welcome contributions! To contribute:

  1. Fork this repository.
  2. Create a new branch (git checkout -b feature-branch).
  3. Commit your changes (git commit -m "Added new feature").
  4. Push the branch (git push origin feature-branch).
  5. Create a Pull Request.

πŸ“© Contact

For issues and feedback, create a GitHub Issue or contact:
πŸ“§ Email: [email protected]

About

AI-Based Cloud Database Management System that uses Flask, SQLAlchemy, and AI to manage and optimize database transactions. It automates data operations, analyzes query performance, and provides AI-powered optimization suggestions. Includes API endpoints, a simulation script, and error handling for efficient cloud database management.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages