This project converts natural language questions into SQL queries and executes them against a database, providing comprehensive results.
- app/app.py: Main Flask application entry point
- app/api/routes.py: API endpoints for query processing
- app/services/nl_to_sql_service.py: Natural language to SQL conversion using LangChain
- app/services/query_service.py: SQL query execution and result formatting
- app/services/langchain_service.py: Advanced LangChain capabilities with SQL reasoning
- app/database/: Database connection and schema management
- ui/streamlit_app.py: Streamlit-based user interface
- Clone the repository
- Install dependencies:
pip install -r requirements.txt - Configure your database connection in
.env - Run the application:
python main.py - Access the UI at http://localhost:8501
- Full Documentation (PDF) - Detailed explanation of architecture, implementation, and usage
- Demo Video - Watch the application in action
Try these example queries:
- What are the top 5 most selling product?
- Provide an overview of the current inventory status, including the count of products in stock for each store.
- Calculate the processing time for orders and identify the staff members with slower processing time.
- How many orders were placed at each store?
- Compare the sales performance of each store in terms of total revenue and average order value.
- How has the total sales revenue changed over the previous quarters?
- Identify the top 10 customers who have made the most purchases.
- For each product category, identify the top-selling product based on total sales.
The database schema and sample data are available in the database_resources folder.
Follow these steps to set up your PostgreSQL database:
- Create a database named
bikestores. - Execute
sqlcreatetables.sqlto set up the schema. - Import data in the following order:
production_categories.sqlproduction_brands.sqlsales_customers.sqlsales_stores.sqlproduction_products.sqlsales_staffs.sqlsales_orders.sqlsales_order_items.sqlproduction_stocks.sql