# πŸ›οΈ 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: `StubRecipeProvider`, player-inventory snapshot, HUD overlay, tooltip+key capture. 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: `StubRecipeProvider`. Next: `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]]