DataMaster 360: Collaborative Analytics Platform

This app simulates a full-fledged collaborative platform for data analysis, featuring file uploads, interactive visualizations, session handling, chat functionality, dynamic chart rendering, and more.


#!/usr/bin/env python3
import streamlit as st
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import time

# Set App Title
st.title("DataMaster 360: Collaborative Analytics Platform")

# Sidebar: User Settings and File Upload
st.sidebar.header("Settings & File Upload")
uploaded_file = st.sidebar.file_uploader("Upload your dataset (CSV)", type=["csv"])

# User Authentication
st.sidebar.subheader("Login")
username = st.sidebar.text_input("Username")
password = st.sidebar.text_input("Password", type="password")

def authenticate(username, password):
    # Simple username/password authentication (could be extended with a database)
    if username == "user" and password == "pass":
        return True
    return False

# Sidebar: Visual Settings
chart_type = st.sidebar.radio("Select Chart Type", ["Line Chart", "Bar Chart", "Scatter Plot", "Histogram", "Pie Chart"])
filter_column = st.sidebar.text_input("Filter Column (Exact Name)")
filter_value = st.sidebar.slider("Filter Values Greater Than", 0, 100, 50)
selected_color = st.sidebar.color_picker("Pick a Chart Color", "#FF5733")

# Sidebar: Additional Collaboration Features
collaboration_mode = st.sidebar.checkbox("Enable Collaboration Mode")

# Session State Setup
if 'authenticated' not in st.session_state:
    st.session_state['authenticated'] = False

if st.session_state['authenticated'] == False:
    if st.sidebar.button("Login"):
        if authenticate(username, password):
            st.session_state['authenticated'] = True
            st.success("Login successful!")
        else:
            st.error("Invalid username or password.")
    st.stop()

# Main App Section
st.header("Data Overview & Visualization")

# If file uploaded and user authenticated
if uploaded_file:
    data = pd.read_csv(uploaded_file)
    st.write("### Raw Data Preview")
    st.dataframe(data.head(10))

    # Filter Column Validation
    if filter_column and filter_column in data.columns:
        filtered_data = data[data[filter_column] > filter_value]
        st.write(f"### Filtered Data (by `{filter_column} > {filter_value}`)")
        st.dataframe(filtered_data)

        # Show Summary Statistics
        with st.expander("Summary Statistics"):
            st.write(filtered_data.describe())

        # Chart Rendering
        st.subheader(f"Visualization: {chart_type}")
        if chart_type == "Line Chart":
            st.line_chart(filtered_data[filter_column])
        elif chart_type == "Bar Chart":
            st.bar_chart(filtered_data[filter_column])
        elif chart_type == "Scatter Plot":
            fig, ax = plt.subplots()
            ax.scatter(filtered_data.index, filtered_data[filter_column], color=selected_color)
            st.pyplot(fig)
        elif chart_type == "Histogram":
            fig, ax = plt.subplots()
            ax.hist(filtered_data[filter_column], bins=20, color=selected_color)
            st.pyplot(fig)
        elif chart_type == "Pie Chart":
            fig, ax = plt.subplots()
            ax.pie(filtered_data[filter_column].value_counts(), labels=data[filter_column].unique(), autopct='%1.1f%%', colors=[selected_color])
            st.pyplot(fig)

        # Data Download
        csv = filtered_data.to_csv(index=False)
        st.download_button("Download Filtered Data", data=csv, file_name="filtered_data.csv", mime="text/csv")

    else:
        st.warning("Please enter a valid column name for filtering.")

    # Collaborative Features: Chat System
    if collaboration_mode:
        st.subheader("Collaboration & Live Chat")
        feedback = st.text_area("Leave feedback or analysis notes")
        if st.button("Submit Feedback"):
            st.write(f"Feedback: {feedback}")
            st.balloons()

        chat_message = st.chat_input("Send a message to the team")
        if chat_message:
            st.write(f"You: {chat_message}")
        with st.expander("Chat History"):
            st.chat_message("user1").write("User 1: This data looks promising!")
            st.chat_message("user2").write("User 2: Let's explore more filters.")

# Advanced Data Processing Simulation
st.header("Advanced Data Processing")
with st.spinner("Processing large datasets..."):
    for i in range(100):
        time.sleep(0.02)
    st.success("Processing completed!")

# Metrics Display
st.subheader("Key Metrics")
if uploaded_file:
    if filter_column:
        st.metric("Max Value", filtered_data[filter_column].max())
        st.metric("Min Value", filtered_data[filter_column].min())
        st.metric("Mean Value", round(filtered_data[filter_column].mean(), 2))

# Feedback Form
st.subheader("Feedback Form")
with st.form("feedback_form"):
    user_name = st.text_input("Your Name")
    feedback_message = st.text_area("Your Feedback")
    submitted = st.form_submit_button("Submit")
    if submitted:
        st.write(f"Thank you, {user_name}, for your feedback!")
        st.write(f"Feedback Message: {feedback_message}")

# Progress Bar for Data Export
st.subheader("Data Export Progress")
progress = st.progress(0)
for i in range(100):
    time.sleep(0.05)
    progress.progress(i + 1)

# Simulated LaTeX Formula for Mathematical Analysis
st.latex(r"\int_a^b f(x)dx = F(b) - F(a)")
    

Features in DataMaster 360:

Detailed Features: