# Repository Guidelines

## Project Structure & Module Organization
- `sproutgate-frontend/`: React + Vite app. Entry at `src/main.jsx`, main UI in `src/App.jsx`, user portal partials in `src/components/userPortal/` (e.g. `UserPortalAuthSection.jsx`, `UserPortalProfileSection.jsx`), styles in `src/styles.css`.
- `sproutgate-backend/`: Go + Gin API. Entry at `main.go`, HTTP handlers in `internal/handlers/` (split across `handler.go`, `requests.go`, `helpers.go`, `auth_login.go`, `auth_password.go`, `secondary_email.go`, `profile.go`, `checkin.go`, `admin.go`), domain models in `internal/models/`, storage in `internal/storage/`.
- `sproutgate-backend/data/`: JSON-backed config and data. Config files live in `data/config/`, user records in `data/users/`.
- Root scripts `sproutgate.sh` and `sproutgate.bat` provide dev and build shortcuts.

## Build, Test, and Development Commands
- `./sproutgate.sh dev` or `sproutgate.bat dev`: start backend and frontend dev servers.
- `./sproutgate.sh build` or `sproutgate.bat build`: build the frontend bundle.
- `cd sproutgate-backend && go mod tidy`: sync Go dependencies.
- `cd sproutgate-backend && go run .`: run the API (default port `8080`).
- `cd sproutgate-frontend && npm install`: install frontend dependencies.
- `cd sproutgate-frontend && npm run dev`: run Vite dev server (default `5173`).
- `cd sproutgate-frontend && npm run build`: create a production build.
- `cd sproutgate-frontend && npm run preview`: preview the build locally.

## Coding Style & Naming Conventions
- Go code should be `gofmt`-formatted; packages are lowercase, exported types use PascalCase, JSON tags use lowerCamelCase.
- Frontend code follows existing `src/*.jsx` patterns: 2-space indentation, double quotes, components in PascalCase, hooks prefixed with `use`.
- File naming mirrors current structure: Go files are lowercase (use underscores when needed, e.g., `secondary_email.go`); React components use `.jsx`.

## Testing Guidelines
- No automated test suites are configured yet (no `*_test.go` and no `npm test` script).
- When adding backend tests, use Go's standard testing (`*_test.go`) and run `go test ./...` in `sproutgate-backend/`.
- If frontend tests are introduced, document the runner and command in `sproutgate-frontend/package.json` and update this guide.

## Commit & Pull Request Guidelines
- Git history currently contains only `Initial commit`; there is no established commit convention yet.
- Use short, imperative commit summaries; add a scope when helpful (e.g., `frontend: refine admin table`).
- PRs should include a concise summary, testing notes, and screenshots for UI changes; call out any config or env var updates.

## Security & Configuration Tips
- Backend configuration is stored under `sproutgate-backend/data/config/` (admin, auth, email, check-in, registration invites).
- Frontend API base URL can be set via `sproutgate-frontend/.env` using `VITE_API_BASE`.
- Avoid committing real credentials or production tokens; use local overrides for secrets.
- API reference lives in `sproutgate-backend/API_DOCS.md` and is served at `GET /api/docs`. Brief JSON overview: `GET /` and `GET /api`.
