|
| 1 | +# Repository Guidelines |
| 2 | + |
| 3 | +## Project Structure & Module Organization |
| 4 | + |
| 5 | +```text |
| 6 | +├─ cmd/alexandria # Main binary source (main.go, server.go) |
| 7 | +├─ alexandria # Core library code and unit tests |
| 8 | +├─ web # Templating and static assets (css, fonts) |
| 9 | +├─ Dockerfile # Container image definition |
| 10 | +├─ manifest/ # Kustomize manifests for prod/staging |
| 11 | +├─ package.json # Node tooling for asset pipeline |
| 12 | +└─ go.mod / go.sum # Go module definition |
| 13 | +``` |
| 14 | + |
| 15 | +- Go source lives under `cmd/` for executables and top‑level packages for |
| 16 | + reusable code. |
| 17 | +- Tests are co‑located with the package they cover (`*_test.go`). |
| 18 | +- Static web assets are under `web/xess/static` and compiled templates under |
| 19 | + `web/`. |
| 20 | + |
| 21 | +## Production Environment |
| 22 | + |
| 23 | +The service is deployed to a Kubernetes cluster. Production manifests are stored |
| 24 | +under the `manifest/` directory and are applied with Kustomize (e.g., |
| 25 | +`kustomize build manifest/prod | kubectl apply -f -`). The Docker image built |
| 26 | +via `docker buildx bake --load` is pushed to the container registry and |
| 27 | +referenced in the Kubernetes Deployment spec. |
| 28 | + |
| 29 | +## Build, Test, and Development Commands |
| 30 | + |
| 31 | +| Command | Description | |
| 32 | +| ------------------------------ | ------------------------------------------------- | |
| 33 | +| `go build ./cmd/alexandria` | Compiles the server binary. | |
| 34 | +| `go run ./cmd/alexandria` | Runs the server locally (reads env vars). | |
| 35 | +| `npm run test` | Executes all repository tests (via npm script). | |
| 36 | +| `npm install && npm run build` | Installs Node dependencies and builds web assets. | |
| 37 | +| `docker buildx bake --load` | Builds the Docker image using the bake file. | |
| 38 | + |
| 39 | +## Coding Style & Naming Conventions |
| 40 | + |
| 41 | +- Use **gofmt** (or `go fmt ./...`) for formatting. |
| 42 | +- Follow **golint/go vet** recommendations – avoid exported names with |
| 43 | + underscores. |
| 44 | +- Indentation: tabs (default Go style). |
| 45 | +- Naming: `camelCase` for variables, `PascalCase` for exported types and |
| 46 | + functions. |
| 47 | +- Linting: `go vet ./...` and `staticcheck ./...` are run in CI. |
| 48 | + |
| 49 | +## Testing Guidelines |
| 50 | + |
| 51 | +- Test files end with `_test.go` and use the standard `testing` package. |
| 52 | +- Name test functions `Test<Thing>` and keep them focused. |
| 53 | +- Run coverage locally with `go test -cover ./...`. |
| 54 | +- Aim for ≥ 80 % coverage on new code. |
| 55 | + |
| 56 | +## Commit & Pull Request Guidelines |
| 57 | + |
| 58 | +- **Commit messages** follow Conventional Commits: |
| 59 | + `<type>(<scope>): <description>`. _Examples:_ |
| 60 | + `feat(server): add health endpoint`, `chore: update license`. |
| 61 | +- PR description must include: |
| 62 | + 1. A brief summary of the change. |
| 63 | + 2. Linked issue number (`Fixes #123`). |
| 64 | + 3. Any required migration steps. |
| 65 | + 4. Screenshots for UI or asset changes. |
| 66 | +- Keep PRs small and focused; request review after CI passes. |
| 67 | +- **Assisted‑by footer** – when a commit is generated with AI assistance, append |
| 68 | + a footer line to the commit message: `Assisted-by: GPT-OSS 120b` |
| 69 | + |
| 70 | +## Security & Configuration Tips |
| 71 | + |
| 72 | +- Secrets are loaded via environment variables (see `README.md`). |
| 73 | +- Do not commit `.env` files; add them to `.gitignore`. |
| 74 | +- Run `go vet` and `staticcheck` before pushing to catch insecure patterns. |
| 75 | + |
| 76 | +--- |
| 77 | + |
| 78 | +These guidelines aim to keep the codebase consistent and easy to contribute to. |
| 79 | +If you notice a gap, feel free to open an issue or submit a PR. |
0 commit comments