Architecture
Slotomancer - Cross-platform roguelike with hexagonal architecture
A wizard-themed roguelike slot-battler built from the ground up with a platform-agnostic game engine, shared UI components, and lightweight platform adapters. Solo technical leadership from architecture to cloud infrastructure, achieving approximately 100% code sharing across desktop and mobile.
- Desktop (Tauri) + Mobile (Expo)
- 100% code sharing
- Hexagonal architecture
- Privacy-first telemetry
- 350+ cards
The challenge
As a solo founder, I needed to ship on desktop and mobile simultaneously while retaining the flexibility to iterate on game balance, add content quickly, and collect player insights without compromising privacy.
- Solo development constraints: Limited time required either choosing a single platform or finding a solution to support both without duplicating effort.
- Content at scale: Roguelikes require hundreds of cards with diverse mechanics, but writing custom code for each would create an unsustainable bottleneck.
- Player trust: Modern gamers expect privacy-first analytics rather than invasive data collection, particularly from indie developers.
Architecture approach
Multi-shell monorepo pattern
Hexagonal architecture with platform-agnostic game engine and thin platform adapters:
apps/mobile, apps/desktop (shells: routing/bundling only)
↓
packages/game-state (shared zustand store)
↓
packages/screens (screen compositions)
↓
packages/ui (UI primitives)
↓
packages/game-core (game engine: pure TS, zero platform deps)Key architectural decisions
- Platform-agnostic core: Game engine has zero React, React Native, or platform dependencies - pure TypeScript business logic.
- Dependency inversion: Core engine has no knowledge of platforms that consume it; dependencies point inward only.
- Shared everything: Screens, UI components, state management, and game logic shared across all platforms.
- Deterministic gameplay: Seeded RNG enables testing, debugging, and future replay systems.
Key outcomes
Shipped two platforms as one person
100% code sharing meant feature parity by default, eliminating duplicate work and platform-specific bugs.
Eliminated content bottlenecks
The standard effects system handles 95% of cards declaratively, while Content Forge enables non-engineers to create game-ready assets with AI assistance.
Built player trust
Opt-in telemetry with hashed IDs, automatic retention limits, and instant opt-out options built confidence within the beta community.
Game engine design
Turn structure
An 11-phase canonical turn eliminates race conditions and timing ambiguity:
- Start of turn → passive effects trigger
- Spin the slot machine → draw symbols
- Mana symbols → add to pools
- Spells → execute effect chains
- Player creatures → attack opponent
- Enemy creatures → attack player
- End of combat → cleanup triggers
Determinism for testing
Seeded RNG (never Math.random()) means every test can reproduce exact gameplay sequences, critical for debugging card interactions and validating balance changes.
Core systems
Meta-progression loops
- Card unlocks: Winning battles and completing achievements expand your permanent collection across all runs.
- Ascension perks: Earn points from victories to purchase permanent modifiers, with up to five active at once, and build synergies between runs.
- In-run economy: Spend 10 mana on tactical options such as artifacts, HP refills, deck removal, or rarity upgrades.
Effects system at scale
Standard effects (dealDamage, apply, mana, modify, spawn, cleanse, draw) handle 95% of the 350+ cards declaratively:
- Every effect supports conditions (mana/HP/turn thresholds) and repeat counts
- Targeting helpers (adjacent, surrounding, all creatures) prevent manual bugs
- A custom effects registry is maintained only for truly unique mechanics.
Privacy-first telemetry
Designed an analytics system that earns player trust: opt-in only, hashed IDs, automatic data deletion, and instant opt-out. Built with Terraform for infrastructure as code.
What gets tracked
- Sessions: platform, OS, duration (no device fingerprinting)
- Run outcomes: victory/defeat with final deck composition and artifacts
- Player choices: which cards/artifacts offered vs. selected
- Errors: crash reports (always sent if telemetry enabled)
Client-side safeguards
- SHA-256 hashed profile IDs, never plain text
- Event batching with 45-second flush + exponential backoff retry
- 24-hour local discard policy for undelivered events
Content Forge: AI-assisted creation
Built a Python desktop application that enables non-engineers to create wizards, cards, and artifacts with AI-generated pixel art, then export game-ready JSON and sprites in one click.
Workflow
- Describe the card/wizard/artifact in natural language
- AI generates pixel art + suggested effects
- Refine mechanics using the effects palette
- Export validates against Zod schemas
- Drop JSON + sprites into game content directory, auto-loaded on next launch
Development practices
Testing philosophy
"Game-true" unit tests model real gameplay sequences with seeded RNG:
- Card contracts: verify rules text matches actual behavior
- Effects battery: comprehensive coverage for standard + custom effects
- Phase-aware timing: assert effects fire in correct turn phases
- Reproducible runs: seeded tests catch non-deterministic bugs
Monorepo structure
- pnpm workspaces for dependency management
- Shared TypeScript config across packages
- Vitest for unified testing
By the numbers
Lessons learned
What worked
- Ports-and-adapters from day one: This allowed testing game logic without launching a mobile emulator or desktop window, saving hundreds of hours.
- Documentation as a first-class artifact: Writing rules and architecture documentation enabled effective AI pair programming and asynchronous collaboration.
- Opt-in telemetry with no compromises: SHA-256 hashing, 90-day auto-delete, and instant opt-out established beta community trust from day one.
- Tooling investment pays dividends: Content Forge transformed content creation from a week-long engineering task into a minutes-long design task.
What I'd do differently
- Event-driven from the start: Starting there would have avoided the challenges of refactoring from a phase-based system mid-development.
- GUI-first for Content Forge: Building the visual UI from day one, rather than starting as a JSON editor, would have accelerated non-engineer adoption.
- Replay system earlier: Deterministic RNG enables replays at no extra cost; building it sooner would have helped debugging and content creation.
- Smaller, composable effects: Some custom effects are monolithic, and more aggressive composition would improve extensibility.
Interested in cross-platform architecture?
I welcome discussions on ports-and-adapters patterns, monorepo strategies, or building game engines with pure business logic. If you are working on multi-platform projects or facing similar challenges, I would be glad to exchange insights.