# Clone the repository
git clone https://github.com/NateDevIO/revenue-intel-saas.git
cd revenue-intel-saas
# Backend setup
cd backend
pip install -r requirements.txt
python -m data.generator # Generate synthetic data
uvicorn api.main:app --reload &
# Frontend setup (in new terminal)
cd frontend
npm install
npm run dev
# Open http://localhost:3000 in your browserNote: For AI-powered insights, add your
ANTHROPIC_API_KEYtobackend/.env
Real-time ARR, MRR, and customer health metrics with AI-powered insights
Track revenue trends, MRR movement waterfall, and growth metrics
Predictive churn scoring with health distribution and at-risk customer identification
Identify at-risk revenue with churn distribution and prioritized interventions
Monte Carlo scenario planning with visual impact analysis
Stage-by-stage conversion tracking with velocity metrics and loss analysis
View More Screenshots
AI-driven recommendations with expected ARR impact and confidence intervals
On-demand Claude-powered executive briefing with business health narrative and priorities
AI-generated root-cause analysis of churn risk with intervention recommendations
Bottleneck identification and rep coaching recommendations powered by Claude
Scenario recommendations and optimal parameter guidance from Claude
Revenue trend narrative with 3-month forecast and benchmark comparison
SaaS companies lose 20-30% of revenue to churn annually, but most don't know:
- Which customers are at risk of churning
- Why they're leaving
- When to intervene for maximum impact
- What actions will generate the highest ROI
Traditional analytics show what happened but not what to do about it.
This platform uses machine learning to predict churn 30-60 days in advance with 85% accuracy, giving customer success teams time to intervene. It combines:
- Predictive Analytics: XGBoost model identifies at-risk customers before they churn
- Root Cause Analysis: SHAP values explain exactly why each customer is at risk
- Impact Quantification: Every recommendation includes expected ARR impact
- Scenario Planning: Monte Carlo simulation models intervention outcomes
|
ARR at risk identified |
Churn prediction accuracy |
Dashboard load time |
Data points analyzed |
- ✅ Identifies at-risk customers 30-60 days before churn
- ✅ Prioritizes interventions by expected value × confidence
- ✅ Reduces analysis time from weeks to seconds
- ✅ Provides actionable Monday morning priorities for CS teams
|
|
The SaaS Revenue Lifecycle Analyzer provides actionable insights to answer the critical question: "What should the business do Monday morning?" Every metric and recommendation includes quantified dollar impact and confidence intervals.
- Identify Revenue Leakage across acquisition, conversion, retention, and expansion
- Prioritize Actions by expected ARR impact × confidence
- Simulate Scenarios with Monte Carlo what-if analysis
- Track Health with predictive churn modeling and customer health scoring
┌─────────────────────────────────────────────────────────────────┐
│ Frontend Layer │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Next.js 14 │ │ TypeScript │ │ TailwindCSS │ │
│ │ App Router │ │ + Recharts │ │ + Radix UI │ │
│ └───────┬──────┘ └──────────────┘ └──────────────┘ │
│ │ │
│ │ HTTP/JSON │
└──────────┼───────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Backend API Layer │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ FastAPI (Python 3.11+) │ │
│ │ ┌────────────┐ ┌────────────┐ ┌────────────┐ │ │
│ │ │ Routes │ │ Cache │ │ Middleware │ │ │
│ │ │ │ │ (LRU+TTL) │ │ Monitoring │ │ │
│ │ └────────────┘ └────────────┘ └────────────┘ │ │
│ └────────────────────────┬─────────────────────────────────┘ │
│ │ │
└───────────────────────────┼─────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────────────────┐
│ Analytics Engine Layer │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
│ │ Churn │ │ Health │ │ Funnel │ │
│ │ Analysis │ │ Score │ │ Analysis │ │
│ └──────┬───────┘ └──────┬───────┘ └──────┬───────┘ │
│ │ │ │ │
│ │ ▼ │ │
│ │ ┌──────────────────┐ │ │
│ └─────▶│ XGBoost Model │◀─────────┘ │
│ │ 85% Accuracy │ │
│ │ SHAP Analysis │ │
│ └──────────────────┘ │
└───────────────────────────┬─────────────────────────────────────┘
│ SQL
▼
┌─────────────────────────────────────────────────────────────────┐
│ Data Layer │
│ ┌──────────────────────────────────────────────────────────┐ │
│ │ DuckDB (Columnar OLAP) │ │
│ │ ┌────────────┐ ┌────────────┐ ┌────────────┐ │ │
│ │ │ Customers │ │ MRR │ │Usage Events│ │ │
│ │ │ (1.6K) │ │ (8K) │ │ (50K) │ │ │
│ │ └────────────┘ └────────────┘ └────────────┘ │ │
│ │ │ │
│ │ 📊 23 Optimized Indexes ⚡ Sub-second Queries │ │
│ └──────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
- User Request → Next.js frontend renders dashboard
- API Calls → FastAPI routes handle requests with caching
- Analytics → Analysis modules query DuckDB and run ML models
- Predictions → XGBoost generates churn probabilities with SHAP explanations
- Response → Structured JSON with metrics, visualizations, and recommendations
Comprehensive technical documentation covering:
- Data architecture and schema design (10 entities, 60K+ records)
- Synthetic data generation methodology
- Statistical analysis techniques (correlation, time series, cohorts)
- Machine learning models (XGBoost churn prediction - 85% accuracy)
- Business metrics formulas (ARR, NRR, LTV:CAC, Rule of 40)
- Data quality and validation procedures
- Performance optimization strategies
Access:
- 📊 Interactive HTML version: Click "Methodology" link in application footer
- 📝 Markdown version: DATA_ANALYSIS_METHODOLOGY.md
- Current ARR, MRR, and NRR at a glance
- Customer health distribution
- MRR waterfall visualization
- Top priority actions with impact estimates
- Stage-by-stage conversion rates
- Velocity metrics and deal cycle time
- Loss reason analysis
- Cohort performance tracking
- Rep performance leaderboard
- Multi-factor health scoring
- At-risk customer identification
- Churn probability prediction
- Usage trend analysis
- NPS correlation
- ARR at risk calculation
- Churn driver analysis
- Segment-level risk breakdown
- Intervention recommendations
- Expected ARR impact per action
- Confidence intervals
- Effort estimation
- Implementation roadmap
- Monte Carlo scenario planning
- Churn reduction impact
- Conversion improvement modeling
- Expansion opportunity sizing
Every major page now includes an on-demand AI analysis panel powered by Claude. Click "Generate Insights" to get a tailored AI briefing, or ask custom questions about the data on that page.
| Page | AI Focus | Example Questions |
|---|---|---|
| Executive Dashboard | Monday morning briefing, anomalies, priorities | "What should I focus on this week?" |
| Revenue at Risk | Root-cause analysis, intervention plans, 90-day forecast | "Which customers should we intervene with first?" |
| Funnel Analysis | Bottleneck identification, loss reason fixes, rep coaching | "Where is the biggest bottleneck in our funnel?" |
| What-If Simulator | Scenario recommendations, result explanation | "Which scenario would have the highest ROI?" |
| Revenue Intelligence | Trend narrative, MRR drivers, 3-month forecast | "Is our revenue accelerating or decelerating?" |
- Ask Claude AI about any individual customer in natural language
- Get instant analysis of churn risk drivers
- Receive actionable intervention recommendations
- Powered by Claude Sonnet for enterprise-grade insights
View Full Stack Details
- Python 3.11+ - Core language
- FastAPI - High-performance async API framework
- DuckDB - Analytical database (columnar OLAP)
- Pandas/NumPy - Data manipulation and analysis
- XGBoost - Gradient boosting for churn prediction
- SHAP - Model interpretability and explainability
- Pydantic - Data validation with type hints
- Next.js 14 - React framework with App Router
- TypeScript - Type-safe development
- TailwindCSS - Utility-first CSS framework
- Radix UI - Accessible component primitives
- Recharts - Composable charting library
- Framer Motion - Animation library
- Lucide Icons - Beautiful icon set
- Pytest - Python testing framework
- Jest - JavaScript testing
- React Testing Library - Component testing
- Puppeteer - Browser automation for screenshots
- ESLint/Prettier - Code quality and formatting
- 10x faster analytical queries on columnar data
- Zero configuration - embedded database, no server setup
- Perfect for OLAP - optimized for aggregations, not transactions
- Easy deployment - single file database, portable
- Excellent on tabular data - superior to deep learning for structured data
- Interpretable - SHAP values explain predictions (critical for business users)
- Fast inference - <50ms per prediction vs seconds for NNs
- Less data needed - works well with 1K+ samples, NNs need 10K+
- Async support - handles concurrent requests efficiently
- Auto documentation - OpenAPI/Swagger UI out of the box
- Type hints - Pydantic validation catches errors at dev time
- Performance - 2-3x faster than Flask for I/O-bound operations
- Server components - faster initial page loads
- Built-in optimization - image optimization, code splitting, caching
- SEO friendly - server-side rendering for better search ranking
- Developer experience - file-based routing, TypeScript support
- Catch bugs early - type errors found at compile time, not runtime
- Better IDE support - autocomplete, refactoring, navigation
- Self-documenting - types serve as inline documentation
- Confidence in refactoring - rename variables safely across codebase
- Python 3.11+
- Node.js 18+
- npm or yarn
cd backend
# Install Python dependencies
pip install -r requirements.txt
# Set up environment variables (optional - for AI features)
cp .env.example .env
# Edit .env and add your ANTHROPIC_API_KEY from https://console.anthropic.com/
# Generate synthetic data (creates ~60K records)
python -m data.generator
# Start the API server
uvicorn api.main:app --reloadAPI available at http://localhost:8000
- Documentation:
http://localhost:8000/docs - Health Check:
http://localhost:8000/api/health
cd frontend
# Install dependencies
npm install
# Start development server
npm run devApplication available at http://localhost:3000
cd backend
python -m pytest tests/ -v25 API endpoint tests covering all major features
cd frontend
npm test # Run once
npm run test:watch # Watch mode
npm run test:coverage # Coverage reportComponent and utility tests with React Testing Library
software-saas/
├── backend/
│ ├── api/ # FastAPI application
│ │ ├── main.py # API entry point
│ │ ├── routes/ # Endpoint definitions
│ │ ├── cache.py # Response caching (LRU + TTL)
│ │ └── middleware.py # Performance monitoring
│ ├── data/ # Data layer
│ │ ├── database.py # DuckDB with 23 indexes
│ │ ├── generator.py # Synthetic data generator
│ │ └── assumptions.py # Industry benchmarks
│ ├── analysis/ # Analytics modules
│ │ ├── churn.py # XGBoost prediction
│ │ ├── health_score.py # Multi-factor scoring
│ │ ├── funnel.py # Conversion analytics
│ │ └── revenue.py # NRR, LTV:CAC, etc.
│ └── tests/ # 25 test cases
│
├── frontend/
│ ├── app/ # Next.js pages
│ ├── components/ # React components
│ ├── lib/ # Utilities
│ │ ├── api.ts # API client
│ │ └── performance.ts # Web Vitals tracking
│ └── __tests__/ # Component tests
│
└── Documentation/
├── DATA_ANALYSIS_METHODOLOGY.md # ⭐ Main methodology report
├── PERFORMANCE_MONITORING.md # Performance guide
├── BUNDLE_OPTIMIZATION.md # Bundle analysis
└── PHASE_4_SUMMARY.md # Optimization work
Model Performance:
- 85% accuracy
- 0.88 AUC-ROC
- SHAP interpretability
Top Churn Drivers:
- Declining usage trend (28%)
- Low NPS score (22%)
- Payment issues (15%)
- Short tenure (12%)
- Login inactivity (10%)
Multi-factor scoring (0-100):
- 🟢 Green (≥70): Healthy, low churn risk
- 🟡 Yellow (40-69): At risk, needs attention
- 🔴 Red (<40): Critical, high churn probability
Components:
- Usage (35%)
- Engagement (25%)
- Sentiment (20%)
- Financial (20%)
Calculated Metrics:
- ARR, MRR with trends
- Net Revenue Retention (NRR)
- LTV:CAC ratio
- Rule of 40
- MRR waterfall
Benchmarks:
- NRR >120%: Best-in-class
- LTV:CAC 3-5x: Healthy
- CAC Payback <12 months: Efficient
| Endpoint | Avg Response Time | p95 | p99 | Cache Hit Rate |
|---|---|---|---|---|
/api/summary |
145ms | 320ms | 480ms | 87% |
/api/customers |
180ms | 410ms | 650ms | 72% |
/api/churn/at-risk |
95ms | 180ms | 290ms | 91% |
/api/revenue/waterfall |
120ms | 250ms | 380ms | 84% |
| Churn Prediction | <50ms per customer | - | - | N/A |
Optimization Techniques:
- ⚡ Sub-second API responses with caching (60s-5min TTL)
- 📊 23 database indexes for query optimization
- 🔄 LRU cache with time-based invalidation
- 📈 Request performance monitoring (warns >2s, errors >5s)
- 🔀 Async concurrent query execution (4x faster dashboards)
| Metric | Target | Actual | Status |
|---|---|---|---|
| LCP (Largest Contentful Paint) | <2.5s | 1.8s | ✅ Good |
| FID (First Input Delay) | <100ms | 45ms | ✅ Good |
| CLS (Cumulative Layout Shift) | <0.1 | 0.05 | ✅ Good |
| FCP (First Contentful Paint) | <1.8s | 1.2s | ✅ Good |
| TTFB (Time to First Byte) | <600ms | 380ms | ✅ Good |
Optimization Achievements:
- 📦 Bundle size: -3MB (removed 345 packages)
- ⚙️ SWC minification enabled (30% faster builds)
- 📊 Web Vitals tracking for continuous monitoring
- 🎯 Code splitting with Next.js App Router
- 🖼️ Image optimization (AVIF/WebP formats)
Interactive Docs: http://localhost:8000/docs
GET /api/health # Health check
GET /api/summary # Executive summary
GET /api/actions # Prioritized actions
GET /api/revenue/summary # Revenue metrics
GET /api/revenue/waterfall # MRR waterfall
GET /api/funnel/summary # Funnel overview
GET /api/customers # Customer list (paginated)
GET /api/churn/at-risk # At-risk customers
POST /api/simulator/run-scenario # What-if simulation
POST /api/ai/customer-insights # AI customer analysis
POST /api/ai/executive-insights # AI executive briefing
POST /api/ai/risk-insights # AI risk analysis
POST /api/ai/funnel-insights # AI funnel analysis
POST /api/ai/simulator-insights # AI scenario guidance
POST /api/ai/revenue-insights # AI revenue forecast
This project is deployed and live:
| Service | Platform | URL |
|---|---|---|
| Frontend | Vercel | revenue-intel.vercel.app |
| Backend API | Railway | revenue-intel-saas-production.up.railway.app |
Backend (Railway):
- Sign up at https://railway.app
- Create new project from GitHub repo
- Railway auto-detects the
railway.tomlconfiguration - Generate a public domain in Settings → Networking
Frontend (Vercel):
- Sign up at https://vercel.com
- Import GitHub repository
- Set root directory to
frontend - Add environment variable:
NEXT_PUBLIC_API_URL=https://your-backend.railway.app - Deploy!
📖 See DEPLOYMENT.md for complete step-by-step instructions including:
- Railway backend setup with persistent storage
- Vercel frontend configuration
- Environment variable setup
- Custom domain configuration
- CORS configuration
- Monitoring and logging
- Troubleshooting guide
┌─────────────┐ ┌──────────────┐
│ Vercel │────────▶│ Railway │
│ (Frontend) │ HTTPS │ (Backend) │
│ Next.js 14 │ │ FastAPI │
└─────────────┘ │ + DuckDB │
└──────────────┘
Estimated Cost: $0-7/month (covered by free tiers for moderate usage)
cd backend
python -m data.generatorCreates ~60,000 records across 10 entities with realistic patterns.
cd frontend
npm run analyzeOpens interactive bundle visualization.
- Frontend: Browser console shows Web Vitals (LCP, FID, CLS, etc.)
- Backend: Terminal shows request timing and slow query warnings
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
See CONTRIBUTING.md for detailed guidelines.
This project is licensed under the MIT License - see the LICENSE file for details.
📚 Documentation: See /Documentation folder
📄 Methodology: DATA_ANALYSIS_METHODOLOGY.md
🐛 Issues: GitHub Issues
💬 Questions: Open a Discussion
This project leverages several excellent open-source libraries and tools:
- FastAPI - Modern Python web framework
- Next.js - React framework for production
- DuckDB - High-performance analytical database
- XGBoost - Gradient boosting framework
- Recharts - Composable charting library
- Anthropic Claude - AI-powered insights
- shadcn/ui - Beautifully designed components
NateDev.io - Full-Stack Developer & AI Engineer
Building AI-powered solutions for modern SaaS businesses
Built for SaaS businesses to optimize their revenue lifecycle
⭐ Star this repo if you find it helpful!