Dual-Mode Architecture
Software architecture pattern that provides separate operational modes for controlled demonstrations and live validation, particularly valuable for hackathons and early-stage projects where reliability needs to be balanced with authenticity during presentations.
Core Concept
The pattern implements two distinct runtime configurations within the same codebase:
Demo-Safe Mode
Controlled environment optimized for reliable demonstrations:
- Fixture data: Predetermined scenarios with known outcomes
- Mock integrations: Simulated external services to eliminate dependencies
- Disabled side effects: Prevention of real-world consequences during demos
- Predictable timing: Known response times for smooth presentation flow
- Error suppression: Graceful handling of issues that don't affect core demonstration
Live-Proof Mode
Authentic environment for real-world validation:
- Real integrations: Actual external APIs and services
- Dynamic data: Live information from production sources
- Full functionality: Complete feature set without artificial limitations
- Natural timing: Actual system performance characteristics
- Complete error handling: Production-ready exception management
Implementation Patterns
Configuration-Driven Mode Selection
Use environment variables or configuration files to control mode:
import os
class SystemConfig:
def __init__(self):
self.demo_safe = os.getenv('DEMO_SAFE_MODE', 'false').lower() == 'true'
self.live_proof = os.getenv('LIVE_PROOF_MODE', 'false').lower() == 'true'
def get_data_source(self):
if self.demo_safe:
return FixtureDataSource()
elif self.live_proof:
return LiveDataSource()
else:
return DefaultDataSource()
Service Layer Abstraction
Abstract external dependencies to enable mode switching:
class EmailService:
def __init__(self, config):
self.config = config
def send_alert(self, recipient, message):
if self.config.demo_safe:
# Log intent without actual sending
logger.info(f"DEMO: Would send alert to {recipient}")
return {"status": "demo_simulated", "id": "demo_001"}
else:
# Actual email sending logic
return self._send_real_email(recipient, message)
Data Source Switching
Implement interchangeable data providers:
class DataSourceFactory:
@staticmethod
def create_mail_source(config):
if config.demo_safe:
return FixtureMailSource("demo_emails.json")
elif config.live_proof:
return LiveMailSource("mailapp")
else:
return ConfigurableMailSource()
Design Principles
Transparent Mode Operation
The application should function identically from the user's perspective regardless of mode:
- Consistent UI: Same interface elements and interactions
- Identical workflows: Same steps and processes in both modes
- Seamless switching: Ability to change modes without application restart
- Mode indication: Clear but unobtrusive indication of current operational mode
Graceful Degradation
Each mode should handle the other mode's data gracefully:
- Fixture compatibility: Live mode should work with demo data if needed
- Live data fallback: Demo mode should handle unexpected real data
- Partial functionality: Components should work even if some services are in different modes
- Error isolation: Issues in one mode shouldn't affect the other
Security Separation
Ensure demo mode cannot accidentally affect production systems:
- Write protection: Demo mode prevents any persistent changes
- API isolation: Separate credentials and endpoints where possible
- Data sandboxing: Demo operations confined to test environments
- Audit trails: Clear logging of which mode performed which operations
Use Cases
Hackathon Presentations
Optimize for demo success while maintaining technical credibility:
Primary Demonstration
- Controlled scenarios: Scripts that always work as expected
- Timing predictability: Known performance for smooth presentation flow
- Error elimination: Remove variables that could cause demo failure
- Visual polish: Optimized outputs for audience consumption
Technical Validation
- Live integration proof: Short segments showing real-world connectivity
- Authentic data: Genuine API responses and system interactions
- Performance reality: Actual speed and reliability characteristics
- Q&A flexibility: Ability to explore beyond scripted scenarios
Early-Stage Product Development
Balance feature development with stakeholder demonstrations:
Stakeholder Presentations
- Feature completeness illusion: Show