feat(devex): add a unified just command surface
- 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
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
# 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.
|
||||
@@ -0,0 +1,43 @@
|
||||
set shell := ["bash", "-eu", "-o", "pipefail", "-c"]
|
||||
|
||||
gradle := "./gradlew"
|
||||
|
||||
# Show the backend recipes available in this directory.
|
||||
help:
|
||||
@just --list
|
||||
|
||||
# Print the backend Gradle and JVM versions.
|
||||
version:
|
||||
{{ gradle }} --version
|
||||
|
||||
# Run the backend locally with the requested Spring profile. Default: `dev`.
|
||||
run profile='dev':
|
||||
{{ gradle }} bootRun --args="--spring.profiles.active={{ profile }}"
|
||||
|
||||
# Build the backend jar and run the standard Gradle build lifecycle.
|
||||
build:
|
||||
{{ gradle }} build --no-daemon --parallel --build-cache
|
||||
|
||||
# Run the backend test suite.
|
||||
test:
|
||||
{{ gradle }} test --no-daemon --parallel --build-cache
|
||||
|
||||
# Run a single backend test class, for example `just test-class test_class=org.booklore.service.BookServiceTest`.
|
||||
test-class test_class:
|
||||
{{ gradle }} test --tests "{{ test_class }}" --no-daemon --parallel --build-cache
|
||||
|
||||
# Run tests and generate JaCoCo coverage output.
|
||||
coverage:
|
||||
{{ gradle }} test jacocoTestReport --no-daemon --parallel --build-cache
|
||||
|
||||
# Run the Gradle `check` lifecycle used for local backend verification.
|
||||
check:
|
||||
{{ gradle }} check --no-daemon --parallel --build-cache
|
||||
|
||||
# Remove backend build outputs.
|
||||
clean:
|
||||
{{ gradle }} clean --no-daemon
|
||||
|
||||
# List the available backend Gradle tasks.
|
||||
tasks:
|
||||
{{ gradle }} tasks --all --no-daemon
|
||||
@@ -0,0 +1,69 @@
|
||||
# Grimmory API
|
||||
|
||||
The `booklore-api` project is the Spring Boot backend for Grimmory. It owns the HTTP API, database migrations, background processing, authentication, and the packaged runtime jar that the production container runs.
|
||||
|
||||
## Stack
|
||||
|
||||
- Java 25
|
||||
- Spring Boot 4
|
||||
- Gradle Wrapper
|
||||
- Spring Data JPA + Flyway
|
||||
- MariaDB in production, H2 for selected tests
|
||||
- JUnit 5, Mockito, AssertJ, JaCoCo
|
||||
|
||||
## Local Command Surface
|
||||
|
||||
Use [`Justfile`](Justfile) when possible. It is the primary backend command surface for both humans and agents.
|
||||
|
||||
```bash
|
||||
just # List backend recipes
|
||||
just run # Start bootRun with the dev profile
|
||||
just test # Run the backend test suite
|
||||
just coverage # Run tests and generate JaCoCo output
|
||||
just check # Run the Gradle check lifecycle
|
||||
just tasks # Show available Gradle tasks
|
||||
```
|
||||
|
||||
The repository root also exposes the same recipes through namespacing:
|
||||
|
||||
```bash
|
||||
just api test
|
||||
just api run
|
||||
just api coverage
|
||||
```
|
||||
|
||||
## Running Locally
|
||||
|
||||
The backend expects a MariaDB instance and a local `application-dev.yml` with your database and storage paths. The higher-level setup lives in [../CONTRIBUTING.md](../CONTRIBUTING.md), but the common backend loop is:
|
||||
|
||||
```bash
|
||||
cd booklore-api
|
||||
just run
|
||||
```
|
||||
|
||||
If you need a different Spring profile:
|
||||
|
||||
```bash
|
||||
just run profile=local
|
||||
```
|
||||
|
||||
## Build and Test
|
||||
|
||||
```bash
|
||||
just build
|
||||
just test
|
||||
just coverage
|
||||
just check
|
||||
```
|
||||
|
||||
The frontend bundle is consumed during packaging when the UI build output exists. For normal backend-only development and test runs, the frontend resources are optional.
|
||||
|
||||
## Packaging Notes
|
||||
|
||||
- The production container image is built from the repository root `Dockerfile`.
|
||||
- That Docker build compiles the UI first and passes the resolved frontend dist path into the backend build.
|
||||
- The backend jar remains the packaged application artifact for the current all-in-one runtime model.
|
||||
|
||||
## More Detail
|
||||
|
||||
Backend-specific contributor rules and conventions live in [CONTRIBUTING.md](CONTRIBUTING.md).
|
||||
Reference in New Issue
Block a user