This module provides a web interface for the Arkaid project, featuring natural language to SQL query conversion powered by TogetherAI and interactive data visualization capabilities.
The Interface module offers:
- Natural language to SQL query conversion
- Interactive query execution and visualization
- Database connection management
- Query analysis and decomposition
- Performance monitoring and optimization
app.py
: Main Flask application and web serverai.py
: TogetherAI integration for natural language processingqa.py
: Query analysis and insights functionalityqd.py
: Query decomposition and optimization logic
config.yaml
: Main configuration file for database and application settings.env.example
: Environment variables template for sensitive credentialsprompt.txt
: AI system prompt configuration for query generationdb_config_generator.py
: Automated database configuration generator
connection_tester.py
: Database connection testing utilityexample_usage.py
: Example implementations and usage patterns
templates/
: HTML templates for web pagesindex.html
: Main landing pagequery.html
: Query execution and results pageai.html
: Natural language query interface
static/
: CSS and static assetsstyles.css
: Main stylesheetai.css
: AI interface styling
queries_p1/
: Predefined query examples and templates
- Environment Configuration:
cp .env.example .env
# Edit .env with your credentials and API keys
- Install Dependencies:
pip install -r requirements.txt
- Configure Database:
python db_config_generator.py
- Test Connections:
python connection_tester.py
python app.py
The application will be available at http://localhost:4321
- Navigate to the AI interface
- Enter your query in natural language
- Review the generated SQL
- Execute the query and view results
- Browse available queries in the main interface
- Select a query to view details and execution plan
- Execute the query and analyze results
- Converts English queries to SQL using TogetherAI
- Provides query explanations and insights
- Handles complex analytical queries
- Supports multiple database sources
- Query analysis and optimization
- Performance monitoring
- Result visualization
- Error handling and debugging
- Supports multiple database connections
- Handles materialized views
- Manages complex joins and subqueries
- Provides query decomposition
- Flask
- psycopg2
- pandas
- PyYAML
- python-dotenv
- sqlanalyzer
- SQLAlchemy
- rich
- openai
- TogetherAI API for natural language processing
- PostgreSQL databases
- The interface runs on port 4321 by default
- Natural language processing requires a valid TogetherAI API key
- Query execution is optimized for materialized views when possible
- The interface includes built-in error handling and user feedback
- All database operations are executed with appropriate security measures