|
| 1 | +# Architecture and API (draft) |
| 2 | + |
| 3 | +This project is a local, single-player Minesweeper game. The frontend (Vue) is responsible for UI and user interaction. The backend (Go) is responsible for all game logic and state computation. The frontend and backend communicate via HTTP APIs. This project assumes a trusted local user and does not require authentication or encryption. |
| 4 | + |
| 5 | +High-level contract (illustrative): |
| 6 | + |
| 7 | +- Data shape (GameState) example: |
| 8 | + - width: int |
| 9 | + - height: int |
| 10 | + - mines: int |
| 11 | + - cells: [[Cell]] — each Cell contains coordinates, isMine, isRevealed, isFlagged, adjacentMines (returned by backend) |
| 12 | + - status: one of {playing, won, lost} |
| 13 | + |
| 14 | +- Suggested HTTP endpoints (illustrative, not an implementation): |
| 15 | + - POST /game/new — create a new game; request includes width/height/mines; returns GameState (initially unrevealed) |
| 16 | + - POST /game/reveal — reveal a cell; parameters: game_id (optional if the backend keeps single in-memory game) / x / y; returns updated GameState |
| 17 | + - POST /game/flag — flag/unflag a cell; parameters: x / y; returns updated GameState |
| 18 | + - GET /game — get current GameState (optional) |
| 19 | + |
| 20 | +Error modes and edge cases: |
| 21 | + |
| 22 | +- Invalid coordinates: return 400 Bad Request |
| 23 | +- Operations on a finished game (e.g., revealing after lost/won): return 409 Conflict or return the current state unchanged |
| 24 | +- Very large board sizes (memory/performance): the client should limit max width/height and the server should guard against extreme values that could cause OOM |
| 25 | + |
| 26 | +Success criteria (minimum): |
| 27 | + |
| 28 | +- Frontend can create/reveal/flag cells and correctly render the returned GameState |
| 29 | +- Backend logic correctly implements reveal expansion (when revealing a cell with 0 adjacent mines, automatically reveal neighbors) |
| 30 | + |
| 31 | +Future extensions: |
| 32 | + |
| 33 | +- Persist multiple games (in-memory -> file/DB) |
| 34 | +- User accounts and authentication |
| 35 | +- Packaging and deployment scripts |
0 commit comments