Project 9: Save System Architecture

A versioned save system with migration strategy, integrity checks, and rollback slots.

Quick Reference

Attribute Value
Difficulty Level 3
Time Estimate 1 week
Main Programming Language C# (.NET 8) + MonoGame
Alternative Programming Languages F#, C++ (raylib), Godot C#
Coolness Level Level 3
Business Potential Level 2
Prerequisites Deterministic loop basics, debugging discipline, content pipeline fundamentals
Key Topics Schema versioning, Atomic writes, Recovery and migration

1. Learning Objectives

  1. Translate one concrete production question into a testable implementation plan.
  2. Implement and validate the feature in a MonoGame runtime context.
  3. Instrument success and failure paths with actionable diagnostics.
  4. Produce a repeatable demo artifact for portfolio or interview use.

2. All Theory Needed (Per-Concept Breakdown)

Schema versioning

Fundamentals Schema versioning is central to this project because it defines the non-negotiable behavioral contract for the feature. You should be able to describe valid inputs, legal state transitions, and expected outputs under normal and failure conditions.

Deep Dive into the concept Treat Schema versioning as a boundary-setting mechanism. Start by defining the smallest deterministic scenario that proves the feature works. Stress that scenario under altered timing, altered content inputs, and altered user actions. If behavior changes unexpectedly, document hidden coupling and sequence assumptions. Keep transitions explicit and observable via logs or debug panels. Connect each transition to an event record so regression analysis is possible after refactors.

Atomic writes

Fundamentals Atomic writes ensures the project scales from local prototype behavior to repeatable system behavior.

Deep Dive into the concept Use Atomic writes to reason about data flow ownership and mutation timing. Document where writes occur, when validation runs, and how rollback behaves if a write fails.

Recovery and migration

Fundamentals Recovery and migration connects this project to shipping reality by forcing you to think about operational constraints early.

Deep Dive into the concept Define one production-like failure mode related to Recovery and migration and build a mitigation checklist. The solution is complete when you can demonstrate both a golden path and a controlled failure path.

3. Project Specification

3.1 What You Will Build

A versioned save system with migration pipeline, integrity checks, backup slot recovery, and player-facing status UX.

Visible game deliverable:

  • Save-slot UI with version badges and integrity status
  • Migration result panel showing source/target schema versions
  • Recovery notice banner for backup failover events

3.2 Functional Requirements

  1. Write save payloads with explicit version and checksum metadata.
  2. Run migrations from older fixture versions automatically on load.
  3. Fallback to backup slot when primary save validation fails.
  4. Display save operation status and recovery decisions in UI.

3.3 Non-Functional Requirements

  • Performance: Must remain inside project-appropriate frame budget.
  • Reliability: Must recover from at least one injected failure mode.
  • Usability: Outcome must be observable by a reviewer in under two minutes.

3.4 Example Usage / Output

[SAVE] slot=A version=1->2 migrate=PASS
[SAVE] checksum primary=FAIL backup=PASS
[SAVE] state_hash_match=true

3.5 Data Formats / Schemas / Protocols

  • Event record: {timestamp, module, action, result}
  • Feature state snapshot: {version, state, counters, flags}

3.6 Edge Cases

  • Interrupted write mid-save.
  • Unknown future version payload.
  • Partially valid payload with missing optional fields.

3.7 Real World Outcome

This is a game-facing outcome you can see and play immediately.

What you will see in the game window:

  • Save-slot UI with version badges and integrity status
  • Migration result panel showing source/target schema versions
  • Recovery notice banner for backup failover events

Project 9 Save System Architecture Window Mockup

How you interact:

  • F5 quick-save
  • F9 quick-load
  • Ctrl+M run migration fixture suite

3.7.1 How to Run (Copy/Paste)

$ dotnet restore
$ dotnet build
$ dotnet run --project src/Game -- --scene save-lab

3.7.2 Golden Path Demo (Deterministic)

  1. Start the scene and confirm all HUD panels load.
  2. Perform the three core interactions listed above.
  3. Verify the success signal appears without warnings.

3.7.3 If CLI: exact transcript

$ dotnet run --project src/Game -- --scene save-lab
[SAVE] slot=A version=1->2 migrate=PASS
[SAVE] checksum primary=FAIL backup=PASS
[SAVE] state_hash_match=true

3.7.7 If GUI / Desktop

+------------------------------------------------------+
| save-lab                                   [F1 HUD] |
|------------------------------------------------------|
| PLAYFIELD: gameplay objects and interactions         |
| HUD: key metrics + status badges                    |
| STATUS: success/failure cues and prompts            |
+------------------------------------------------------+

4. Solution Architecture

4.1 High-Level Design

Gameplay State -> Serializer -> Integrity Validator -> Slot Writer -> Load/Migrate/Recover

Gameplay State -> Serializer -> Integrity Validator -> Slot Writer -> Load/Migrate/Recover

4.2 Key Components

Component Responsibility Key Decisions
SaveSerializer Converts runtime state to versioned payload Stable schema with explicit version field
MigrationEngine Transforms older payloads to latest schema Fixture-driven migration tests
SaveRecoveryUI Shows validation and fallback outcomes Never hide recovery decisions from player

4.4 Algorithm Overview

  1. Validate preconditions.
  2. Apply deterministic transition.
  3. Emit feedback and telemetry.
  4. Persist if required.

5. Implementation Guide

5.3 The Core Question You’re Answering

“How do you evolve saves safely after shipping updates?”

5.4 Concepts You Must Understand First

  1. Schema versioning
  2. Atomic writes
  3. Recovery and migration

5.5 Questions to Guide Your Design

  1. What migration policy handles skipped versions safely?
  2. How will you verify save integrity before overwrite?
  3. When should backup slot supersede primary automatically?

5.6 Thinking Exercise

Trace one full success path and one failure path on paper before implementation.

5.7 The Interview Questions They’ll Ask

  1. Why did you pick this architecture boundary?
  2. Which failure mode did you prioritize first and why?
  3. How does your instrumentation accelerate debugging?
  4. How would you scale this feature to a larger game?

5.8 Hints in Layers

  • Hint 1: Stabilize one invariant before feature expansion.
  • Hint 2: Add diagnostics before optimization.
  • Hint 3: Keep platform calls at system boundaries.
  • Hint 4: Re-run deterministic scenario after each refactor.

5.9 Books That Will Help

Topic Book Chapter
Core concept “Clean Architecture by Robert C Martin” Relevant concept chapter
Reliability “Release It!” Failure handling chapters
Architecture “Clean Architecture” Boundary and dependency chapters

6. Testing Strategy

  1. Golden path completes and emits success signal.
  2. Injected failure path recovers without crash.
  3. Re-run scenario after restart and confirm consistency.

7. Common Pitfalls & Debugging

  • Hidden initialization order coupling
  • Time-coupled behavior tied to render rate
  • Missing fallback behavior on platform call failure

8. Extensions & Challenges

  • Beginner: add one extra diagnostics panel metric.
  • Intermediate: add replay capture for event flow.
  • Advanced: add automated stress test harness.

9. Real-World Connections

This project mirrors shipping feature-module work in real indie and mid-size game teams.

10. Resources

  • Steamworks official docs
  • MonoGame docs
  • Gemini image generation docs (for asset-related projects)

11. Self-Assessment Checklist

  • I can explain the feature invariant and prove it in a demo.
  • I can trigger and handle one deterministic failure scenario.
  • I can describe tradeoffs and future scaling choices.

12. Submission / Completion Criteria

Minimum Viable Completion:

  • Feature works in deterministic golden path.
  • One controlled failure path is handled gracefully.
  • Core diagnostics are visible and documented.

Full Completion:

  • All minimum criteria plus edge-case coverage and regression checks.

Excellence:

  • Includes polished instrumentation and clear productionization notes.