A modern, AI-powered C++ library for connecting to and interacting with YugabyteDB (PostgreSQL-compatible distributed database), featuring a beautiful web-based frontend with advanced AI capabilities.
- Distributed Database Connectivity: Robust connection management with connection pooling
- Full CRUD Support: Execute SELECT, INSERT, UPDATE, DELETE operations with ease
- AI-Powered Query Builder: Convert natural language to SQL queries
- Query Optimization: AI-driven query optimization suggestions and performance analysis
- Beautiful Web Interface: Modern, responsive UI with real-time data visualization
- RESTful API: Clean REST API for programmatic access
- Performance Monitoring: Track query execution times and resource usage
- Transaction Support: Safe multi-query transaction handling
- YBConnector: Manages database connections with connection pooling
- YBQueryExecutor: Handles query execution and parameter binding
- YBResultSet: Provides convenient iteration over query results
- YBException: Comprehensive exception hierarchy for error handling
- APIServer: REST API server built with Poco::Net
- AIQueryGenerator: Natural language to SQL conversion
- QueryOptimizer: Query performance analysis and optimization suggestions
- Modern UI: Gradient design with smooth animations
- SQL Editor: Syntax-highlighted code editor powered by CodeMirror
- AI Assistant: Natural language query interface
- Data Visualization: Interactive charts and graphs with Chart.js
- Query Optimizer Panel: Real-time optimization recommendations
- Performance Dashboard: Monitor query metrics and history
-
CMake (3.14 or higher)
# Windows (using Chocolatey) choco install cmake # Or download from https://cmake.org/download/
-
C++ Compiler with C++14 support
- Visual Studio 2019 or later (Windows)
- GCC 5.0+ or Clang 3.8+ (Linux/Mac)
-
Poco C++ Libraries (1.9.0 or higher)
Option 1: Using vcpkg (Recommended)
# Install vcpkg if not already installed git clone https://github.com/Microsoft/vcpkg.git cd vcpkg .\bootstrap-vcpkg.bat # Install Poco .\vcpkg install poco:x64-windows # Integrate with Visual Studio .\vcpkg integrate install
Option 2: Manual Installation
- Download from https://pocoproject.org/download.html
- Follow installation instructions for your platform
-
YugabyteDB (latest stable version)
Windows (using Docker - Recommended)
docker run -d --name yugabytedb_node1 -p7000:7000 -p9000:9000 -p5433:5433 -p9042:9042 \ yugabytedb/yugabyte:latest bin/yugabyted start --daemon=false
Direct Installation
# Download from https://download.yugabyte.com/ # Extract and run: cd yugabyte-<version> .\bin\yugabyted.exe start
- Host: localhost
- Port: 5433 (PostgreSQL compatible)
- Database: yugabyte
- Username: yugabyte
- Password: yugabyte
cd "C:\Poco c++"mkdir build
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=<path-to-vcpkg>/scripts/buildsystems/vcpkg.cmakeWithout vcpkg (if Poco is installed system-wide):
cmake ..cmake --build . --config ReleaseOr using Visual Studio:
cmake --build . --config Release --target ybconnector-server example-app.\Release\example-app.execd build\Release
.\ybconnector-server.exeThe server will start on http://localhost:8080
- Open a web browser
- Navigate to:
http://localhost:8080/web/index.html
Or serve the web files directly:
If you have Python installed:
cd web
python -m http.server 8000Then access: http://localhost:8000/index.html
Note: Make sure the API server is running on port 8080
#include "YBConnector.h"
#include "YBQueryExecutor.h"
using namespace YB;
int main() {
try {
// 1. Create and connect to database
YBConnector connector("localhost", "5433", "yugabyte", "yugabyte", "yugabyte");
connector.connect();
// 2. Create query executor
YBQueryExecutor executor(connector);
// 3. Execute SELECT query
auto result = executor.executeQuery("SELECT * FROM users WHERE age > 25");
while (result->next()) {
std::cout << result->get<std::string>("name") << std::endl;
}
// 4. Execute INSERT
size_t rowsAffected = executor.executeUpdate(
"INSERT INTO users (name, email) VALUES ('John', 'john@example.com')"
);
// 5. Disconnect
connector.disconnect();
} catch (const YBException& e) {
std::cerr << "Error: " << e.what() << std::endl;
}
return 0;
}POST http://localhost:8080/api/connect
Content-Type: application/json
{
"host": "localhost",
"port": "5433",
"database": "yugabyte",
"username": "yugabyte",
"password": "yugabyte"
}POST http://localhost:8080/api/query/execute
Content-Type: application/json
{
"query": "SELECT * FROM users LIMIT 10"
}POST http://localhost:8080/api/query/ai-generate
Content-Type: application/json
{
"query": "Show me all users over 25 years old"
}POST http://localhost:8080/api/query/optimize
Content-Type: application/json
{
"query": "SELECT * FROM users WHERE age > 25 ORDER BY name"
}- Connection Manager: Enter database credentials and connect
- AI Query Builder: Type natural language queries to generate SQL
- SQL Editor: Write and execute SQL queries with syntax highlighting
- Results Display: View query results in a beautiful table
- Data Visualization: Automatically visualize query results
- Query Optimizer: Get AI-powered optimization suggestions
- Performance Metrics: Monitor query execution times
- Query History: Access previously executed queries
cd build
cmake --build . --config Release --target tests
.\Release\tests.exeThe example application (example-app.exe) demonstrates:
- β Database connection and authentication
- β SELECT queries with various WHERE clauses
- β INSERT, UPDATE, DELETE operations
- β Transaction support
- β Error handling
- β Connection pooling
Poco c++/
βββ CMakeLists.txt # Build configuration
βββ README.md # This file
βββ include/ # Public headers
β βββ YBConnector.h
β βββ YBQueryExecutor.h
β βββ YBResultSet.h
β βββ YBException.h
β βββ AIHelpers.h
βββ src/ # Implementation files
β βββ YBConnector.cpp
β βββ YBQueryExecutor.cpp
β βββ YBResultSet.cpp
β βββ YBException.cpp
β βββ APIServer.cpp
β βββ AIQueryGenerator.cpp
β βββ QueryOptimizer.cpp
βββ examples/ # Example applications
β βββ main.cpp
βββ web/ # Web frontend
β βββ index.html
β βββ css/
β β β crisp styles.css
β βββ js/
β βββ app.js
β βββ ai-assistant.js
β βββ visualizer.js
βββ tests/ # Unit tests
βββ build/ # Build artifacts
1. Connection Refused
- Ensure YugabyteDB is running
- Check port 5433 is not blocked by firewall
- Verify connection credentials
2. Poco Library Not Found
# Set POCO_ROOT environment variable
$env:POCO_ROOT = "C:\path\to\poco"
cmake .. -DPOCO_ROOT="C:\path\to\poco"3. Build Errors on Windows
- Ensure you have Visual Studio Build Tools installed
- Use Developer Command Prompt for VS
- Check CMake generator:
cmake -G "Visual Studio 16 2019" ..
4. Web Interface Can't Connect to API
- Verify API server is running on port 8080
- Check browser console for CORS errors
- Ensure firewall allows connection to localhost:8080
Modify connection pool size in YBConnector constructor:
YBConnector connector(host, port, db, user, pass, poolSize=5);Change port in APIServer.cpp:
unsigned short port = 8080; // Change to desired portThis project is provided as-is for educational and demonstration purposes.
Contributions are welcome! Please ensure:
- Code follows C++14 standards
- All tests pass
- Code is properly commented
- Documentation is updated
- Additional database backends (MySQL, SQLite)
- GraphQL API support
- Real-time query result streaming
- Advanced caching layer
- Multi-database query federation
- Enhanced AI features with machine learning models
For issues, questions, or suggestions, please create an issue in the project repository.
Made with β€οΈ using C++ and Poco Libraries