Operation: Black Swan

Turn-Based Network Architecture Strategy Simulation

5. Technology Stack & Implementation

5.1 Frontend Framework

Next.js 16.0.3 (Static Export)

  • React 19.2.0 for component-based UI architecture
  • TypeScript for type-safe game logic and state management
  • Static site generation for optimal performance and SEO
  • Built-in routing, code splitting, and optimization
  • Excellent developer experience with hot reloading and error messages

Styling & UI Components

  • Tailwind CSS 4.1.9 for utility-first styling
  • shadcn/ui components built on Radix UI primitives
  • VT323 font (Google Fonts) for terminal/cyberpunk aesthetic
  • Responsive design that works on desktop and mobile

5.2 State Management

Zustand 5.0.8

  • Lightweight state management library (5KB gzipped)
  • Game state: turns, budget, connections, events, mission points
  • Automatic persistence to localStorage via Zustand middleware
  • Resume capability: "Resume last game?" on title screen
  • State persists across page refreshes
Next.js Static Export

Next.js provides file-based routing, automatic code splitting, and built-in optimization for images, fonts, and JavaScript bundles. The static export capability (output: 'export') generates pure HTML, CSS, and JavaScript that deploys directly to S3 without requiring a Node.js server. TypeScript integration delivers compile-time type checking and enhanced IDE support, catching errors before deployment. The framework's optimization pipeline reduces bundle size and improves load times without manual configuration.

5.3 Hosting Infrastructure

AWS S3 (Static Website Hosting)

  • Stores all static assets: HTML, JavaScript, CSS, images
  • Static website hosting enabled for direct access
  • Versioning enabled for backup and rollback capability

AWS CloudFront (CDN)

  • Global edge caching for sub-100ms response times worldwide
  • SSL/TLS termination with automatic certificate management
  • Custom domain support with Route 53 integration
  • Cache invalidation for instant updates after deployment

5.4 Deployment Process

Build & Deploy Workflow:

  1. Build: pnpm build creates optimized static files in out/ directory
  2. Upload: aws s3 sync out/ s3://bucket-name --delete uploads files to S3
  3. Invalidate Cache: CloudFront cache invalidation (if needed) for instant updates
  4. Done: Changes live globally within minutes
Deployment Benefits:
  • No server management or maintenance required
  • Zero-downtime deployments (S3 + CloudFront handles traffic seamlessly)
  • Automatic scaling (CloudFront scales to handle any traffic volume)
  • Simple rollback (revert to previous S3 version if needed)

5.5 Performance Characteristics

Load Time:

  • First Contentful Paint: <1 second (cached assets)
  • Time to Interactive: <2 seconds (optimized bundle size)
  • Global Latency: <100ms from CloudFront edge locations

Bundle Size:

  • Next.js optimizes and code-splits automatically
  • Initial bundle: ~200-300KB gzipped (includes React, game logic, UI components)
  • Lazy loading for non-critical components
  • Images optimized and served via CloudFront

Runtime Performance:

  • Client-side game logic executes instantly (no network latency)
  • Zustand state updates trigger efficient React re-renders
  • localStorage writes are asynchronous and non-blocking
  • 60 FPS animations and smooth UI interactions

6. Design Decisions

Client-Side Execution Model

The MVP implements single-player gameplay with client-side state management and localStorage persistence. This approach eliminates backend infrastructure requirements during initial development, allowing the team to focus resources on simulation mechanics, game balance, and user experience refinement. Static hosting provides zero-cost scaling and maintenance-free operation, with CloudFront automatically handling traffic distribution globally.

Game logic resides in modular TypeScript utilities that can execute in either browser or Node.js environments. This architecture supports incremental server integration when features like multiplayer, leaderboards, or analytics justify the infrastructure complexity. Client-side state management persists for UI responsiveness while servers add authoritative validation, creating a hybrid model that preserves instant local feedback while preventing exploitation in competitive scenarios.

Turn-Based Game Structure

The simulation operates in discrete turns that represent time periods for infrastructure deployment and operations. This structure reflects how real infrastructure projects progress through phases rather than completing instantly, with build timers ranging from 1-5 turns depending on connection type and complexity. Turn-based progression creates space for strategic planning, requiring players to anticipate future needs and budget constraints rather than reacting to immediate pressures.

The turn system enables sophisticated mechanics like recurring budget cycles (every 5 turns), multi-turn events (outages lasting 2-4 turns), and operational cost spreading (paid over 5 turns). Events can span multiple turns, creating sustained challenges that test whether players built genuinely resilient systems rather than barely-sufficient architectures. Players can consider decisions carefully without time pressure, making the simulation accessible while maintaining strategic depth through resource management and planning challenges.

Zustand State Management

Zustand provides lightweight state management at 5KB gzipped, handling game state for turns, budget, connections, events, and mission points. The library's minimal API enables direct state updates without actions, reducers, or dispatch patterns, reducing boilerplate and simplifying state mutations for game logic. Built-in persist middleware synchronizes state to localStorage automatically, enabling save/resume functionality with a single configuration option.

The store structure supports complex game state with nested objects (connections, site-to-site links, events) while maintaining simple update patterns. State changes trigger efficient React re-renders through shallow comparison, updating only components that subscribe to modified state slices. The straightforward API accelerates development velocity and simplifies debugging, with state changes visible in browser DevTools and localStorage persistence providing transparent save/load behavior.

7. Scalability & Performance

Automatic Scaling

Frontend: Next.js static files served via CloudFront CDN, providing global edge caching and automatic scaling. No manual configuration needed—CloudFront handles any traffic volume.

Hosting: S3 + CloudFront automatically scale based on traffic. No server management, no capacity planning, no scaling configuration.

Game Logic: Runs entirely client-side, scaling is automatic (each player's browser handles their own game state).

Performance Optimization

Code Splitting: Next.js automatically code-splits by route, loading only required JavaScript for each page.

Lazy Loading: Non-critical components (modals, charts) are lazy-loaded to reduce initial bundle size.

Image Optimization: Images optimized and served via CloudFront with proper caching headers.

Bundle Size: ~200-300KB gzipped for initial load (React, game logic, UI components).

Client-Side Execution Speed

Turn Processing: <100ms for full turn processing (build updates, budget, events, throughput calculation, mission points).

State Updates: Zustand triggers efficient React re-renders (only changed components update).

localStorage: Asynchronous writes, non-blocking (doesn't affect UI responsiveness).

Future Scalability Considerations

Phase 2 (Server-Side Features):

  • Authoritative Game Logic: Server-side validation for multiplayer or competitive play
  • Analytics & Telemetry: Track player behavior, game completion rates, difficulty balancing
  • Multiplayer Features: Competitive play, leaderboards, shared challenges
  • Persistence Across Devices: Save games to cloud, resume on any device
  • Anti-Cheat: Validate player actions, detect exploits

Migration Path:

  • Extract game logic to shared utilities that run client or server-side
  • Client-side state management remains for UI responsiveness
  • Server validates critical operations (turn processing, budget validation)
  • Incremental migration: add server-side features without rewriting client