# Dev Loop

Clone, install tools with mise, run just recipes, seed fixtures, and run E2E tests.

## First-time setup

```sh
git clone --recurse-submodules https://gitlab.com/yotoshelf/yotoshelf.git
cd yotoshelf
mise install        # installs Go, Node, sqlc, golangci-lint, just
just dev            # starts Go :8080 + Astro :4300
```

## just recipes

```sh
just dev            # Go backend + Astro frontend, hot reload
just check          # lint + test + build (must pass before MR)
just generate       # sqlc + openapi-typescript code generation
just seed           # populate the DB with fixture data
just test           # unit tests only
just test-v         # unit tests, verbose
just e2e            # Playwright end-to-end (both servers must be up)
just build          # production binary + embedded frontend
just migrate        # run pending DB migrations
just migration NAME # create a new goose migration file
```

## Fixture seeding

`just seed` creates a local admin user, two collections, several sample cards, and linked Yoto account fixtures. The seed command is idempotent — running it multiple times is safe.

To reset to a clean state:

```sh
rm yotoshelf.db
just migrate
just seed
```

## Code generation

After any change to SQL queries or the huma API:

```sh
just generate
```

This runs sqlc (type-safe query generation) and openapi-typescript (frontend type generation). Generated files are committed — never edit them manually.

## E2E tests

Playwright E2E tests live in `e2e/`. They require both servers to be running:

```sh
# Terminal 1
just dev

# Terminal 2
just e2e
```

CI runs E2E against a fresh seeded database on every MR.

## Hot reload behaviour

- **Go backend:** Uses `air` for live reloading. Changes to `.go` files trigger a rebuild and restart in ~1s.
- **Astro frontend:** Vite HMR. Component and style changes are instant. Changes to `frontend/src/lib/api/types.ts` (generated) require a manual page refresh.
