Skip to main content

Architecture

Titan is built on Microsoft Orleans, a virtual actor framework that provides a simplified programming model for distributed systems.

System Overview

Project Structure

ProjectTypeDescription
Titan.AppHostAspire OrchestratorManages containers and service configuration
Titan.APIOrleans ClientPublic gateway with SignalR hubs and HTTP endpoints
Titan.GrainsClass LibraryCore business logic as Orleans grain implementations
Titan.AbstractionsClass LibraryShared interfaces, models, and contracts
Titan.IdentityHostOrleans SiloHosts identity-related grains (Account, Character, Session)
Titan.InventoryHostOrleans SiloHosts inventory grains (Bag, Stash, ItemGenerator)
Titan.TradingHostOrleans SiloHosts trading grains with Orleans Streams
Titan.ClientClass LibraryStrongly-typed .NET SDK
titan-dashboardReact/ViteAdmin dashboard for monitoring and management

Orleans Grain Model

Orleans uses virtual actors called Grains. Key characteristics:

  1. Single-threaded: Each grain processes one request at a time
  2. Location-transparent: Grains can be on any silo, Orleans routes calls
  3. Persistent: State is automatically saved to storage
  4. Lazy activation: Grains are created on first access, deactivated when idle

Grain Keys

Grains are identified by keys. Titan uses:

Communication Flow

SignalR Hub Request Flow

Authentication Flow

Persistence

Titan uses MemoryPack for high-performance binary serialization:

  • ~40% smaller payloads compared to JSON
  • Fast serialization via source generators
  • Used for both wire protocol and storage

Storage Configuration

Grains persist state to PostgreSQL via Orleans' ADO.NET provider:

[PersistentState("account", "OrleansStorage")]
IPersistentState<AccountGrainState> _state;

Rate Limiting

Redis-backed rate limiting protects the API:

Policies are configured per-endpoint pattern in appsettings.json and can be modified at runtime via the admin API.

Aspire Orchestration

The Titan.AppHost uses .NET Aspire to orchestrate all services:

Key benefits:

  • Single startup project for the entire solution
  • Automatic container provisioning (Redis, PostgreSQL)
  • Service discovery between projects
  • Integrated dashboard for logs and traces