4.9 KiB
4.9 KiB
Sales Analysis Template - Overview
Start here for a high-level understanding of the template.
For detailed setup, see QUICK_START.md. For complete documentation, see README.md.
🎯 Purpose
This template provides a production-ready, reusable framework for analyzing sales invoice detail data from any company. It's designed to be:
- Flexible: Works with different column names, date formats, and data structures
- Automated: Interactive setup wizard configures everything
- AI-Optimized: Fully optimized for Cursor AI - just ask and the AI generates complete analyses
- Best-in-Class: Based on proven patterns from 24+ production analyses
📦 What's Included
Core Framework
config.py- Centralized configuration (customize for your company)data_loader.py- Intelligent data loading with fallback logicanalysis_utils.py- Common utilities (formatters, LTM, helpers)validate_revenue.py- Revenue validation utility
Templates & Tools
analysis_template.py- Template for creating new analysesrun_all_analyses.py- Batch runner for all scriptssetup_wizard.py- Interactive setup wizard
Documentation
README.md- Comprehensive documentationQUICK_START.md- Quick reference guide.cursor/rules/- Cursor IDE rules for automation
Configuration
requirements.txt- Python dependencies.gitignore- Git ignore patterns
🚀 Quick Start
-
Run setup wizard:
python setup_wizard.py -
Test data loading:
python -c "from data_loader import load_sales_data; from config import get_data_path; df = load_sales_data(get_data_path()); print(f'✓ Loaded {len(df):,} rows')" -
Create your first analysis:
cp analysis_template.py my_analysis.py # Edit my_analysis.py python my_analysis.py
🎨 Key Features
1. Flexible Data Loading
- Handles different column names via configuration
- Fallback logic for date parsing (100% coverage)
- Automatic validation
2. LTM Support
- Automatic Last Twelve Months calculation
- Apples-to-apples comparison with full years
- Configurable periods
3. Standardized Formatting
- Automatic millions formatter for revenue
- Consistent chart styling
- Professional output
4. Exclusion Filters
- Easy configuration for excluding segments
- Useful for test accounts, business units, etc.
5. AI Automation
- Comprehensive Cursor rules
- Automated agent assistance
- Best practices enforcement
📊 Analysis Types Supported
This template supports all standard sales analyses:
- Revenue: Annual trends, monthly analysis, by segment
- Customer: Segmentation, concentration, churn, CLV
- Product: Performance, lifecycle, BCG matrix
- Financial: Price elasticity, margins
- Advanced: Seasonality, forecasting, predictions
🔧 Customization Points
All customization happens in config.py:
- Company Info: Name, analysis date
- Data File: Location, filename
- Column Mappings: Revenue, date, customer, product, etc.
- Date Range: Years, LTM configuration
- Filters: Exclusion rules
- Chart Settings: Sizes, styles, DPI
📚 Documentation Structure
README.md- Complete guide (start here)QUICK_START.md- Quick start (includes Cursor tips)EXAMPLES.md- Example scripts guideTEMPLATE_SUMMARY.md- Comprehensive template overview.cursor/rules/- Detailed patterns for AI agents (auto-loaded by Cursor)config.py- Heavily commented configuration
🎓 Learning Path
- Read:
QUICK_START.md(5 minutes) - Run:
setup_wizard.py(2 minutes) - Test: Data loading (1 minute)
- Create: First analysis using
analysis_template.py(15 minutes) - Explore:
.cursor/rules/for patterns (as needed)
💡 Best Practices
- Always use utilities - Don't reinvent the wheel
- Use config values - Never hardcode column names
- Validate data - After loading and after analysis
- Follow patterns - See
.cursor/rules/analysis_patterns.md - Test incrementally - Test data loading before full analysis
🔍 What Makes This "Best-in-Class"
- Proven Patterns: Based on 24+ production analyses
- Flexibility: Works with any data structure
- Automation: Setup wizard + AI-friendly rules
- Documentation: Comprehensive guides and examples
- Error Handling: Validation and troubleshooting built-in
- Consistency: Standardized formatting and patterns
📈 Next Steps
- Run
setup_wizard.pyto configure for your company - Review
config.pyto understand all options - Create your first analysis using
analysis_template.py - Explore
.cursor/rules/for detailed patterns - Build your analysis suite
Template Version: 1.0
Last Updated: January 2026
Status: Production Ready