8.7 KiB
Sales Analysis Template - Summary
This document provides a comprehensive overview of the template structure and capabilities.
For quick start, see QUICK_START.md. For detailed documentation, see README.md.
📋 What This Template Provides
This template was created based on the comprehensive Dukane Corporation sales analysis project, which included 24+ production-ready analysis scripts. All best practices, patterns, and lessons learned have been distilled into this reusable template.
📁 Complete File Structure
sales_analysis_template/
├── README.md # Comprehensive documentation
├── QUICK_START.md # Quick reference guide
├── TEMPLATE_OVERVIEW.md # Template overview and features
├── TEMPLATE_SUMMARY.md # This file
├── EXAMPLES.md # Example scripts guide
├── SETUP_CHECKLIST.md # Setup verification checklist
├── requirements.txt # Python dependencies
├── .gitignore # Git ignore patterns
│
├── Core Framework Files:
│ ├── config.py # ⭐ Centralized configuration
│ ├── config_validator.py # Configuration validation utility
│ ├── data_loader.py # ⭐ Intelligent data loading
│ ├── data_quality.py # Data quality reporting
│ ├── data_processing.py # Data transformation utilities
│ ├── analysis_utils.py # ⭐ Common utilities
│ ├── statistical_utils.py # Statistical analysis utilities
│ └── validate_revenue.py # Revenue validation
│
├── Utility Files:
│ ├── export_utils.py # Export to CSV/Excel
│ ├── report_generator.py # PDF report generation
│ ├── logger_config.py # Logging configuration
│ └── generate_sample_data.py # Generate sample data for testing
│
├── Templates & Tools:
│ ├── analysis_template.py # Template for new analyses
│ ├── run_all_analyses.py # Batch runner
│ └── setup_wizard.py # Interactive setup wizard
│
├── examples/ # Example analysis scripts
│ ├── annual_revenue_trend.py # Simple annual revenue analysis
│ ├── customer_segmentation.py # RFM customer segmentation
│ ├── cohort_analysis.py # Customer cohort analysis
│ └── product_performance.py # Product performance analysis
│
├── tests/ # Unit tests
│ ├── test_data_loader.py # Data loader tests
│ ├── test_analysis_utils.py # Analysis utils tests
│ └── test_config_validator.py # Config validator tests
│
└── .cursor/
└── rules/ # Cursor IDE rules (auto-loaded)
├── ai_assistant_guide.md # Complete AI assistant guide
├── advanced_analysis_patterns.md # Advanced techniques
├── analysis_patterns.md # Analysis patterns
├── chart_formatting.md # Chart formatting rules
├── code_quality.md # Code quality standards
├── common_errors.md # Error troubleshooting
├── data_loading.md # Data loading patterns
├── error_handling.md # Error handling patterns
└── ltm_methodology.md # LTM methodology
🎯 Key Features Implemented
1. Flexible Configuration System
config.py: Centralized configuration with extensive comments- All column names, date ranges, and settings configurable
- No hardcoded values - everything comes from config
2. Intelligent Data Loading
data_loader.py: Fallback logic for date parsing- Handles missing dates gracefully
- 100% date coverage via fallback columns
- Automatic validation and error reporting
3. Comprehensive Utilities
analysis_utils.py: All common functions in one place- Chart formatters (millions, thousands)
- LTM calculation helpers
- Mixed type handling for years
- Price calculation utilities
- Exclusion filter helpers
4. Interactive Setup
setup_wizard.py: Asks clarifying questions- Automatically configures
config.py - Validates inputs
- Provides next steps
5. AI-Friendly Rules
.cursor/rules/: Comprehensive Cursor IDE rules- Auto-loaded by Cursor
- Enforces best practices
- Provides patterns and troubleshooting
6. Production-Ready Templates
analysis_template.py: Complete template with examplesrun_all_analyses.py: Batch runner with error handling- Follows all best practices
🔑 Design Principles
Flexibility
- Works with any column names (configured in config.py)
- Handles different date formats
- Supports various data structures
- Optional features (LTM, exclusions) can be disabled
Automation
- Setup wizard asks all necessary questions
- Cursor rules guide AI agents automatically
- Batch runner handles multiple analyses
- Validation catches errors early
Best Practices
- Always use utilities (never reinvent the wheel)
- Consistent formatting across all analyses
- Proper error handling and validation
- Comprehensive documentation
Reusability
- Generic enough for any company
- Specific enough to be immediately useful
- Well-documented for future agents
- Easy to extend with new analyses
📊 Analysis Types Supported
The template supports all standard sales analyses:
Revenue Analyses
- Annual revenue trends
- Monthly revenue analysis
- Revenue by segment/product/geography
Customer Analyses
- Customer segmentation (RFM)
- Customer concentration
- Churn analysis
- Cohort analysis
- Customer lifetime value (CLV)
Product Analyses
- Product performance
- Product lifecycle
- BCG matrix
- Market basket analysis
Financial Analyses
- Price elasticity
- Contribution margin
- Price vs volume analysis
Advanced Analyses
- Seasonality analysis
- Time series forecasting
- Customer churn prediction
🚀 Usage Workflow
-
Setup (5 minutes)
- Run
setup_wizard.py - Answer questions about your data
- Configuration automatically updated
- Run
-
Test (2 minutes)
- Test data loading
- Verify configuration works
-
Create (15 minutes)
- Copy
analysis_template.py - Customize for your analysis
- Run and verify
- Copy
-
Scale (ongoing)
- Create multiple analyses
- Add to batch runner
- Generate complete analysis suite
💡 What Makes This "Best-in-Class"
- Proven Patterns: Based on 24+ production analyses
- Comprehensive: Covers all common analysis types
- Flexible: Works with any data structure
- Automated: Setup wizard + AI-friendly rules
- Documented: Extensive documentation at every level
- Production-Ready: Error handling, validation, best practices
📚 Documentation Hierarchy
QUICK_START.md- Start here (5-minute overview, includes Cursor tips)README.md- Complete guide (comprehensive)EXAMPLES.md- Example scripts guideTEMPLATE_OVERVIEW.md- High-level overviewSETUP_CHECKLIST.md- Verification checklist.cursor/rules/- Detailed patterns for AI agents (auto-loaded by Cursor)config.py- Inline comments for all options
🎓 Learning Resources
- Quick Start:
QUICK_START.md- Get running in 5 minutes - Full Guide:
README.md- Complete documentation - Patterns:
.cursor/rules/analysis_patterns.md- Code patterns - Troubleshooting:
.cursor/rules/common_errors.md- Fix issues - Examples:
analysis_template.py- Working example
✅ Quality Assurance
All components include:
- ✅ Error handling
- ✅ Input validation
- ✅ Comprehensive comments
- ✅ Type hints where helpful
- ✅ Documentation strings
- ✅ Best practices enforcement
🔄 Future Enhancements
Potential additions (not included in v1.0):
- Example analysis scripts (can be added from Dukane project)
- Unit tests
- CI/CD configuration
- Docker containerization
- Additional visualization libraries
📝 Notes for Users
- First Time: Start with
QUICK_START.mdandsetup_wizard.py - Configuration: All customization in
config.py - Creating Analyses: Use
analysis_template.pyas starting point - AI Assistance: Cursor rules are auto-loaded, just ask for help
- Troubleshooting: Check
.cursor/rules/common_errors.mdfirst
🎉 Success Criteria
The template is ready when:
- ✅ Setup wizard runs successfully
- ✅ Data loads without errors
- ✅ First analysis generates charts
- ✅ All validations pass
- ✅ Documentation is clear
Template Version: 1.0
Created: January 2026
Based On: Dukane Corporation Sales Analysis Project
Status: Production Ready ✅