Add configuration files and update project documentation
- Introduced .editorconfig for consistent coding styles across the project. - Added .golangci.yml for Go linting configuration. - Updated AGENTS.md to clarify project structure and components. - Enhanced CONTRIBUTING.md with Makefile usage for common tasks. - Updated Dockerfiles to use Go 1.24 and improved build instructions. - Refined README.md and deployment documentation for clarity. - Added testing documentation in testing.md for backend and frontend tests. - Introduced Makefile for streamlined development commands and tasks.
This commit is contained in:
@@ -4,18 +4,42 @@
|
||||
|
||||
Clone the repository and run the project locally (see [Development](docs/development.md)):
|
||||
|
||||
- **Option A:** Docker Compose for development: `docker compose -f docker-compose.dev.yml up` (frontend on 3000, backend on 3080).
|
||||
- **Option A:** Docker Compose for development: `docker compose -f docker-compose.dev.yml up` (or `make dev`). Frontend on 3000, backend on 3080.
|
||||
- **Option B:** Run Go backend from the repo root (`go run ./cmd/hnh-map -grids=./grids -port=8080`) and Nuxt separately (`cd frontend-nuxt && npm run dev`). Ensure the frontend can reach the backend (proxy or same host).
|
||||
|
||||
## Code layout
|
||||
|
||||
- **Backend:** Entry point is `cmd/hnh-map/main.go`. All application logic lives in `internal/app/` (package `app`): `app.go`, `auth.go`, `api.go`, `handlers_redirects.go`, `client.go`, `client_grid.go`, `client_positions.go`, `client_markers.go`, `admin_*.go`, `map.go`, `tile.go`, `topic.go`, `migrations.go`.
|
||||
- **Frontend:** Nuxt 3 app in `frontend-nuxt/` (pages, components, composables, layouts, server, plugins, `public/gfx`). It is served by the Go backend at root `/` with baseURL `/`.
|
||||
The backend follows a layered architecture: **Store → Services → Handlers**.
|
||||
|
||||
## Formatting and tests
|
||||
- **Backend:** Entry point is `cmd/hnh-map/main.go`. Application logic lives in `internal/app/`:
|
||||
- `app.go` — `App` struct, domain types, SPA serving, constants.
|
||||
- `router.go` — route registration.
|
||||
- `topic.go` — pub/sub for real-time updates.
|
||||
- `migrations.go` — database migrations.
|
||||
- `store/` — bbolt database access layer (`db.go`, `buckets.go`).
|
||||
- `services/` — business logic (`auth.go`, `map.go`, `admin.go`, `client.go`, `export.go`).
|
||||
- `handlers/` — HTTP handlers (`api.go`, `auth.go`, `map.go`, `client.go`, `admin.go`, `tile.go`, `handlers.go`, `response.go`).
|
||||
- `apperr/` — domain error types.
|
||||
- `response/` — shared JSON response helpers.
|
||||
- **Frontend:** Nuxt 3 app in `frontend-nuxt/` (pages, components, composables, layouts, plugins, `public/gfx`). It is served by the Go backend at root `/` with baseURL `/`.
|
||||
|
||||
- Go: run `go fmt ./...` before committing.
|
||||
- Add or update tests if you change behaviour; run `go test ./...` if tests exist.
|
||||
## Formatting, linting, and tests
|
||||
|
||||
Use Makefile targets for common tasks:
|
||||
|
||||
```bash
|
||||
make fmt # Format all code (Go + frontend)
|
||||
make lint # Run Go linter (golangci-lint) and frontend ESLint
|
||||
make test # Run Go tests
|
||||
```
|
||||
|
||||
Or run manually:
|
||||
|
||||
- Go: `go fmt ./...` and `golangci-lint run`
|
||||
- Frontend: `npm --prefix frontend-nuxt run lint` and `npm --prefix frontend-nuxt run format`
|
||||
- Tests: `go test ./...`
|
||||
|
||||
Always format and lint before committing. Add or update tests if you change behaviour.
|
||||
|
||||
## Submitting changes
|
||||
|
||||
|
||||
Reference in New Issue
Block a user