A comprehensive Streamlit-powered analytics dashboard for analyzing CTC (Crush, Tear, Curl) tea sales data
across North and South India markets. This application provides AI-powered market insights, statistical
analysis, and interactive visualizations for tea auction data.
- Interactive Data Visualization: Dynamic charts showing price trends, volume analysis, and market efficiency
- Market Comparison: Compare different tea markets (North/South India, Leaf/Dust varieties)
- Statistical Analysis: Comprehensive analysis including correlations, trends, and market positions
- Data Processing: Support for Excel (.xlsx, .xls) and CSV file formats with intelligent column mapping
- Market Narrative: AI-generated market analysis and insights
- Price Analysis: Detailed price trend analysis with forecasting
- Market Intelligence: Competitive analysis and strategic recommendations
- Automated Reporting: AI-powered insights generation using OpenAI GPT models
- Multi-tab Interface: Organized analysis across Position, Trends, Comparison, and Levels tabs
- Responsive Design: Mobile-optimized interface with touch-friendly controls
- Real-time Processing: Dynamic data filtering and analysis
- Export Capabilities: PDF report generation for detailed analysis
- Welcome Brewing Sequence: Animated introduction for first-time users with tea preparation stages
- Data Upload Animations: Tea steeping progress indicators during file processing
- AI Analysis Animations: Tea master tasting animations for market intelligence generation
- Visualization Brewing: Tea preparation animations while charts are being generated
- Correlation Blending: Tea blending animations for relationship analysis
- Progress Tracking: Multi-stage tea ceremony progress indicators with elapsed time
- Frontend: Streamlit 1.29.0
- Data Processing: Pandas 2.1.3, NumPy 1.26.2
- Visualization: Plotly 5.18.0, Plotly Express
- AI Integration: OpenAI 1.3.5
- File Processing: openpyxl, xlrd
- Report Generation: ReportLab
- Python: 3.11+
-
Clone the repository:
git clone https://github.com/your-username/ctc-tea-sales-analytics.git cd ctc-tea-sales-analytics -
Install dependencies using pip:
pip install .Or install from pyproject.toml directly:
pip install -e . -
Set up environment variables (optional for AI features):
export OPENAI_API_KEY="your-openai-api-key"
Using pip with dependencies list:
pip install streamlit==1.29.0 pandas==2.1.3 plotly==5.18.0 openai==1.3.5 numpy==1.26.2 openpyxl xlrd reportlab plotly-expressFor development:
pip install -e ".[dev]"Local Development:
streamlit run main.py --server.port=5000 --server.address=0.0.0.0On Replit: Click the "Run" button or use the configured workflow.
The application expects Excel or CSV files with the following columns (accepts variations):
| Required Column | Accepted Variations |
|---|---|
| Centre | Centre, Center, Market Center, Location |
| Sale No | Sale No, Sale Number, Sale_No, SaleNo |
| Sales Price(Kg) | Price/Kg, Price (Kg), Sales Price, Price |
| Sold Qty (Ton) | Sold Quantity, Sold_Qty, Quantity Sold |
| Unsold Qty (Ton) | Unsold Quantity, Unsold_Qty, Quantity Unsold |
Markets should follow the format: {Region} CTC {Type}
- Regions: North India, South India
- Types: Leaf, Dust
Example: "North India CTC Leaf", "South India CTC Dust"
- Drag-and-drop file upload
- Intelligent column mapping with fuzzy matching
- Data validation and cleaning
- Support for multiple file formats
- Multi-select filters for regions and tea types
- Dynamic market filtering
- Real-time data updates
- Current market position metrics
- Price, volume, and efficiency analysis
- Historical context and percentile rankings
- Price trend visualization with trend lines
- Market efficiency tracking
- Rolling correlations and moving averages
- Cross-market comparisons
- Correlation heatmaps
- Competitive benchmarking
- Price distribution analysis
- Volume analysis with multiple aggregation methods
- Statistical summaries and insights
- Market Narrative: Comprehensive market analysis
- Price Analysis: Detailed price insights and forecasting
- Market Intelligence: Strategic recommendations
βββ main.py # Main Streamlit application
βββ utils.py # Data processing and analysis utilities
βββ styles.py # Custom CSS styling
βββ loading_animations.py # Tea-themed loading animation system
βββ assets/ # Sample data and resources
β βββ default_data.csv # Sample tea market dataset
βββ pyproject.toml # Project dependencies
βββ .replit # Replit configuration
βββ README.md # This file
The dashboard features a comprehensive tea-themed loading animation system that enhances user experience
during data processing and analysis operations.
- Tea Messages: 50+ themed messages across 5 categories (upload, processing,
ai_analysis, visualization, report) - Tea Icons: 10 animated tea-related emojis (teapot, cup, leaves, steam, etc.)
- Progress Animations: Spinning teapot, tea leaf progress bars, steaming cup sequences
- Multi-step Progress: Tracks progress across multiple processing stages
- Elapsed Time Display: Shows processing duration for transparency
- Automatic Cleanup: Removes animation placeholders when complete
- Category-based Messages: Different message sets for different operations
- Chart Brewing: 4-stage visualization preparation with progress tracking
- Correlation Blending: Tea blending metaphor for relationship analysis
- Market Intelligence: Sophisticated tea tasting animation for AI analysis
- Traditional Ceremony: Classical tea preparation with reverent styling
- Modern Station: Contemporary brewing with digital aesthetics
- Artisan Crafting: Hand-crafted approach with premium styling
- App Initialization: Welcome brewing sequence on first visit
- Data Upload: Tea steeping animations during file processing
- Sample Data Loading: Quick brewing animation for instant data access
- AI Analysis: Tea master tasting sequence for all AI-powered insights
- Chart Generation: Visualization brewing for market position charts
- Correlation Analysis: Tea blending animation for relationship matrices
- Statistical Processing: Multi-stage progress tracking for complex calculations
- HTML/CSS Animations: Custom styled progress bars with gradient effects
- Dynamic Content: Real-time message updates with contextual tea terminology
- Responsive Design: Animations adapt to mobile and desktop viewports
- Performance Optimized: Lightweight animations that don't impact data processing
- State Management: Proper cleanup prevents UI conflicts and memory leaks
process_excel_data(): Handles the entire data loading and cleaning pipeline. It reads uploaded Excel or CSV files, intelligently maps column names to a standard format using fuzzy matching, and converts data to the appropriate types.standardize_market_category(): Standardizes market category names to a consistent format ({region} CTC {type}) to ensure uniformity in data processing and analysis.calculate_weighted_price(): Calculates the weighted average price of tea, taking into account the quantity sold. This provides a more accurate representation of the market price than a simple average.
analyze_levels(): Analyzes the current market position and absolute values, providing insights into price and volume levels compared to historical data.analyze_trends(): Analyzes time-series patterns and changes in the market, identifying trends in price, volume, and efficiency.analyze_comparatives(): Performs cross-market comparisons and benchmarking, allowing users to compare the performance of different tea markets.calculate_correlations(): Calculates the correlation matrix between different market metrics, revealing relationships between price, volume, and efficiency.
generate_ai_narrative(): Uses OpenAI's GPT model to generate a high-level narrative analysis of the market, providing a concise summary of the current situation.generate_price_analysis(): Generates a detailed analysis of price trends, including insights into seasonality, volatility, and potential future movements.generate_market_insights(): Provides strategic market intelligence and competitive analysis, offering recommendations based on the data.
This project follows the Google Python Style Guide. All code should be formatted with a linter (like pylint or flake8) to ensure consistency. Docstrings should follow the Google format, clearly explaining the purpose of each function, its arguments, and what it returns.
OPENAI_API_KEY: Required for AI-powered features.
The app includes custom styling and mobile optimization. Configuration can be found in styles.py.
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This application is optimized for Replit deployment:
- Click the "Deploy" button in Replit
- The app will be available on your Replit domain
- Supports both development and production modes
For other platforms, ensure:
- Python 3.11+ environment
- All dependencies installed
- Environment variables configured
- Port 5000 accessible
- File Upload Errors: Ensure your file has the required columns with accepted
naming variations - AI Features Not Working: Check that
OPENAI_API_KEYis properly set - Performance Issues: For large datasets, the app includes optimized batch processing
Run with debug logging:
streamlit run main.py --logger.level=debugThis project is licensed under the MIT License - see the LICENSE file for details.
For issues and questions:
- Check the troubleshooting section
- Review the console logs for error details
- Ensure all dependencies are properly installed
- Built with Streamlit for the web interface
- Plotly for interactive visualizations
- OpenAI for AI-powered insights
- Pandas and NumPy for data processing
Note: This application is designed for tea market analysis and can be adapted for other
commodity markets with similar data structures.


