Documentation
Enterprise Deployment/Private Deployment

Private Deployment

This guide covers the process of deploying ThinkCode in a private, self-hosted environment for enterprise customers who require complete control over their infrastructure, data, and security.

Private Deployment Overview

ThinkCode's private deployment option allows enterprises to:

  • Host ThinkCode within their own infrastructure
  • Maintain complete data sovereignty
  • Implement custom security controls
  • Integrate with internal systems
  • Customize the deployment architecture
  • Deploy air-gapped installations where required
  • Utilize on-premises AI models

Deployment Models

ThinkCode supports several private deployment models:

On-Premises Deployment

Full deployment within your organization's data centers:

  • Complete control over hardware and infrastructure
  • Integration with existing on-premises systems
  • Support for air-gapped environments
  • Compliance with strict data residency requirements

Private Cloud Deployment

Deployment in your organization's private cloud:

  • Leverage cloud infrastructure while maintaining control
  • Support for AWS, Azure, GCP, and other cloud providers
  • Integration with cloud-native services
  • Hybrid deployment options

Virtual Private Cloud (VPC) Deployment

Managed deployment in a dedicated VPC:

  • ThinkCode-managed infrastructure in your cloud account
  • Reduced operational overhead
  • Maintained isolation and security
  • Simplified upgrades and maintenance

Architecture Overview

Standard Architecture

The standard private deployment architecture includes:

┌─────────────────────────────────────────────────────────────┐
│                   Enterprise Network                         │
│                                                             │
│  ┌─────────────┐    ┌─────────────┐    ┌─────────────┐     │
│  │  Load       │    │  ThinkCode  │    │  Database   │     │
│  │  Balancer   │───▶│  Application│───▶│  Cluster    │     │
│  │             │    │  Cluster    │    │             │     │
│  └─────────────┘    └─────────────┘    └─────────────┘     │
│         │                  │                  │            │
│         ▼                  ▼                  ▼            │
│  ┌─────────────┐    ┌─────────────┐    ┌─────────────┐     │
│  │  Identity   │    │  AI Model   │    │  Storage    │     │
│  │  Provider   │    │  Service    │    │  Service    │     │
│  │             │    │             │    │             │     │
│  └─────────────┘    └─────────────┘    └─────────────┘     │
│                                                             │
└─────────────────────────────────────────────────────────────┘

High-Availability Architecture

For mission-critical deployments:

┌─────────────────────────────────────────────────────────────────────────────┐
│                            Enterprise Network                                │
│                                                                             │
│  ┌─────────────┐    ┌─────────────┐    ┌─────────────┐    ┌─────────────┐  │
│  │  Global     │    │  Regional   │    │  Regional   │    │  Regional   │  │
│  │  Load       │───▶│  Load       │───▶│  Load       │───▶│  Load       │  │
│  │  Balancer   │    │  Balancer 1 │    │  Balancer 2 │    │  Balancer 3 │  │
│  └─────────────┘    └─────────────┘    └─────────────┘    └─────────────┘  │
│                            │                 │                  │           │
│                            ▼                 ▼                  ▼           │
│  ┌─────────────┐    ┌─────────────┐    ┌─────────────┐    ┌─────────────┐  │
│  │  Monitoring │    │  ThinkCode  │    │  ThinkCode  │    │  ThinkCode  │  │
│  │  & Alerting │    │  Cluster 1  │    │  Cluster 2  │    │  Cluster 3  │  │
│  │             │    │             │    │             │    │             │  │
│  └─────────────┘    └─────────────┘    └─────────────┘    └─────────────┘  │
│        │                   │                 │                  │           │
│        │                   ▼                 ▼                  ▼           │
│        │            ┌─────────────┐    ┌─────────────┐    ┌─────────────┐  │
│        │            │  Database   │    │  Database   │    │  Database   │  │
│        │            │  Replica 1  │    │  Replica 2  │    │  Replica 3  │  │
│        │            │             │    │             │    │             │  │
│        │            └─────────────┘    └─────────────┘    └─────────────┘  │
│        │                   │                 │                  │           │
│        │                   └─────────┬───────┘                  │           │
│        │                             ▼                          │           │
│        │                    ┌─────────────┐                     │           │
│        └───────────────────▶│  Database   │◀────────────────────┘           │
│                             │  Primary    │                                 │
│                             │             │                                 │
│                             └─────────────┘                                 │
│                                                                             │
└─────────────────────────────────────────────────────────────────────────────┘

Air-Gapped Deployment

For environments with no internet connectivity:

┌─────────────────────────────────────────────────────────────┐
│                 Air-Gapped Environment                       │
│                                                             │
│  ┌─────────────┐    ┌─────────────┐    ┌─────────────┐     │
│  │  Internal   │    │  ThinkCode  │    │  Database   │     │
│  │  Load       │───▶│  Application│───▶│  Cluster    │     │
│  │  Balancer   │    │  Cluster    │    │             │     │
│  └─────────────┘    └─────────────┘    └─────────────┘     │
│         │                  │                  │            │
│         ▼                  ▼                  ▼            │
│  ┌─────────────┐    ┌─────────────┐    ┌─────────────┐     │
│  │  Internal   │    │  Local AI   │    │  Local      │     │
│  │  Identity   │    │  Model      │    │  Storage    │     │
│  │  Provider   │    │  Service    │    │  Service    │     │
│  └─────────────┘    └─────────────┘    └─────────────┘     │
│                                                             │
│  ┌─────────────────────────────────────────────────────┐   │
│  │              Offline Update Mechanism               │   │
│  │  (Manual updates via approved media/channels)       │   │
│  └─────────────────────────────────────────────────────┘   │
│                                                             │
└─────────────────────────────────────────────────────────────┘

Prerequisites

Before deploying ThinkCode in a private environment, ensure you have:

Hardware Requirements

ComponentMinimumRecommendedHigh Performance
CPU16 cores32 cores64+ cores
RAM64 GB128 GB256+ GB
Storage500 GB SSD1 TB SSD2+ TB NVMe SSD
Network1 Gbps10 Gbps25+ Gbps
GPU (optional)NVIDIA T4NVIDIA A10NVIDIA A100

Software Requirements

  • Kubernetes 1.24+ or Docker Swarm
  • PostgreSQL 14+
  • Redis 6+
  • NGINX or similar load balancer
  • Identity provider (compatible with OIDC or SAML)
  • Certificate management solution
  • Monitoring and logging infrastructure

Network Requirements

  • Internal DNS resolution
  • Load balancing capability
  • TLS termination
  • Network segmentation for security
  • Firewall rules for component communication
  • (Optional) Internet access for updates and cloud AI services

Deployment Process

Planning Phase

  1. Architecture Design:

    • Select deployment model
    • Design network architecture
    • Plan for high availability
    • Design backup and recovery strategy
    • Plan for monitoring and logging
  2. Resource Allocation:

    • Allocate hardware resources
    • Set up virtualization if applicable
    • Configure storage systems
    • Set up networking components
  3. Security Planning:

    • Define security policies
    • Plan encryption strategy
    • Configure network security
    • Set up identity management
    • Plan for secrets management

Installation Phase

  1. Prepare Kubernetes Cluster:
# Example: Create a namespace for ThinkCode
kubectl create namespace thinkcode
 
# Apply resource quotas
kubectl apply -f thinkcode-resource-quotas.yaml
 
# Set up persistent volumes
kubectl apply -f thinkcode-persistent-volumes.yaml
  1. Deploy Database:
# Deploy PostgreSQL with high availability
helm repo add bitnami https://charts.bitnami.com/bitnami
helm install thinkcode-db bitnami/postgresql \
  --namespace thinkcode \
  --set global.postgresql.auth.postgresPassword=<secure-password> \
  --set global.postgresql.auth.database=thinkcode \
  --set architecture=replication \
  --set primary.persistence.size=100Gi \
  --set readReplicas.persistence.size=100Gi \
  --set readReplicas.replicaCount=2
  1. Deploy Redis:
# Deploy Redis for caching and session management
helm install thinkcode-redis bitnami/redis \
  --namespace thinkcode \
  --set auth.password=<secure-password> \
  --set architecture=replication \
  --set master.persistence.size=20Gi \
  --set replica.persistence.size=20Gi \
  --set replica.replicaCount=2
  1. Deploy ThinkCode Application:
# Add ThinkCode Helm repository
helm repo add thinkcode https://charts.thinkcode.me
 
# Install ThinkCode
helm install thinkcode thinkcode/thinkcode-enterprise \
  --namespace thinkcode \
  --set global.enterpriseLicense=<your-license-key> \
  --set global.database.host=thinkcode-db-postgresql \
  --set global.database.password=<db-password> \
  --set global.redis.host=thinkcode-redis-master \
  --set global.redis.password=<redis-password> \
  --set global.aiService.type=local \
  --set ingress.enabled=true \
  --set ingress.hostname=thinkcode.your-domain.com \
  --values your-custom-values.yaml
  1. Deploy AI Model Service (if using local models):
# Deploy AI model service
helm install thinkcode-ai thinkcode/thinkcode-ai-service \
  --namespace thinkcode \
  --set models.localPath=/path/to/models \
  --set resources.requests.memory=32Gi \
  --set resources.requests.cpu=8 \
  --set resources.limits.memory=64Gi \
  --set resources.limits.cpu=16 \
  --set gpu.enabled=true \
  --set gpu.count=1

Using Docker Compose

For smaller deployments, Docker Compose can be used:

  1. Create Docker Compose File:
# docker-compose.yml
version: '3.8'
 
services:
  db:
    image: postgres:14-alpine
    volumes:
      - postgres_data:/var/lib/postgresql/data
    environment:
      - POSTGRES_PASSWORD=<secure-password>
      - POSTGRES_USER=thinkcode
      - POSTGRES_DB=thinkcode
    restart: always
    networks:
      - thinkcode-network
 
  redis:
    image: redis:6-alpine
    command: redis-server --requirepass <secure-password>
    volumes:
      - redis_data:/data
    restart: always
    networks:
      - thinkcode-network
 
  ai-service:
    image: thinkcode/ai-service:latest
    volumes:
      - ./models:/app/models
      - ./ai-config:/app/config
    environment:
      - MODEL_PATH=/app/models
      - USE_GPU=true
    restart: always
    networks:
      - thinkcode-network
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: 1
              capabilities: [gpu]
 
  app:
    image: thinkcode/enterprise:latest
    depends_on:
      - db
      - redis
      - ai-service
    environment:
      - DATABASE_URL=postgresql://thinkcode:<secure-password>@db:5432/thinkcode
      - REDIS_URL=redis://:password@redis:6379
      - AI_SERVICE_URL=http://ai-service:8000
      - LICENSE_KEY=<your-license-key>
      - NEXTAUTH_SECRET=<secure-secret>
      - NEXTAUTH_URL=https://thinkcode.your-domain.com
    volumes:
      - app_data:/app/data
    restart: always
    networks:
      - thinkcode-network
 
  nginx:
    image: nginx:latest
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./nginx/conf.d:/etc/nginx/conf.d
      - ./nginx/ssl:/etc/nginx/ssl
    depends_on:
      - app
    restart: always
    networks:
      - thinkcode-network
 
networks:
  thinkcode-network:
 
volumes:
  postgres_data:
  redis_data:
  app_data:
  1. Start the Services:
docker-compose up -d

Configuration Phase

  1. Initial Setup:

    • Access the ThinkCode admin interface
    • Complete the initial setup wizard
    • Configure organization settings
    • Set up initial admin user
  2. Integration Configuration:

    • Configure SSO integration
    • Set up repository connections
    • Configure CI/CD integrations
    • Set up monitoring integrations
  3. AI Configuration:

    • Configure AI model settings
    • Set up knowledge base connections
    • Configure AI role definitions
    • Set up expert knowledge inheritance

AI Model Deployment Options

ThinkCode supports multiple AI model deployment options for private environments:

Local Model Deployment

Deploy AI models within your infrastructure:

  1. Hardware Requirements:

    • GPU servers (recommended for performance)
    • High-memory CPU servers (alternative)
    • Fast storage for model files
  2. Supported Models:

    • ThinkCode Enterprise Models (optimized)
    • Open-source models (with compatibility layer)
    • Custom fine-tuned models
  3. Deployment Steps:

    • Download approved model files
    • Configure model service settings
    • Deploy using Kubernetes or Docker
    • Connect ThinkCode application to model service

Example model service configuration:

# model-service-config.yaml
models:
  - name: thinkcode-enterprise-large
    path: /models/thinkcode-enterprise-large
    type: llama
    quantization: 4bit
    contextLength: 16384
    priority: high
    
  - name: thinkcode-enterprise-small
    path: /models/thinkcode-enterprise-small
    type: llama
    quantization: 4bit
    contextLength: 8192
    priority: medium
    
  - name: code-embedding-model
    path: /models/code-embedding-model
    type: embedding
    dimensions: 1536
    priority: high
 
serving:
  maxConcurrentRequests: 32
  batchSize: 4
  dynamicBatching: true
  
hardware:
  gpuEnabled: true
  gpuMemoryBuffer: 1024
  cpuThreads: 16

Private Cloud AI Service

Use ThinkCode's AI service in your private cloud:

  1. Requirements:

    • VPC peering or private connection
    • Authentication configuration
    • Data encryption in transit
  2. Configuration Steps:

    • Set up VPC peering with ThinkCode AI VPC
    • Configure authentication credentials
    • Set up encryption and security policies
    • Connect ThinkCode application to cloud AI service

Hybrid Model Approach

Combine local and cloud models for optimal performance:

  1. Configuration:

    • Deploy smaller models locally
    • Use cloud service for larger models
    • Configure routing based on request type
    • Set up fallback mechanisms
  2. Example Configuration:

# hybrid-ai-config.yaml
modelRouting:
  codeCompletion:
    primary: local:thinkcode-enterprise-small
    fallback: cloud:thinkcode-enterprise-large
    
  codeGeneration:
    primary: local:thinkcode-enterprise-large
    fallback: cloud:thinkcode-enterprise-xl
    
  embedding:
    primary: local:code-embedding-model
    fallback: none
    
  systemDesign:
    primary: cloud:thinkcode-enterprise-xl
    fallback: local:thinkcode-enterprise-large
    
routingRules:
  - condition: "request.size < 1000 && request.priority == 'high'"
    target: local
    
  - condition: "request.size >= 1000 || request.complexity == 'high'"
    target: cloud
    
  - condition: "default"
    target: local

Security Considerations

Data Protection

Implement comprehensive data protection:

  1. Encryption:

    • Data at rest encryption
    • TLS for all communications
    • Database encryption
    • Secrets management
  2. Access Control:

    • Role-based access control
    • Network segmentation
    • Least privilege principle
    • Regular access reviews
  3. Compliance:

    • Data residency requirements
    • Regulatory compliance
    • Audit logging
    • Retention policies

Network Security

Secure the network infrastructure:

  1. Network Design:

    • Segmented network architecture
    • Internal service communication only
    • Controlled external access
    • DMZ for exposed services
  2. Firewall Configuration:

    • Restrictive firewall rules
    • Application-level filtering
    • DDoS protection
    • Intrusion detection/prevention
  3. Example Network Policy (Kubernetes):

# network-policy.yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: thinkcode-network-policy
  namespace: thinkcode
spec:
  podSelector:
    matchLabels:
      app: thinkcode
  policyTypes:
  - Ingress
  - Egress
  ingress:
  - from:
    - namespaceSelector:
        matchLabels:
          name: thinkcode
    - podSelector:
        matchLabels:
          app: nginx
    ports:
    - protocol: TCP
      port: 3000
  egress:
  - to:
    - podSelector:
        matchLabels:
          app: db
    ports:
    - protocol: TCP
      port: 5432
  - to:
    - podSelector:
        matchLabels:
          app: redis
    ports:
    - protocol: TCP
      port: 6379
  - to:
    - podSelector:
        matchLabels:
          app: ai-service
    ports:
    - protocol: TCP
      port: 8000

Audit and Compliance

Implement audit and compliance measures:

  1. Audit Logging:

    • Comprehensive activity logging
    • Secure log storage
    • Log analysis and alerting
    • Tamper-evident logs
  2. Compliance Monitoring:

    • Automated compliance checks
    • Regular security scanning
    • Vulnerability management
    • Compliance reporting

Monitoring and Maintenance

Monitoring Setup

Implement comprehensive monitoring:

  1. System Monitoring:

    • Resource utilization
    • Service health
    • Performance metrics
    • Capacity planning
  2. Application Monitoring:

    • User activity
    • Error rates
    • Response times
    • Feature usage
  3. AI Service Monitoring:

    • Model performance
    • Inference times
    • Usage patterns
    • Quality metrics
  4. Example Prometheus Configuration:

# prometheus-config.yaml
global:
  scrape_interval: 15s
  evaluation_interval: 15s
 
scrape_configs:
  - job_name: 'thinkcode-app'
    kubernetes_sd_configs:
      - role: pod
        namespaces:
          names:
            - thinkcode
    relabel_configs:
      - source_labels: [__meta_kubernetes_pod_label_app]
        regex: thinkcode
        action: keep
      - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_scrape]
        regex: true
        action: keep
      - source_labels: [__meta_kubernetes_pod_annotation_prometheus_io_path]
        regex: (.+)
        target_label: __metrics_path__
        action: replace
      - source_labels: [__address__, __meta_kubernetes_pod_annotation_prometheus_io_port]
        regex: ([^:]+)(?::\d+)?;(\d+)
        replacement: $1:$2
        target_label: __address__
        action: replace
 
  - job_name: 'thinkcode-ai'
    kubernetes_sd_configs:
      - role: pod
        namespaces:
          names:
            - thinkcode
    relabel_configs:
      - source_labels: [__meta_kubernetes_pod_label_app]
        regex: thinkcode-ai
        action: keep

Backup and Recovery

Implement robust backup and recovery:

  1. Backup Strategy:

    • Database backups
    • Configuration backups
    • User data backups
    • Knowledge base backups
  2. Recovery Procedures:

    • Database restoration
    • Application recovery
    • Disaster recovery plan
    • Regular recovery testing
  3. Example Backup Script:

#!/bin/bash
# ThinkCode Enterprise Backup Script
 
# Set variables
BACKUP_DIR="/backups/thinkcode"
DATE=$(date +%Y-%m-%d-%H%M)
DB_CONTAINER="thinkcode-db"
DB_NAME="thinkcode"
DB_USER="thinkcode"
 
# Create backup directory
mkdir -p $BACKUP_DIR/$DATE
 
# Backup database
echo "Backing up database..."
kubectl exec -n thinkcode $DB_CONTAINER -- pg_dump -U $DB_USER $DB_NAME | gzip > $BACKUP_DIR/$DATE/database.sql.gz
 
# Backup configuration
echo "Backing up configuration..."
kubectl get configmaps -n thinkcode -o yaml > $BACKUP_DIR/$DATE/configmaps.yaml
kubectl get secrets -n thinkcode -o yaml > $BACKUP_DIR/$DATE/secrets.yaml
 
# Backup persistent volumes
echo "Backing up persistent volumes..."
kubectl get pvc -n thinkcode -o yaml > $BACKUP_DIR/$DATE/pvc.yaml
 
# Backup custom resources
echo "Backing up custom resources..."
kubectl get thinkcode -n thinkcode -o yaml > $BACKUP_DIR/$DATE/thinkcode-resources.yaml
 
# Create archive
echo "Creating archive..."
tar -czf $BACKUP_DIR/thinkcode-backup-$DATE.tar.gz -C $BACKUP_DIR $DATE
 
# Cleanup
rm -rf $BACKUP_DIR/$DATE
 
# Rotate backups (keep last 7 days)
find $BACKUP_DIR -name "thinkcode-backup-*.tar.gz" -type f -mtime +7 -delete
 
echo "Backup completed: $BACKUP_DIR/thinkcode-backup-$DATE.tar.gz"

Updates and Upgrades

Manage updates and upgrades:

  1. Update Strategy:

    • Scheduled maintenance windows
    • Staged rollout approach
    • Testing in staging environment
    • Rollback procedures
  2. Air-Gapped Updates:

    • Offline update packages
    • Manual update procedures
    • Verification and validation
    • Controlled deployment
  3. Example Update Procedure:

# ThinkCode Enterprise Update Procedure
 
# 1. Download update package
# For air-gapped environments, transfer the package securely
 
# 2. Backup current deployment
./backup-thinkcode.sh
 
# 3. Apply database migrations (if any)
kubectl apply -f thinkcode-db-migrations.yaml
 
# 4. Update application
helm upgrade thinkcode thinkcode/thinkcode-enterprise \
  --namespace thinkcode \
  --values your-custom-values.yaml \
  --version X.Y.Z
 
# 5. Update AI service (if needed)
helm upgrade thinkcode-ai thinkcode/thinkcode-ai-service \
  --namespace thinkcode \
  --values your-ai-values.yaml \
  --version X.Y.Z
 
# 6. Verify deployment
kubectl get pods -n thinkcode
kubectl logs -n thinkcode deployment/thinkcode-app
 
# 7. Run health checks
curl -k https://thinkcode.your-domain.com/api/health

Scaling and Performance

Horizontal Scaling

Scale your deployment horizontally:

  1. Application Scaling:

    • Add application replicas
    • Configure auto-scaling
    • Load balancer configuration
    • Session persistence
  2. Database Scaling:

    • Read replicas
    • Connection pooling
    • Sharding (for very large deployments)
    • Query optimization
  3. Example Horizontal Pod Autoscaler:

# hpa.yaml
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
  name: thinkcode-app-hpa
  namespace: thinkcode
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: thinkcode-app
  minReplicas: 3
  maxReplicas: 10
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: Utilization
        averageUtilization: 70
  - type: Resource
    resource:
      name: memory
      target:
        type: Utilization
        averageUtilization: 80

Performance Optimization

Optimize performance:

  1. Caching Strategy:

    • Redis caching
    • Content delivery network
    • Browser caching
    • Query result caching
  2. Resource Allocation:

    • Right-size containers
    • Optimize memory usage
    • CPU and GPU allocation
    • Storage performance
  3. Example Redis Cache Configuration:

# redis-cache-config.yaml
maxmemory: 8gb
maxmemory-policy: allkeys-lru
timeout: 300
tcp-keepalive: 60
databases: 16
save: ""
appendonly: no
cluster-enabled: no

Troubleshooting

Common Issues

Solutions for common deployment issues:

  1. Database Connection Issues:

    • Check network policies
    • Verify credentials
    • Check database logs
    • Test connection manually
  2. AI Service Problems:

    • Verify model files
    • Check GPU availability
    • Monitor memory usage
    • Review inference logs
  3. Performance Degradation:

    • Check resource utilization
    • Review database queries
    • Monitor network traffic
    • Analyze application logs

Diagnostic Tools

Tools for diagnosing issues:

  1. Log Analysis:

    • Centralized logging
    • Log correlation
    • Error pattern detection
    • Performance logging
  2. Monitoring Dashboards:

    • System metrics
    • Application metrics
    • User experience metrics
    • AI performance metrics
  3. Example Diagnostic Commands:

# Check pod status
kubectl get pods -n thinkcode
 
# View application logs
kubectl logs -n thinkcode deployment/thinkcode-app
 
# Check database status
kubectl exec -n thinkcode thinkcode-db-0 -- pg_isready -U thinkcode
 
# Test AI service
kubectl exec -n thinkcode -it thinkcode-app-0 -- curl http://thinkcode-ai:8000/health
 
# Check resource usage
kubectl top pods -n thinkcode

Best Practices for Private Deployment

  • Start small: Begin with a pilot deployment before full-scale implementation
  • Document everything: Maintain detailed documentation of your deployment
  • Regular testing: Conduct regular disaster recovery and failover testing
  • Security first: Implement security measures from the beginning
  • Performance monitoring: Continuously monitor and optimize performance
  • Update planning: Plan updates carefully with proper testing
  • User feedback: Collect and act on user feedback for improvements
  • Capacity planning: Regularly review and plan for capacity needs

Next Steps

After completing your private deployment:

For additional assistance, contact ThinkCode Enterprise Support or schedule a consultation with our enterprise solutions team.