This repository contains a Streamlit application designed to serve as a real-time Business Intelligence (BI) dashboard. It visualizes sales and order data, fetching both aggregate metrics and raw records from a backend workflow engine, n8n. It also includes functionality to generate a detailed AI-powered report on demand.
PerP/
├── README.md # Project documentation and setup instructions
├── app.py # Main Streamlit application (Frontend)
├── n8n_workflow.json # n8n workflow configuration (Backend automation)
└── pyproject.toml # Python dependencies
└──.python-version # Python version
app.py: The main Streamlit dashboard application that handles UI rendering, data visualization, and user interactionsn8n_workflow.json: Complete n8n workflow configuration that includes Airtable integration, data processing, and AI-powered insights generation
- Key Performance Indicators (KPIs): Real-time display of Total Orders, Total Revenue, Average Order Value, and Items Sold
- Data Visualization: Bar charts illustrating distributions across Order Status, Payment Method, and geographic breakdown by Country (Orders and Revenue)
- Dynamic Data Fetching: Data is sourced via a webhook endpoint from an n8n workflow
- Raw Data View: Ability to switch the view to see the raw records in a sortable table
- AI Report Generation: A dedicated button to trigger a separate webhook call to generate a text-based, analytical report using the Gemini 2.5 Flash model
To run this application, you need both the Python environment for the dashboard and the running n8n environment for the data source.
- Python 3.8+
- Dependencies listed in
requirements.txt
- A running n8n instance (latest version recommended)
- The n8n workflow must be configured and active, exposing two webhooks:
- Data Webhook: (for dashboard data and insights generation)
Replace withYOUR_DATA_WEBHOOK_URL - Report Webhook: (for AI report generation)
Replace withYOUR_REPORT_WEBHOOK_URL
- Data Webhook: (for dashboard data and insights generation)
The n8n workflow relies on the following integrations:
- Airtable Node: To fetch and process raw data
- Google Gemini Node (
gemini-2.5-flash-lite-preview-06-17): To generate the analytical report text
git clone <repository_url>
cd <project_directory>Install the required packages using the generated requirements.txt file:
pip install -r requirements.txtEnsure your n8n workflows are imported, configured with the correct API keys (Airtable, Gemini), and are activated to listen for webhook calls at the specified URLs.
Important: The Streamlit app assumes the n8n instance is accessible. Adjust the
ENDPOINT_URLandREPORT_WEBHOOK_URLvariables in the Python script to use your own n8n host URL (e.g.,http://localhost:XXXXor your production server domain).
Execute the Streamlit application from your terminal:
streamlit run <your_script_name>.pyThe application will automatically open in your default web browser (usually at http://localhost:XXXX).
The application utilizes a split architecture for robustness and capability:
Handles all UI rendering, user interaction (buttons, select boxes), and dashboard visualization.
Serves as a data processing and AI/LLM orchestration layer. It is responsible for:
- Querying the source database (e.g., Airtable)
- Calculating aggregate metrics (KPIs, distributions)
- Calling the Gemini API to generate complex text analysis reports