Squadbase

Streamlit BI Dashboard: EC & Google Analytics

Streamlit Streamlit

Production-ready Streamlit application featuring Google Analytics 4 insights, e-commerce analytics, and an AI Data Agent for natural language queries.

Core Components

Analytics Dashboards:

  • GA4 Analytics - Traffic analysis, user behavior, conversion tracking
  • E-commerce Intelligence - Sales performance, customer segmentation, inventory optimization
  • AI Data Agent - Natural language to SQL query conversion with Google Gemini

Technical Stack:

  • Streamlit + BigQuery + Google Gemini AI
  • Modular component architecture
  • Comprehensive data caching and performance optimization

Customization Guide

1. Data Source Integration

# components/your_domain/data_queries.py
@st.cache_data(show_spinner="Loading metrics...")
def fetch_metrics() -> pd.DataFrame:
    query = """
    SELECT date, revenue, customers, orders
    FROM your_database.sales_table
    WHERE date >= CURRENT_DATE() - INTERVAL 30 DAY
    """
    return your_client.query(query).to_dataframe()

Supported Sources: BigQuery (default), PostgreSQL, MySQL, CSV files, REST APIs

2. Industry-Specific Components

SaaS: User activation, retention metrics, feature usage, subscription revenue, churn prediction

E-commerce: Product performance, customer lifetime value, inventory optimization, marketing attribution

Content/Media: Engagement metrics, audience demographics, revenue per visitor, social media impact

3. AI Data Agent Customization

# components/your_domain/data_agent/tools.py
@tool
def analyze_customer_segments(time_period: str) -> str:
    """Analyze customer segments for specified period."""
    query = f"""
    SELECT customer_segment, COUNT(*) as customers,
           AVG(order_value) as avg_order_value,
           SUM(total_revenue) as segment_revenue
    FROM your_customer_analysis_view
    WHERE period = '{time_period}'
    GROUP BY customer_segment
    """
    return execute_analysis(query)

Custom AI Tools: Financial forecasting, inventory recommendations, customer risk scoring, campaign optimization

4. Interface Customization

  • Styling: Update lib/tailwind_colors.py for brand colors
  • Branding: Add company logo and custom layouts
  • Authentication: Integrate existing user access systems

5. Advanced Features

Real-Time Updates:

if st.button("🔄 Refresh"):
    st.cache_data.clear()
    st.experimental_rerun()

Data Export:

def export_data():
    return get_analysis_data().to_csv(index=False)

st.download_button("📥 Export", export_data(), "analysis.csv")

Visualizations: Geographic heat maps, time series forecasting, network graphs, custom KPI cards

Use Cases

Corporate Dashboard: Data warehouse integration (Snowflake, Redshift, BigQuery), executive KPIs, automated reports, secure team deployment

Client Reporting: White-label analytics, custom branding, role-based access, client-specific metrics, PDF generation

Product Analytics: User engagement, feature adoption, A/B testing, funnel analysis, real-time monitoring

Marketing Intelligence: Multi-channel campaigns, CAC/LTV analysis, attribution modeling, social media tracking

Setup

git clone <repository-url>
cd streamlit-business-intelligence
uv sync

Configuration Steps:

  1. Update data queries in components/*/data_queries.py
  2. Configure database connection in lib/bigquery_client.py
  3. Set API keys in .env file
  4. Create custom components in components/your_domain/
  5. Deploy with Squadbase for team access

Architecture Benefits

Modular Design: Independent components, easy feature modification Performance: Built-in caching for complex queries and large datasets AI Integration: Extensible agent for business-specific context Production-Ready: Authentication, error handling, deployment configurations included

Streamlit BI Dashboard: EC & Google Analytics | Squadbase Showcase