- Command surface: - add a root `Justfile` with namespaced `api`, `ui`, and `release` modules so humans and agents can use the same entrypoints from the repo root - add project-local Justfiles for `booklore-api`, `booklore-ui`, and `tools/release` so each area remains self-contained and can still be driven from inside its own directory - standardize local developer workflows around `just check`, `just test`, `just api run`, `just ui dev`, `just db-up`, and `just image-build` - Workflow integration: - update the reusable test suite workflow to install `just` and run backend and frontend CI steps through the Justfiles instead of hardcoded shell commands - update the semantic-release workflows to install `just` and invoke release tooling via `just release install`, `just release preview`, and `just release run` - keep the Docker image publication workflows on the native Docker actions while moving the project-command logic into the canonical command surface - Documentation: - split backend and frontend implementation guidance into `booklore-api/README.md`, `booklore-api/CONTRIBUTING.md`, `booklore-ui/README.md`, and `booklore-ui/CONTRIBUTING.md` - simplify the top-level `README.md` and `CONTRIBUTING.md` so they stay focused on overview, policy, and navigation while pointing to component-specific guides for deeper detail - align contributor-facing examples on the `just` interface instead of mixing ad hoc Gradle, npm, Docker, and Compose commands - Developer environment: - add `mise.toml` to pin the expected Java and Node toolchain versions for local work - switch the development Compose defaults from the old Booklore database values to Grimmory-oriented defaults - keep the command layout ready for a future API/UI split without forcing that packaging change yet
63 lines
2.4 KiB
Markdown
63 lines
2.4 KiB
Markdown
# Contributing to Grimmory API
|
|
|
|
This document covers backend-specific development and review expectations for `booklore-api`.
|
|
|
|
For repository-wide contribution policy, branch strategy, PR requirements, and release semantics, start with [../CONTRIBUTING.md](../CONTRIBUTING.md).
|
|
|
|
## Preferred Command Surface
|
|
|
|
Use [`Justfile`](Justfile) when possible:
|
|
|
|
```bash
|
|
just # List backend recipes
|
|
just run # Start the backend with the dev profile
|
|
just test # Run backend tests
|
|
just coverage # Generate JaCoCo coverage output
|
|
just check # Run the Gradle check lifecycle
|
|
```
|
|
|
|
From the repository root, the same recipes are available through the `api` namespace:
|
|
|
|
```bash
|
|
just api test
|
|
just api run
|
|
just api check
|
|
```
|
|
|
|
## Backend Conventions
|
|
|
|
- Use Spring Data JPA repository methods or JPQL. Do not introduce native queries unless a maintainer has explicitly approved them.
|
|
- Prefer constructor injection via Lombok `@AllArgsConstructor`. Do not add `@Autowired`.
|
|
- Use Lombok `@Slf4j` for logging. Do not instantiate loggers manually.
|
|
- Throw API-facing errors via `ApiError` helpers instead of raw `RuntimeException`.
|
|
- Entities use the `*Entity` suffix. DTOs and API models do not.
|
|
- Use MapStruct for entity-to-DTO mapping instead of hand-written mapping code.
|
|
- Security checks should use the existing project patterns such as `@PreAuthorize("@securityUtil.isAdmin()")` or `@CheckBookAccess`.
|
|
- Use modern Java language features where they clarify the code.
|
|
- Keep imports explicit. Do not inline fully-qualified class names.
|
|
|
|
## Migrations
|
|
|
|
- Flyway migrations live in `src/main/resources/db/migration/`.
|
|
- Name migrations `V<number>__<Description>.sql`.
|
|
- Never modify a released migration. Add a new migration instead.
|
|
- Prefer idempotent guards such as `IF EXISTS` and `IF NOT EXISTS` when the SQL dialect allows them.
|
|
|
|
## Testing
|
|
|
|
- Unit tests should normally use JUnit 5 + Mockito + AssertJ.
|
|
- Use `@ExtendWith(MockitoExtension.class)` for unit tests.
|
|
- Use `@SpringBootTest` only when you need a real Spring integration context.
|
|
- Keep tests behavior-oriented. Avoid shallow tests that only exercise getters, setters, or mocks without asserting meaningful outcomes.
|
|
|
|
## Validation Before Opening a PR
|
|
|
|
Run the backend checks locally before sending a PR:
|
|
|
|
```bash
|
|
just test
|
|
just check
|
|
```
|
|
|
|
If your change affects migrations, persistence, or API behavior, also run the full stack locally and verify the behavior manually.
|