Production SaaS Systems
Overview
Experience designing and building SaaS platforms with emphasis on data correctness, reliability, and operational simplicity.
Core Platform Components
Multi-Tenancy
- Account isolation at database and API levels
- Row-level security (RLS) policies
- Cross-tenant access prevention
- Data residency compliance
Authentication & Authorization
- JWT-based authentication
- OAuth2 integration (Google, GitHub, etc.)
- Role-based access control (RBAC)
- Permission inheritance and delegation
- Audit logging of access
Billing System
- Subscription management (monthly/annual)
- Usage-based billing
- Proration and upgrades/downgrades
- Invoice generation and delivery
- Tax calculation (sales tax, VAT)
- Stripe, Paddle, or custom integrations
Usage Metering
- Real-time usage tracking
- Event aggregation and batching
- Rate limiting per tenant
- Quota management
- Overage handling
Subscription Workflows
- Upgrade/downgrade flows
- Trial period management
- Renewal reminders
- Churn prevention
- Cancellation workflows
Third-Party Integrations
- OAuth-based API access
- Webhook delivery
- Rate limiting per API key
- Usage tracking per integration
- API versioning
Admin Dashboards
- Tenant management
- User management
- Usage analytics
- Billing overview
- Support tools
Background Jobs
- Invoice generation
- Email notifications
- Usage aggregation
- Cleanup jobs
- Data exports
Notifications
- In-app notifications
- Email alerts
- Webhook events
- Notification preferences
- Batch delivery
Analytics
- Event tracking
- Funnel analysis
- Cohort analysis
- Revenue metrics
- Churn analysis
Architecture Patterns
Data Correctness
- ACID transactions for billing operations
- Idempotent webhook handlers
- Financial audit trail
- Double-entry bookkeeping for complex billing
Reliability
- Database replication
- Read replicas for analytics
- Backup and recovery procedures
- Disaster recovery plan
- Zero-downtime deployments
Observability
- Distributed tracing
- Structured logging
- Metrics dashboards
- Alert routing
- On-call rotation
Scalability
- Horizontal scaling of API servers
- Database connection pooling
- Cache layer (Redis)
- CDN for static assets
- Async processing for heavy operations
Technology Stack
| Layer | Technology |
|---|---|
| Frontend | React, TypeScript, Tailwind CSS |
| Backend | Node.js, Express or Next.js API routes |
| Database | PostgreSQL with read replicas |
| Caching | Redis for sessions and cache |
| Job Queue | Bull, RQ, or Celery |
| Payments | Stripe API |
| Hosting | AWS (EC2, RDS, S3, CloudFront) |
| CI/CD | GitHub Actions, CircleCI |
| Monitoring | Datadog, New Relic, or CloudWatch |
Key Learnings
Data Correctness First
- Use transactions religiously for financial operations
- Verify consistency regularly
- Design idempotent operations
Reliability Requires Design
- Assume failures will happen
- Build retry logic everywhere
- Comprehensive logging essential
Observability is a Feature
- Know what’s happening in production
- Alerts should be actionable
- Dashboards should tell a story
Security is Ongoing
- Regular security audits
- Dependency scanning
- Access control reviews
- Data encryption (in transit and at rest)
Operational Simplicity
- Automate repetitive tasks
- Document runbooks
- Build for debugging
- Minimize manual processes
Example Metrics
- Uptime: 99.95% (2.2 hours/month downtime)
- API Latency: 100-200ms p95
- Database: Handles 5,000 requests/sec
- Billing Accuracy: 99.99% correct invoices
- Customer Scale: 100k+ active users
- GMV: $10M+ annual processed payments