-
Notifications
You must be signed in to change notification settings - Fork 2
Planning Your Deployment
This guide helps you plan and prepare for deploying TMI (Threat Modeling Improved) in your environment. TMI consists of two main components: a Go-based API server and an Angular-based web application.
TMI is a collaborative threat modeling platform with:
- Real-time collaborative diagram editing via WebSockets
- Role-based access control (reader, writer, owner)
- OAuth 2.0 authentication with PKCE (RFC 7636) and JWT
- RESTful API with OpenAPI 3.0.3 specification
- Support for multiple threat modeling frameworks (STRIDE, CIA, LINDDUN, etc.)
[Internet] → [Load Balancer/Reverse Proxy]
↓
[TMI Server Instances]
↓
[Database (PostgreSQL/Oracle/MySQL/SQL Server/SQLite)]
[Cache Cluster (Redis)]
[Monitoring Stack]
- TMI Server: Go HTTP server with WebSocket support for real-time collaboration
- TMI Web Application: Angular/TypeScript frontend
- Database: Primary data storage for threat models, diagrams, and user data (supports PostgreSQL, Oracle, MySQL, SQL Server, and SQLite via GORM)
- Redis Cache: Session storage, caching, and real-time WebSocket message coordination
- OAuth/SAML Integration: Authentication via configurable identity providers (Google, GitHub, Microsoft, or any OAuth 2.0/SAML provider)
- Load Balancer: Traffic distribution, SSL termination, health checks (production)
- Monitoring: Observability stack for metrics and alerts (recommended)
Best for: Small teams, development/staging environments
Components:
- Single server running TMI server, web app, database (e.g., PostgreSQL), and Redis
- Nginx reverse proxy for SSL termination
- Local file-based logging
- Basic monitoring with health checks
Pros: Simple setup, low cost, easy maintenance Cons: No high availability, limited scalability, single point of failure
Estimated Cost: $5-20/month (small VPS or Heroku Eco dynos)
Best for: Production environments with moderate load
Components:
- Load-balanced TMI server instances
- Dedicated database and cache servers
- Separate web server for static frontend
- Centralized logging and monitoring
- Automated backup and recovery
Pros: Better performance, some redundancy, easier scaling Cons: More complex setup, higher cost, requires load balancer
Estimated Cost: $100-300/month (cloud VMs or Heroku Standard dynos)
Best for: Deploying to AWS, OCI, GCP, or Azure with minimal effort
TMI provides 8 ready-to-use Terraform templates -- public and private variants for each of 4 cloud providers. Each template deploys a complete TMI stack (Kubernetes cluster, managed PostgreSQL, Redis, load balancer, secrets, logging) with a single terraform apply.
Public templates are internet-accessible, low-cost deployments for evaluation:
| Provider | Est. Monthly Cost | Notes |
|---|---|---|
| OCI | $0 | Always Free tier (arm64 Ampere nodes) |
| Azure | ~$75-85 | AKS Free tier + B2s node |
| GCP | ~$80-100 | GKE Autopilot + Cloud SQL |
| AWS | ~$140-150 | EKS + t3.medium node |
Private templates are for internal deployments with no public ingress -- the deployer establishes connectivity (VPN, bastion, etc.).
Pros: One-command deployment, provider-native services, automatic secret generation, WebSocket support configured Cons: Requires cloud provider account and Terraform knowledge
See Terraform-Deployment for full details.
Best for: Organizations with existing Kubernetes infrastructure
Components:
- Existing Kubernetes cluster
- TMI deployed via Helm or raw manifests
- External database and Redis
- Custom ingress/load balancer configuration
Pros: Integrates with existing infrastructure, full control Cons: More setup effort than Terraform templates, requires Kubernetes expertise
Estimated Cost: Varies (depends on existing infrastructure)
- Operating System: Linux, macOS, or Windows (with WSL)
- Database: PostgreSQL 12+, Oracle, MySQL, SQL Server, or SQLite (PostgreSQL recommended for production)
- Redis: Version 6 or higher
- Node.js: Version 22+ (for web app)
- Go: Version 1.26+ (for building server)
- Domain name with DNS configured (for production)
- SSL/TLS certificates (Let's Encrypt recommended)
- Inbound access on configured ports (default: 8080 for API server)
- Outbound HTTPS access to OAuth providers
- Firewall configured to restrict database/Redis access
You need to register OAuth applications with at least one provider. TMI supports any OAuth 2.0 provider via environment-variable-based configuration (OAUTH_PROVIDERS_<NAME>_*). Common providers include:
- Google: Google Cloud Console
- GitHub: GitHub Developer Settings
- Microsoft: Azure Portal
Each OAuth application needs:
- Client ID (Client Secret for confidential clients; public clients use PKCE)
- Authorized redirect URIs configured
- Appropriate scopes enabled
- Docker Engine 20.10+ or Docker Desktop
- Docker Compose 2.0+ (for local development)
- Kubernetes 1.24+ (for orchestration)
- Container registry access (Docker Hub, GCR, ECR, etc.)
- kubectl configured and authenticated
- Helm 3+ (optional but recommended)
- Ingress controller configured
- Persistent volume provisioner
- Certificate manager (cert-manager recommended)
Use this matrix to choose your deployment approach:
| Criteria | Single Server | Multi-Server | Kubernetes |
|---|---|---|---|
| Team Size | 1-10 users | 10-100 users | 100+ users |
| Budget | $5-20/mo | $100-300/mo | $500+/mo |
| Availability Needs | 95% OK | 99% required | 99.9% required |
| Setup Complexity | Low | Medium | High |
| Scaling | Manual | Semi-automated | Fully automated |
| Maintenance Effort | Low | Medium | Medium-High |
| Skillset Required | Basic Linux | Moderate DevOps | Kubernetes expertise |
Best for: Quick deployment, minimal DevOps overhead
Pros:
- Simple deployment from GitHub
- Managed PostgreSQL and Redis addons
- Automated scaling and health checks
- Built-in SSL/TLS
- Easy environment management
Cons:
- Higher per-unit cost
- Less infrastructure control
- Vendor lock-in
Best for: Maximum control, existing infrastructure
Pros:
- Full control over configuration
- Predictable costs
- Can use existing infrastructure
- No vendor lock-in
Cons:
- More manual setup required
- Need to manage OS updates
- Security hardening is your responsibility
Best for: Consistent environments, easy local development
Pros:
- Consistent deployment across environments
- Easy to replicate locally
- Good for dev/staging environments
- Portable to different hosts
Cons:
- Requires Docker knowledge
- Single-host limitations
- Need orchestration for production HA
Best for: Large-scale deployments, cloud-native architecture
Pros:
- Excellent scalability
- Built-in high availability
- Self-healing capabilities
- Industry standard orchestration
Cons:
- Steep learning curve
- Operational complexity
- Overkill for small deployments
- OAuth Providers: Choose which providers to enable (any OAuth 2.0 or SAML provider)
- PKCE: OAuth 2.0 authorization code flow uses PKCE (RFC 7636) for public clients
- JWT Configuration: Plan token expiration and refresh policies
- Session Management: Redis for session storage with appropriate TTLs
- HTTPS: Required for all production deployments
- Firewall Rules: Database and Redis should not be internet-accessible
- Network Segmentation: Separate application, database, and cache layers
- SSL/TLS: Use TLS 1.3 for all communications
- Rate Limiting: Implement at load balancer or reverse proxy level
- Database Encryption: Enable encryption at rest for your database
- Backup Encryption: Encrypt all database backups
- Secret Management: Use environment variables or secret management tools (Vault, etc.)
- Audit Logging: Enable application and database audit logs
Small deployment (< 100 users):
- PostgreSQL: 2GB RAM, 20GB storage
- Redis: 256MB RAM
- Expected growth: ~1GB/month
Medium deployment (100-1000 users):
- PostgreSQL: 4-8GB RAM, 100GB storage
- Redis: 1GB RAM
- Expected growth: ~5GB/month
Large deployment (1000+ users):
- PostgreSQL: 16GB+ RAM, 500GB+ storage
- Redis: 4GB+ RAM
- Expected growth: Monitor and scale proactively
TMI API Server (per instance):
- Small: 1 CPU, 1GB RAM (10-50 users)
- Medium: 2 CPU, 2GB RAM (50-200 users)
- Large: 4 CPU, 4GB RAM (200-500 users)
TMI Web Application (static hosting):
- Minimal resources needed (served via CDN or static hosting)
- nginx: 512MB RAM sufficient for any load
- Average: 100-500 KB per user session
- WebSocket traffic: Minimal for real-time updates
- API requests: 1-10 KB per request
- Diagram data: 10-100 KB per diagram
- Servers/VMs provisioned and accessible
- DNS records configured for production domains
- SSL/TLS certificates obtained and validated
- Firewall rules configured
- Backup storage configured and tested
- Database installed and configured (PostgreSQL, Oracle, MySQL, SQL Server, or SQLite)
- Redis installed and configured
- Database backups scheduled
- Connection pooling configured
- Performance tuning completed
- OAuth applications created
- Client IDs and secrets generated
- Redirect URIs configured with production URLs
- Required scopes enabled
- Test users configured (if applicable)
- Log aggregation configured
- Metrics collection setup
- Alert rules defined
- Health check configured (TMI uses the root endpoint
/for health checks) - Dashboard created
- Deployment runbook created
- Rollback procedures documented
- Emergency contact list prepared
- Architecture diagram updated
- Configuration documented
Developer Machine
├── TMI Server (localhost:8080)
├── TMI Web App (localhost:4200, Angular dev server)
├── Database (Docker container or SQLite)
└── Redis (Docker container)
Use case: Local development and testing
Setup time: 10 minutes with make start-dev
Staging Server
├── TMI Server (staging-api.example.com)
├── TMI Web App (staging.example.com)
├── Database (managed service or dedicated server)
└── Redis (managed service or dedicated server)
Use case: Pre-production testing, QA Setup time: 1-2 hours
Load Balancer (HTTPS)
├── TMI Server Instances (2-3 replicas)
├── TMI Web App (static hosting or CDN)
│
Database Layer
├── Database (primary + read replicas, PostgreSQL recommended)
└── Redis (cluster or sentinel)
│
Monitoring Stack
├── Metrics (Prometheus)
├── Logs (ELK/Loki)
└── Tracing (Jaeger/Tempo)
Use case: Production deployment with high availability Setup time: 4-8 hours initial setup
- Choose your deployment approach based on the decision matrix above
- Review Deploying-TMI-Server for detailed server deployment instructions
- Review Deploying-TMI-Web-Application for frontend deployment
- Set up Setting-Up-Authentication with your chosen OAuth providers
- Configure your Database-Setup for your environment
- Integrate Component-Integration to connect everything together
- Complete Post-Deployment verification and testing
- Documentation: Home | FAQ
- Common Issues: Common-Issues
- GitHub: TMI Repository
- Community: File an issue on GitHub for questions
- Deploying-TMI-Server -- Server deployment instructions
- Deploying-TMI-Web-Application -- Frontend deployment
- Setting-Up-Authentication -- OAuth provider configuration
- Database-Setup -- Database installation and configuration
- Security-Best-Practices -- Security guidelines
- Configuration-Reference -- Full configuration variable reference
For in-depth technical documentation, see these guides in the source repository:
- Container Security Guide - Chainguard images, Grype integration, vulnerability scanning
- Deployment Guide - Complete production deployment procedures
- PostgreSQL Operations - Database setup, migrations, and maintenance
- Using TMI for Threat Modeling
- Accessing TMI
- Authentication
- Creating Your First Threat Model
- Understanding the User Interface
- Working with Data Flow Diagrams
- Managing Threats
- Collaborative Threat Modeling
- Using Notes and Documentation
- Timmy AI Assistant
- Metadata and Extensions
- Planning Your Deployment
- Terraform Deployment (AWS, OCI, GCP, Azure)
- Deploying TMI Server
- OCI Container Deployment
- Certificate Automation
- Deploying TMI Web Application
- Setting Up Authentication
- Database Setup
- Component Integration
- Post-Deployment
- Branding and Customization
- Monitoring and Health
- Cloud Logging
- Configuration Management
- Config Migration Guide
- Database Operations
- Database Security Strategies
- Security Operations
- Performance and Scaling
- Maintenance Tasks
- Getting Started with Development
- Architecture and Design
- API Integration
- Testing
- Contributing
- Extending TMI
- Dependency Upgrade Plans
- DFD Graphing Library Reference
- Migration Instructions