Skip to content

Commit e81cfe9

Browse files
author
Jiache Zhang
committed
folder structure init
1 parent 81e626d commit e81cfe9

File tree

8 files changed

+189
-1
lines changed

8 files changed

+189
-1
lines changed

.github/workflows/ci.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
pull_request:
6+
7+
jobs:
8+
backend:
9+
name: Backend (Go) checks
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v4
13+
- name: Setup Go
14+
uses: actions/setup-go@v4
15+
with:
16+
go-version: '1.20'
17+
- name: Cache Go modules
18+
uses: actions/cache@v4
19+
with:
20+
path: |-
21+
~/.cache/go-build
22+
${{ github.workspace }}/backend/pkg/mod
23+
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
24+
- name: "Backend: lint & build (template)"
25+
run: |
26+
echo "Run backend linters and build here (per backend/README.md)"
27+
28+
frontend:
29+
name: Frontend (Node) checks
30+
runs-on: ubuntu-latest
31+
steps:
32+
- uses: actions/checkout@v4
33+
- name: Setup Node
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: '18'
37+
- name: "Frontend: install & build (template)"
38+
run: |
39+
echo "Run frontend install/build/lint here (per frontend/README.md)"

Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
.PHONY: help init start-backend start-frontend fmt lint
2+
3+
help:
4+
@echo "Targets: init, start-backend, start-frontend, fmt, lint"
5+
6+
init:
7+
@echo "Run per-subproject init steps. See frontend/README.md and backend/README.md"
8+
9+
start-backend:
10+
@echo "Start backend: cd backend && go run ./... (after you init go module and implement server)"
11+
12+
start-frontend:
13+
@echo "Start frontend: cd frontend && npm install && npm run dev (after you scaffold the Vue app)"
14+
15+
fmt:
16+
@echo "Run formatters in each subproject (go fmt, npm format etc.)"
17+
18+
lint:
19+
@echo "Run linters in each subproject (go vet/staticcheck, eslint etc.)"

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,30 @@
1-
# minesweeper
1+
# minesweeper
2+
3+
This repository is a monorepo skeleton for practicing full-stack development with a Minesweeper game. The project separates frontend and backend but keeps them in one repository and includes example CI and documentation templates.
4+
5+
Initial directory layout:
6+
7+
- `frontend/` — Frontend code and instructions (Vue + Vite). Responsible only for UI and user interaction.
8+
- `backend/` — Backend code and instructions (Go). Responsible for game logic and state computation, communicating with the frontend over HTTP.
9+
- `docs/` — Architecture, API design, and CI/CD guidance.
10+
- `.github/workflows/` — Example CI workflow files.
11+
12+
Quick start (recommended flow):
13+
14+
1. Initialize the backend module:
15+
16+
- Change to `backend/` and run `go mod init github.com/<your-username>/minesweeper/backend` (or follow `backend/README.md`).
17+
18+
2. Initialize the frontend development project:
19+
20+
- Change to `frontend/` and create a Vite + Vue project:
21+
22+
`npm create vite@latest` or `pnpm create vite` and follow `frontend/README.md` for options.
23+
24+
3. Run locally: start the backend from the command line first, then run the frontend development server and open it in your browser.
25+
26+
See the README files inside each subdirectory and `docs/` for more detailed guidance and CI/CD examples.
27+
28+
---
29+
30+
Next step: the repository now contains scaffold files (README, docs, CI template, .gitignore, Makefile, and subproject READMEs). Follow those instructions to initialize each subproject.

backend/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# backend (Go) — README
2+
3+
Goal: Implement all game logic and state computation in Go and expose a simple HTTP REST API for the frontend to call.
4+
5+
Recommended local initialization steps:
6+
7+
1. Change into `backend/` and initialize the module:
8+
9+
go mod init github.com/<your-username>/minesweeper/backend
10+
11+
2. Suggested code organization:
12+
13+
- `cmd/server/` — executable entrypoint (e.g. `main.go`)
14+
- `internal/` or `pkg/` — game logic, models, and services
15+
- `game/` — core algorithms: mine placement, reveal expansion, win/loss detection
16+
- `http/` — HTTP handler layer responsible for JSON serialization and routing
17+
18+
3. Run (example):
19+
20+
go run ./cmd/server
21+
22+
Note: This repository currently contains only documentation and a skeleton. After implementing the backend logic you can run the service from the command line.

docs/ARCHITECTURE.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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

docs/CI_CD.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# CI / CD Recommendations (example)
2+
3+
Goal: On each push or pull request automatically verify that the backend builds and passes basic static checks, and that the frontend can install dependencies and build (or at least run basic linters).
4+
5+
Recommended steps:
6+
7+
1. Checkout the repository
8+
2. Setup Go (pin a version, e.g. 1.20+), run `go vet` / `go test` / `go build` (based on the backend implementation)
9+
3. Setup Node (pin a version, e.g. 18+), in `frontend/` run `npm ci` and `npm run build` or `npm run lint`
10+
4. Optional: cache dependencies (Go modules, npm cache) to speed up runs
11+
5. Optional: deploy built frontend to static hosting (e.g., GitHub Pages) or build and release backend binaries
12+
13+
This repository contains an example GitHub Actions workflow at `.github/workflows/ci.yml` as a starting point.

docs/OPERATIONS.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Operations and Local Development (notes)
2+
3+
This repository is intended for local, single-developer learning and development. Recommended workflow:
4+
5+
- Implement and run the backend in `backend/` first with `go run` and have it listen on a port such as `http://localhost:8080`.
6+
- Then run the frontend development server from `frontend/` using Vite (default `http://localhost:5173`) and point the frontend API base URL to the backend address.
7+
8+
This repository currently provides documentation and CI templates only. The next step is to initialize the subprojects following the instructions in `backend/README.md` and `frontend/README.md`.

frontend/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# frontend (Vue) — README
2+
3+
Goal: Use Vue + Vite to implement only the UI and user interactions for the Minesweeper game. The frontend should call the backend HTTP API to create and update game state.
4+
5+
Recommended local initialization steps (example):
6+
7+
1. In the `frontend/` directory scaffold a Vite project:
8+
9+
npm create vite@latest . # choose Vue / JavaScript or TypeScript when prompted
10+
11+
2. Install dependencies and start the development server:
12+
13+
npm install
14+
npm run dev
15+
16+
Suggested project structure:
17+
18+
- `src/` — Vue source files
19+
- `components/` — components like Board, Cell, Controls
20+
- `services/api.ts` — a small wrapper for HTTP calls to the backend
21+
- `App.vue` / `main.ts`
22+
23+
Note: This repository currently contains only documentation and a skeleton. Initialize the real frontend code with Vite as described above.

0 commit comments

Comments
 (0)