How dreamblader/dominion-simulator works
Based on our analysis of the file tree and README, this project is a full-stack card game simulator called "Dimensional Dominions" that mimics a board game experience. Its goal is to simulate various card game actions (drawing, spawning, attacking, etc.) in an online environment, similar in spirit to digital board game platforms. The project uses a React front-end for the user interface (located in src/Client) and a Node-based server for game logic (located in src/Server). Additionally, there is a data layer with SQL scripts, CSV conversion utilities, and a database (data/game.db) that helps set up and maintain game data.
• Game Client (Frontend)
• All the React-based UI components found under src/Client.
• Subdivision into subcomponents: game pages (arena, board, lobby, menu, rules, etc.), UI components (cards, menus, fragments, etc.), context providers (game, menu, page etc.) and style assets.
• User interactions such as drawing cards, shuffling decks, and initiating phases.
• Game Server (Backend)
• Located in src/Server with server actions managing game logic (e.g., board actions, control flows, database interactions).
• Contains code that processes game phases (e.g., spawn phase, tick phase, battle phase) and interacts with game state models in src/models.
• Data Layer and Database
• The data folder holds SQL scripts (data/sql) to initialize and update the game database, CSV files for card data conversion, and scripts (data/start-db.js, data/card-convert.js) for data processing.
• Represents persistent storage for game components such as decks, cards, and game rules.
• Game Models and Utility Layer
• Found in src/models and src/utils, containing definitions for the card objects, game state (ticks, phases, actions) and helper functions.
• Although this can be seen as an internal part of both server and client logic, it’s important to show that there’s a clearly defined domain model for the game.
Relationships and Interactions
• The Game Client (React UI) communicates with the Game Server (via API calls or real-time socket connections) to trigger game actions (e.g., starting a turn, drawing a card, flipping a card).
• The Server processes the actions (the core game engine) by consuming request data from the UI, updating game state based on user actions, and referencing the models and game logic.
• The Data Layer supports the Server by persisting game state, card information, and other static/dynamic data. Scripts under data/ are used for the initial population and updates to this information.
• The Models (domain layer) encapsulate the rules and interactions within the game (for example, board tiles, ticks, and menus) and are referenced by both client-side state management and server-side processing.
• External references: the README refers to Boardgame.io, which means some game-framework-provided abstractions might also be integrated on the server side.
Architectural Patterns and Technologies
• A clear separation exists between the presentation (React UI) and the game logic (Node server). This suggests an MVC or separated concerns approach.
• State management is likely shared between the client and server, with clients dispatching actions to the server which applies game rules and updates the model accordingly.
• Data conversion and database seeding operations (via CSV converters and SQL scripts) follow a batch/command-line utility pattern.
Elements
• "React UI (Client)" representing src/Client.
• "Game Server/API" representing src/Server.
• "Game Models & Logic" (src/models and src/utils) as a shared or supporting component.
• "Database & Data Scripts" representing data/game.db, SQL, and CSV conversion tools.
• From the "React UI" to the "Game Server/API" when an action (e.g., drawing a card) is invoked.
• From the "Game Server/API" to the "Database" for updates or queries.
• From the "Data Scripts" to the "Database" during initialization or updates.
• External libraries or frameworks like Boardgame.io if they are part of the game loop, showing their integration within the server logic.