f807a9e603
Build / build (push) Failing after 27s
VanillaRecipeProvider scans every RecipeType by output, prefers crafting-table recipes, and falls back to gather. Stub stays in unit tests. Overlay still HUD; persistence still RAM.
229 lines
6.2 KiB
Markdown
229 lines
6.2 KiB
Markdown
# 🏛️ Architecture
|
||
|
||
This is a living scaffold. It will change as we iterate.
|
||
|
||
Language lives in [[🗣️ Ubiquitous Language]]. This document describes how that domain is structured in code.
|
||
|
||
Satistaskory is designed with Domain-Driven Design.
|
||
|
||
---
|
||
|
||
## 📜 Golden Rule
|
||
|
||
The Domain Layer must not know about EMI, JEI, REI, NeoForge APIs, UI frameworks, or save formats.
|
||
|
||
Infrastructure serves the domain. Never the other way around.
|
||
|
||
Goals are the domain. Recipes are implementation details.
|
||
|
||
---
|
||
|
||
## Core domain chain
|
||
|
||
```text
|
||
Goal
|
||
↓
|
||
Recipe Resolution
|
||
↓
|
||
Material Requirements
|
||
↓
|
||
Material Aggregation
|
||
↓
|
||
Inventory State (available quantities)
|
||
↓
|
||
Missing Materials / Ready To Craft
|
||
↓
|
||
Completed Goal
|
||
```
|
||
|
||
---
|
||
|
||
## Layers
|
||
|
||
Dependencies point inward. The domain does not depend on infrastructure.
|
||
|
||
```text
|
||
+--------------------------+
|
||
| UI Layer |
|
||
+--------------------------+
|
||
|
|
||
v
|
||
+--------------------------+
|
||
| Application Layer |
|
||
+--------------------------+
|
||
|
|
||
v
|
||
+--------------------------+
|
||
| Domain Layer | <-----+
|
||
+--------------------------+ |
|
||
|
|
||
+--------------------------+
|
||
| Infrastructure Layer |
|
||
+--------------------------+
|
||
```
|
||
|
||
The UI and application layers call the domain.
|
||
|
||
Infrastructure implements interfaces defined by the domain (and used by the application). It is not below the domain in a dependency sense; it sits outside and plugs in.
|
||
|
||
---
|
||
|
||
## Domain
|
||
|
||
This layer contains the actual business logic.
|
||
|
||
Primary objects:
|
||
|
||
- `Goal` — [[🎯 Goal]]
|
||
- `MaterialRequirement` — [[🧱 Material Requirement]]
|
||
- `ProgressState` — [[📉 Missing Material]], [[🛠️ Ready To Craft]]
|
||
|
||
`Project` and [[✅ Completed Goal]] exist in the language. They are not packaged in the first slice. See [[📦 Packages]].
|
||
|
||
`InventoryState` is a value the domain consumes (available quantities). How that snapshot is collected is infrastructure. See [[🎒 Inventory State]].
|
||
|
||
Domain services:
|
||
|
||
- [[🧾 Recipe Resolution]] — goal → material requirements
|
||
- [[➕ Material Aggregation]] — active goals → aggregated list
|
||
- [[📈 Progress Calculation]] — missing, ready-to-craft, completion
|
||
|
||
Recipe resolution uses a `RecipeProvider` port. It does not call a recipe mod.
|
||
|
||
---
|
||
|
||
## Application
|
||
|
||
Coordinates use cases.
|
||
|
||
First use case: [[▶️ Create Goal]]. In code this slice is one `Planner` facade (create / increment / decrement / clear / snapshot), not one class per use case.
|
||
|
||
Mark Goal Complete is named. It is not in the first slice.
|
||
|
||
The application layer calls infrastructure through ports (`RecipeProvider`, inventory snapshot). It does not contain domain rules. It loads what the use case needs, asks the domain to decide, and presents the result. Persistence is in-memory for this slice.
|
||
|
||
Packages: [[📦 Packages]].
|
||
|
||
---
|
||
|
||
## Infrastructure
|
||
|
||
Infrastructure exists to satisfy domain requirements.
|
||
|
||
Infrastructure may be replaced.
|
||
|
||
Examples:
|
||
|
||
- NeoForge
|
||
- `RecipeManager` (vanilla + mod-registered recipes)
|
||
- Save data storage
|
||
- Inventory scanning
|
||
|
||
Shipped this slice: `VanillaRecipeProvider` (`RecipeManager`, all types, one level), player-inventory snapshot, HUD overlay, tooltip+key capture. `StubRecipeProvider` is unit tests only. No save adapter yet. EMI/JEI/REI are not dependencies.
|
||
|
||
Infrastructure is never the source of domain truth.
|
||
|
||
---
|
||
|
||
## Recipe abstraction
|
||
|
||
The domain should never import a recipe viewer.
|
||
|
||
Port: [[🔌 Recipe Provider]] — `resolve(ItemId, quantity) → list of MaterialRequirement`.
|
||
|
||
Shipped: `VanillaRecipeProvider` on `RecipeManager`. EMI/JEI/REI are not required. See ADR-016.
|
||
|
||
Recipe viewing is out of scope. This port exists so the domain can resolve requirements, not so Satistaskory can become a recipe browser.
|
||
|
||
---
|
||
|
||
## Persistence abstraction
|
||
|
||
The domain should not know where data is stored.
|
||
|
||
Possible implementations:
|
||
|
||
- World Save
|
||
- Server Save
|
||
- Future Cloud Sync
|
||
|
||
First slice: in-memory. No save adapter yet.
|
||
|
||
---
|
||
|
||
## Inventory abstraction
|
||
|
||
The domain should not know how inventory is read.
|
||
|
||
It receives available quantities (`InventoryState`).
|
||
|
||
How those quantities are gathered (player inventory, ender chest, later storage integrations) is infrastructure and may change without a domain rewrite.
|
||
|
||
First slice: player inventory only.
|
||
|
||
---
|
||
|
||
## UI philosophy
|
||
|
||
The UI should be replaceable. It renders domain information. It does not contain domain logic.
|
||
|
||
Discovered consumers (see [[🖥️ Experience]]):
|
||
|
||
- **Capture** — in-place on inventory, crafting bench craft pane, and craft book. Tooltip + rebindable Add key (default `=`). We do not own those views. Not a clickable chip beside the slot.
|
||
- **Living** — play overlay HUD on the **right** of the play screen (not a `Screen`). Two regions: [[🎯 Goal|goals]] with quantity `[+]` / `[-]`, then aggregated materials still needed (one row per material, with a count). `X Clear Items` clears the goal list. Vanilla button sprites + click sound; cursor via chat. See [[🖼️ Wireframes]] Screen 2.
|
||
|
||
Not discovered:
|
||
|
||
- Full-screen planner
|
||
- Row selection / per-goal filter of the missing list
|
||
|
||
Progressive disclosure is a UI concern guided by the domain: the materials region defaults to missing materials; expand into per-goal breakdowns, recipe trees, and dependency chains only on demand. Those expansions are not this panel’s first drawing.
|
||
|
||
---
|
||
|
||
## Architectural rules
|
||
|
||
1. Goals are the domain.
|
||
2. Recipes are infrastructure.
|
||
3. UI is infrastructure.
|
||
4. Storage is infrastructure.
|
||
5. Integrations are infrastructure.
|
||
6. The domain layer must not depend on infrastructure.
|
||
7. Infrastructure may depend on the domain.
|
||
|
||
---
|
||
|
||
## Success criteria
|
||
|
||
If the recipe source changes (stub → `RecipeManager`, or a later viewer-only edge case), Satistaskory should require only an adapter replacement and not a domain rewrite.
|
||
|
||
The domain model should survive infrastructure changes.
|
||
|
||
See [[🎯 Success Metrics]].
|
||
|
||
---
|
||
|
||
## Related Documents
|
||
|
||
[[🧠 Philosophy]]
|
||
|
||
[[📦 Bounded Contexts]]
|
||
|
||
[[📝 Decisions]]
|
||
|
||
[[🗣️ Ubiquitous Language]]
|
||
|
||
[[🧾 Recipe Resolution]]
|
||
|
||
[[🖥️ Experience]]
|
||
|
||
[[🚶 Day in the Life]]
|
||
|
||
[[🖼️ Wireframes]]
|
||
|
||
[[📦 Packages]]
|
||
|
||
[[🔌 Recipe Provider]]
|
||
|
||
[[▶️ Create Goal]]
|