docs: consolidate application project development docs (#545)
* docs: add DEVELOPMENT.md * docs: dedupe application project development guides * docs: update junit version target
This commit is contained in:
+5
-5
@@ -121,8 +121,8 @@ just image-build # Build the production image locally
|
|||||||
|
|
||||||
Use the repo-level guide for workflow, release, and PR policy, then drop into the component-specific guides when you are working inside a project:
|
Use the repo-level guide for workflow, release, and PR policy, then drop into the component-specific guides when you are working inside a project:
|
||||||
|
|
||||||
- Backend: [booklore-api/README.md](booklore-api/README.md) and [booklore-api/CONTRIBUTING.md](booklore-api/CONTRIBUTING.md)
|
- Backend: [booklore-api/DEVELOPMENT.md](booklore-api/DEVELOPMENT.md)
|
||||||
- Frontend: [frontend/README.md](frontend/README.md) and [frontend/CONTRIBUTING.md](frontend/CONTRIBUTING.md)
|
- Frontend: [frontend/DEVELOPMENT.md](frontend/DEVELOPMENT.md)
|
||||||
|
|
||||||
### Option 1: Docker Development Stack (Recommended)
|
### Option 1: Docker Development Stack (Recommended)
|
||||||
|
|
||||||
@@ -358,7 +358,7 @@ Before opening your PR:
|
|||||||
- [ ] PR is linked to an **approved** issue (PRs without a linked issue will be closed)
|
- [ ] PR is linked to an **approved** issue (PRs without a linked issue will be closed)
|
||||||
- [ ] All tests pass (`just test`)
|
- [ ] All tests pass (`just test`)
|
||||||
- [ ] Actual test output is pasted in the PR description
|
- [ ] Actual test output is pasted in the PR description
|
||||||
- [ ] Code follows the relevant component conventions (see [booklore-api/CONTRIBUTING.md](booklore-api/CONTRIBUTING.md) and [frontend/CONTRIBUTING.md](frontend/CONTRIBUTING.md))
|
- [ ] Code follows the relevant component conventions (see [booklore-api/DEVELOPMENT.md](booklore-api/DEVELOPMENT.md) and [frontend/DEVELOPMENT.md](frontend/DEVELOPMENT.md))
|
||||||
- [ ] No lint errors
|
- [ ] No lint errors
|
||||||
- [ ] Branch is up-to-date with `develop`
|
- [ ] Branch is up-to-date with `develop`
|
||||||
- [ ] You ran the full stack locally and manually verified the change works
|
- [ ] You ran the full stack locally and manually verified the change works
|
||||||
@@ -392,8 +392,8 @@ We've seen a sharp increase in AI-generated PRs where the contributor clearly ne
|
|||||||
|
|
||||||
Detailed coding conventions now live with each project:
|
Detailed coding conventions now live with each project:
|
||||||
|
|
||||||
- Backend rules: [booklore-api/CONTRIBUTING.md](booklore-api/CONTRIBUTING.md)
|
- Backend rules: [booklore-api/DEVELOPMENT.md](booklore-api/DEVELOPMENT.md)
|
||||||
- Frontend rules: [frontend/CONTRIBUTING.md](frontend/CONTRIBUTING.md)
|
- Frontend rules: [frontend/DEVELOPMENT.md](frontend/DEVELOPMENT.md)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
+238
@@ -0,0 +1,238 @@
|
|||||||
|
# Developing Grimmory
|
||||||
|
|
||||||
|
This document covers the technical side of working in the Grimmory codebase: environment setup, build
|
||||||
|
commands, testing, and conventions. If you haven't already, read [CONTRIBUTING.md](CONTRIBUTING.md)
|
||||||
|
first — it covers the process side: how issues become PRs, what gets a PR closed, and how to submit
|
||||||
|
work.
|
||||||
|
|
||||||
|
## Project Structure
|
||||||
|
|
||||||
|
```
|
||||||
|
grimmory/
|
||||||
|
├── frontend/ # Angular frontend (TypeScript, PrimeNG)
|
||||||
|
├── booklore-api/ # Spring Boot backend (Java 25, Gradle)
|
||||||
|
├── deploy/ # Compose, Helm, and Podman deployment examples
|
||||||
|
├── packaging/docker/ # Container runtime assets used by the Docker build
|
||||||
|
├── dev.docker-compose.yml # Development Docker stack
|
||||||
|
├── assets/ # Shared assets (logos, icons)
|
||||||
|
└── local/ # Local development helpers
|
||||||
|
```
|
||||||
|
|
||||||
|
## Preferred Command Surface
|
||||||
|
|
||||||
|
Use the root [`Justfile`](Justfile) as the primary local command surface. It wraps the commands below
|
||||||
|
into a consistent interface for both humans and agents.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
just # Show all root, api, and ui recipes
|
||||||
|
just check # Run the local verification pass
|
||||||
|
just test # Run backend + frontend tests
|
||||||
|
just api run # Start the backend with the dev profile
|
||||||
|
just ui dev # Start the frontend dev server
|
||||||
|
just dev-up # Start the Docker dev stack
|
||||||
|
just image-build # Build the production image locally
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Tip:** Agents and automation should prefer `just` recipes where a suitable recipe exists, so local
|
||||||
|
> workflows and documented commands stay aligned.
|
||||||
|
|
||||||
|
> **Tip:** Set `GRIMMORY_COMPOSE_FILE=/path/to/compose.yml` if you need the root `just` recipes to
|
||||||
|
> target a different development compose file.
|
||||||
|
|
||||||
|
## Component Guides
|
||||||
|
|
||||||
|
Use this document for repo-level workflow, then drop into the component-specific guides when working
|
||||||
|
inside a project:
|
||||||
|
|
||||||
|
- Backend: [booklore-api/DEVELOPMENT.md](booklore-api/DEVELOPMENT.md)
|
||||||
|
- Frontend: [frontend/DEVELOPMENT.md](frontend/DEVELOPMENT.md)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Development Setup
|
||||||
|
|
||||||
|
### Option 1: Docker Development Stack (Recommended)
|
||||||
|
|
||||||
|
The fastest way to get a working environment. No local toolchain required.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
just dev-up
|
||||||
|
```
|
||||||
|
|
||||||
|
This starts:
|
||||||
|
|
||||||
|
| Service | URL / Port |
|
||||||
|
| ---------- | --------------------- |
|
||||||
|
| Frontend | <http://localhost:4200> |
|
||||||
|
| Backend | <http://localhost:6060> |
|
||||||
|
| MariaDB | localhost:3366 |
|
||||||
|
| Debug port | localhost:5005 |
|
||||||
|
|
||||||
|
All ports are configurable via environment variables (`FRONTEND_PORT`, `BACKEND_PORT`, `DB_PORT`,
|
||||||
|
`REMOTE_DEBUG_PORT`) in the compose file.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
just dev-down # Stop the stack
|
||||||
|
```
|
||||||
|
|
||||||
|
### Option 2: Manual Setup
|
||||||
|
|
||||||
|
For full control over each component or IDE integration (debugging, hot-reload, etc.).
|
||||||
|
|
||||||
|
#### Prerequisites
|
||||||
|
|
||||||
|
| Tool | Version | Download |
|
||||||
|
| ----------------------- | ------- | -------------------------------------------- |
|
||||||
|
| Java | 25+ | [Adoptium](https://adoptium.net/) |
|
||||||
|
| Node.js + Corepack/Yarn | 24+ | [nodejs.org](https://nodejs.org/) |
|
||||||
|
| MariaDB | 10.6+ | [mariadb.org](https://mariadb.org/download/) |
|
||||||
|
| Git | latest | [git-scm.com](https://git-scm.com/) |
|
||||||
|
|
||||||
|
#### 1. Database
|
||||||
|
|
||||||
|
Start MariaDB and create the database:
|
||||||
|
|
||||||
|
```sql
|
||||||
|
CREATE DATABASE IF NOT EXISTS grimmory;
|
||||||
|
CREATE USER 'grimmory_user'@'localhost' IDENTIFIED BY 'your_password';
|
||||||
|
GRANT ALL PRIVILEGES ON grimmory.* TO 'grimmory_user'@'localhost';
|
||||||
|
FLUSH PRIVILEGES;
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Tip:** You can also start just the database with `just db-up`.
|
||||||
|
|
||||||
|
#### 2. Backend
|
||||||
|
|
||||||
|
|
||||||
|
```bash
|
||||||
|
just api run
|
||||||
|
```
|
||||||
|
|
||||||
|
#### 3. Frontend
|
||||||
|
|
||||||
|
```bash
|
||||||
|
just ui install
|
||||||
|
just ui dev # Available at http://localhost:4200 with hot-reload
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## API Reference Docs
|
||||||
|
|
||||||
|
When enabled, API documentation is available at:
|
||||||
|
|
||||||
|
- Scalar UI: `http://localhost:6060/api/docs`
|
||||||
|
- OpenAPI JSON: `http://localhost:6060/api/openapi.json`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Running Tests
|
||||||
|
|
||||||
|
Always run tests before submitting a pull request.
|
||||||
|
|
||||||
|
**Frontend (Vitest):**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
just ui test # Run all tests
|
||||||
|
just ui coverage # With coverage report (output: coverage/)
|
||||||
|
```
|
||||||
|
|
||||||
|
**Backend (JUnit + Gradle):**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
just api test # Run all tests
|
||||||
|
just api test-class test_class=org.booklore.service.BookServiceTest # Specific class
|
||||||
|
just api coverage # Coverage report
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Building the Production Docker Image
|
||||||
|
|
||||||
|
To verify your changes in an environment identical to production, build and run the full Docker image
|
||||||
|
locally. The multi-stage `Dockerfile` compiles both the Angular frontend and the Spring Boot backend,
|
||||||
|
so no local toolchain is needed beyond Docker.
|
||||||
|
|
||||||
|
> **Note:** The first build downloads and caches dependencies in Docker layers. Subsequent builds are
|
||||||
|
> significantly faster.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
just image-build # Build the image
|
||||||
|
just db-up # Start only the database from the dev stack
|
||||||
|
just image-run # Run the production image against it
|
||||||
|
```
|
||||||
|
|
||||||
|
The application will be available at <http://localhost:6060>.
|
||||||
|
|
||||||
|
```bash
|
||||||
|
just db-down # Stop the database when done
|
||||||
|
just dev-down # Or stop the full stack if started with `just dev-up`
|
||||||
|
```
|
||||||
|
|
||||||
|
### Cross-platform builds
|
||||||
|
|
||||||
|
```bash
|
||||||
|
just image-build linux/arm64 grimmory:local-arm64
|
||||||
|
```
|
||||||
|
|
||||||
|
### Tips
|
||||||
|
|
||||||
|
- **Memory:** The image defaults to 60% of container RAM. Use `--memory=512m` to simulate constrained
|
||||||
|
environments.
|
||||||
|
- **Volumes:** Mount book directories to `/books`, data/config to `/app/data`, and an optional bookdrop
|
||||||
|
folder to `/bookdrop`.
|
||||||
|
- **Logs:** Use `docker logs -f grimmory-local` to follow application logs.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Branch Naming
|
||||||
|
|
||||||
|
Create branches from `develop` using these prefixes:
|
||||||
|
|
||||||
|
| Prefix | Use for | Example |
|
||||||
|
| ----------- | ------------------ | ---------------------------- |
|
||||||
|
| `feat/` | New features | `feat/epub-reader-support` |
|
||||||
|
| `fix/` | Bug fixes | `fix/book-import-validation` |
|
||||||
|
| `refactor/` | Code restructuring | `refactor/auth-flow` |
|
||||||
|
| `docs/` | Documentation | `docs/update-install-guide` |
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git checkout develop
|
||||||
|
git checkout -b feat/your-feature-name
|
||||||
|
```
|
||||||
|
|
||||||
|
> **Note:** Feature work targets `develop`. `main` is reserved for stable releases and release tags.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## Commit Messages
|
||||||
|
|
||||||
|
We follow [Conventional Commits](https://www.conventionalcommits.org/):
|
||||||
|
|
||||||
|
```
|
||||||
|
<type>(<scope>): <subject>
|
||||||
|
```
|
||||||
|
|
||||||
|
**Types:** `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore`, `perf`
|
||||||
|
|
||||||
|
**Examples:**
|
||||||
|
|
||||||
|
```
|
||||||
|
feat(reader): add keyboard navigation for page turning
|
||||||
|
fix(api): resolve memory leak in book scanning service
|
||||||
|
feat(auth)!: migrate to OAuth 2.1
|
||||||
|
|
||||||
|
BREAKING CHANGE: OAuth 2.0 is no longer supported
|
||||||
|
```
|
||||||
|
|
||||||
|
PR titles targeting `develop` or `main` must follow the same format. Release impact is derived from
|
||||||
|
commit type:
|
||||||
|
|
||||||
|
| Type | Release impact |
|
||||||
|
| ----------------------------------------------- | -------------- |
|
||||||
|
| `feat` | Minor |
|
||||||
|
| `fix`, `perf`, `refactor` | Patch |
|
||||||
|
| `docs`, `ci`, `build`, `chore`, `test`, `style` | Changelog only |
|
||||||
|
|
||||||
|
Feature work is squash-merged into `develop`. Do not expect a second squash from `develop` to `main` —
|
||||||
|
release automation depends on preserved conventional commit history.
|
||||||
@@ -175,15 +175,13 @@ Additional deployment examples:
|
|||||||
|
|
||||||
## Developer Surfaces
|
## Developer Surfaces
|
||||||
|
|
||||||
This repository contains two application projects:
|
|
||||||
|
|
||||||
- Backend: [`booklore-api/README.md`](booklore-api/README.md)
|
Contributor workflow, PR policy, and release semantics live in [CONTRIBUTING.md](CONTRIBUTING.md).
|
||||||
- Frontend: [`frontend/README.md`](frontend/README.md)
|
|
||||||
|
|
||||||
Contributor workflow, PR policy, and release semantics live in [CONTRIBUTING.md](CONTRIBUTING.md). Component-specific implementation guidance lives in:
|
General purpose development guidelines live in [DEVELOPMENT.md](DEVELOPMENT.md). Component-specific implementation guidance lives in:
|
||||||
|
|
||||||
- [`booklore-api/CONTRIBUTING.md`](booklore-api/CONTRIBUTING.md)
|
- [`booklore-api/DEVELOPMENT.md`](booklore-api/DEVELOPMENT.md)
|
||||||
- [`frontend/CONTRIBUTING.md`](frontend/CONTRIBUTING.md)
|
- [`frontend/DEVELOPMENT.md`](frontend/DEVELOPMENT.md)
|
||||||
|
|
||||||
The root [`Justfile`](Justfile) is the primary local command surface and mirrors the folder-local `booklore-api/Justfile` and `frontend/Justfile` entrypoints.
|
The root [`Justfile`](Justfile) is the primary local command surface and mirrors the folder-local `booklore-api/Justfile` and `frontend/Justfile` entrypoints.
|
||||||
|
|
||||||
|
|||||||
@@ -1,71 +0,0 @@
|
|||||||
# 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
|
|
||||||
```
|
|
||||||
|
|
||||||
## API Docs (`API_DOCS_ENABLED`)
|
|
||||||
|
|
||||||
- `application.yaml` binds `app.api-docs.enabled` to `API_DOCS_ENABLED` (default `false`).
|
|
||||||
- `application.yaml` binds `springdoc.api-docs.enabled` to `app.api-docs.enabled`.
|
|
||||||
- `application-dev.yml` enables docs for local dev profile runs by default.
|
|
||||||
- For runtime/container profiles, set `API_DOCS_ENABLED=true` to expose:
|
|
||||||
- `/api/openapi.json`
|
|
||||||
- `/api/docs`
|
|
||||||
|
|
||||||
## 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,134 @@
|
|||||||
|
# Grimmory API Development
|
||||||
|
|
||||||
|
This document is the canonical development guide for `booklore-api`. It covers the local command
|
||||||
|
surface, setup expectations, build and test workflows, and backend-specific conventions.
|
||||||
|
|
||||||
|
For repository-wide contribution policy, branch strategy, PR requirements, and release semantics, start
|
||||||
|
with [../CONTRIBUTING.md](../CONTRIBUTING.md). For repo-level environment setup and Docker workflows,
|
||||||
|
see [../DEVELOPMENT.md](../DEVELOPMENT.md).
|
||||||
|
|
||||||
|
## Project Scope
|
||||||
|
|
||||||
|
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 used by the production
|
||||||
|
container.
|
||||||
|
|
||||||
|
## Stack
|
||||||
|
|
||||||
|
- Java 25
|
||||||
|
- Spring Boot 4
|
||||||
|
- Gradle Wrapper
|
||||||
|
- Spring Data JPA + Flyway
|
||||||
|
- MariaDB in production, H2 for selected tests
|
||||||
|
- JUnit 5, Mockito, AssertJ, JaCoCo
|
||||||
|
|
||||||
|
## 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
|
||||||
|
just build # Build the backend jar
|
||||||
|
just tasks # Show available Gradle tasks
|
||||||
|
```
|
||||||
|
|
||||||
|
From the repository root, the same recipes are available through the `api` namespace:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
just api run
|
||||||
|
just api test
|
||||||
|
just api coverage
|
||||||
|
just api check
|
||||||
|
```
|
||||||
|
|
||||||
|
## Running Locally
|
||||||
|
|
||||||
|
The backend expects a MariaDB instance and a local `application-dev.yml` with your database and
|
||||||
|
storage paths. The common backend loop is:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd booklore-api
|
||||||
|
just run
|
||||||
|
```
|
||||||
|
|
||||||
|
If you need a different Spring profile:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
just run profile=local
|
||||||
|
```
|
||||||
|
|
||||||
|
Use the repo-level guide in [../DEVELOPMENT.md](../DEVELOPMENT.md) for the full Docker stack, MariaDB
|
||||||
|
setup, and cross-project local workflows.
|
||||||
|
|
||||||
|
## 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, frontend resources are optional.
|
||||||
|
|
||||||
|
## API Docs (`API_DOCS_ENABLED`)
|
||||||
|
|
||||||
|
- `application.yaml` binds `app.api-docs.enabled` to `API_DOCS_ENABLED` (default `false`).
|
||||||
|
- `application.yaml` binds `springdoc.api-docs.enabled` to `app.api-docs.enabled`.
|
||||||
|
- `application-dev.yml` enables docs for local dev profile runs by default.
|
||||||
|
- For runtime or container profiles, set `API_DOCS_ENABLED=true` to expose:
|
||||||
|
- `/api/openapi.json`
|
||||||
|
- `/api/docs`
|
||||||
|
|
||||||
|
## 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.
|
||||||
|
|
||||||
|
## 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 6 + 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.
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
# 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).
|
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
# Contributing to Grimmory UI
|
|
||||||
|
|
||||||
This document covers frontend-specific development and review expectations for `frontend`.
|
|
||||||
|
|
||||||
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 frontend recipes
|
|
||||||
just install # Install or update dependencies for local development
|
|
||||||
just install-ci # Install dependencies exactly as CI does
|
|
||||||
just dev # Start the local dev server
|
|
||||||
just test # Run frontend tests
|
|
||||||
just check # Run the standard local verification pass
|
|
||||||
just lint # Run the frontend linter
|
|
||||||
just build # Build the production bundle
|
|
||||||
```
|
|
||||||
|
|
||||||
From the repository root, the same recipes are available through the `ui` namespace:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
just ui install
|
|
||||||
just ui install-ci
|
|
||||||
just ui dev
|
|
||||||
just ui test
|
|
||||||
just ui check
|
|
||||||
just ui lint
|
|
||||||
```
|
|
||||||
|
|
||||||
## Frontend Conventions
|
|
||||||
|
|
||||||
- Follow the Angular style guide.
|
|
||||||
- All components are standalone. Do not add NgModules.
|
|
||||||
- Use `inject()` for dependency injection instead of constructor injection.
|
|
||||||
- Prefer PrimeNG components and project styling patterns over custom one-off UI primitives.
|
|
||||||
- Use SCSS for styling and keep the visual language consistent with the existing application.
|
|
||||||
- Use Transloco for user-facing strings. New strings belong under `src/i18n/`.
|
|
||||||
- Keep UI changes responsive for desktop and mobile layouts.
|
|
||||||
- Tests should use Vitest, not Karma or Jasmine.
|
|
||||||
|
|
||||||
## i18n and UI Copy
|
|
||||||
|
|
||||||
- Update all relevant locale files when adding or renaming translation keys.
|
|
||||||
- Keep translation-key changes separate from bulk JSON reformatting whenever practical.
|
|
||||||
- Prefer Grimmory naming for UI-visible labels and keys, while preserving compatibility shims only when they are still required by existing backend or migration behavior.
|
|
||||||
|
|
||||||
## Validation Before Opening a PR
|
|
||||||
|
|
||||||
Run the frontend checks locally before sending a PR:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
just install
|
|
||||||
just check
|
|
||||||
```
|
|
||||||
|
|
||||||
If your change affects layout, responsive behavior, or interaction design, also run the full stack locally and capture screenshots or a short screen recording for the PR.
|
|
||||||
|
|
||||||
If you specifically want to mirror the stricter CI dependency policy, run:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
just install-ci
|
|
||||||
just ci-check
|
|
||||||
```
|
|
||||||
@@ -0,0 +1,121 @@
|
|||||||
|
# Grimmory UI Development
|
||||||
|
|
||||||
|
This document is the canonical development guide for `frontend`. It covers the local command surface,
|
||||||
|
setup, build and test workflows, and frontend-specific conventions.
|
||||||
|
|
||||||
|
For repository-wide contribution policy, branch strategy, PR requirements, and release semantics, start
|
||||||
|
with [../CONTRIBUTING.md](../CONTRIBUTING.md). For repo-level environment setup and Docker workflows,
|
||||||
|
see [../DEVELOPMENT.md](../DEVELOPMENT.md).
|
||||||
|
|
||||||
|
## Project Scope
|
||||||
|
|
||||||
|
The `frontend` project is the Angular browser application for Grimmory. It owns client-side routing,
|
||||||
|
stateful UI interactions, component styling, localization, and the compiled bundle packaged into the
|
||||||
|
production image.
|
||||||
|
|
||||||
|
## Stack
|
||||||
|
|
||||||
|
- Angular 21
|
||||||
|
- TypeScript
|
||||||
|
- PrimeNG + PrimeIcons
|
||||||
|
- Transloco for i18n
|
||||||
|
- Vitest for unit tests
|
||||||
|
- Angular ESLint
|
||||||
|
- SCSS
|
||||||
|
|
||||||
|
## Preferred Command Surface
|
||||||
|
|
||||||
|
Use [`Justfile`](Justfile) when possible:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
just # List frontend recipes
|
||||||
|
just install # Install or update dependencies for local development
|
||||||
|
just install-ci # Install dependencies exactly as CI does
|
||||||
|
just dev # Start the local dev server
|
||||||
|
just test # Run frontend tests
|
||||||
|
just coverage # Run tests with coverage output
|
||||||
|
just check # Run the standard local verification pass
|
||||||
|
just ci-check # Run the stricter CI-style verification pass
|
||||||
|
just lint # Run the frontend linter
|
||||||
|
just build # Build the production bundle
|
||||||
|
```
|
||||||
|
|
||||||
|
From the repository root, the same recipes are available through the `ui` namespace:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
just ui install
|
||||||
|
just ui install-ci
|
||||||
|
just ui dev
|
||||||
|
just ui test
|
||||||
|
just ui coverage
|
||||||
|
just ui check
|
||||||
|
just ui lint
|
||||||
|
```
|
||||||
|
|
||||||
|
## Running Locally
|
||||||
|
|
||||||
|
For the normal frontend loop:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd frontend
|
||||||
|
just install
|
||||||
|
just dev
|
||||||
|
```
|
||||||
|
|
||||||
|
The dev server runs on `http://localhost:4200` by default.
|
||||||
|
|
||||||
|
If you need the full application stack, start the backend and database from the repository root with
|
||||||
|
`just dev-up` or use the repo-level manual setup in [../DEVELOPMENT.md](../DEVELOPMENT.md).
|
||||||
|
|
||||||
|
## Build and Test
|
||||||
|
|
||||||
|
```bash
|
||||||
|
just build
|
||||||
|
just test
|
||||||
|
just coverage
|
||||||
|
just check
|
||||||
|
just lint
|
||||||
|
```
|
||||||
|
|
||||||
|
The production output is written to `dist/grimmory/`. The backend packaging flow consumes that bundle
|
||||||
|
when building the all-in-one production image.
|
||||||
|
|
||||||
|
Use `just install-ci` and `just ci-check` when you need the stricter CI-style dependency and audit
|
||||||
|
flow from a clean install.
|
||||||
|
|
||||||
|
## Frontend Conventions
|
||||||
|
|
||||||
|
- Follow the Angular style guide.
|
||||||
|
- All components are standalone. Do not add NgModules.
|
||||||
|
- Use `inject()` for dependency injection instead of constructor injection.
|
||||||
|
- Prefer PrimeNG components and existing project styling patterns over custom one-off UI primitives.
|
||||||
|
- Use SCSS for styling and keep the visual language consistent with the existing application.
|
||||||
|
- Use Transloco for user-facing strings. New strings belong under `src/i18n/`.
|
||||||
|
- Keep UI changes responsive for desktop and mobile layouts.
|
||||||
|
- Tests should use Vitest, not Karma or Jasmine.
|
||||||
|
|
||||||
|
## i18n and UI Copy
|
||||||
|
|
||||||
|
- Update all relevant locale files when adding or renaming translation keys.
|
||||||
|
- Keep translation-key changes separate from bulk JSON reformatting whenever practical.
|
||||||
|
- Prefer Grimmory naming for UI-visible labels and keys, while preserving compatibility shims only when
|
||||||
|
they are still required by existing backend or migration behavior.
|
||||||
|
|
||||||
|
## Validation Before Opening a PR
|
||||||
|
|
||||||
|
Run the frontend checks locally before sending a PR:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
just install
|
||||||
|
just check
|
||||||
|
```
|
||||||
|
|
||||||
|
If your change affects layout, responsive behavior, or interaction design, also run the full stack
|
||||||
|
locally and capture screenshots or a short screen recording for the PR.
|
||||||
|
|
||||||
|
If you specifically want to mirror the stricter CI dependency policy, run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
just install-ci
|
||||||
|
just ci-check
|
||||||
|
```
|
||||||
@@ -1,74 +0,0 @@
|
|||||||
# Grimmory UI
|
|
||||||
|
|
||||||
The `frontend` project is the Angular frontend for Grimmory. It owns the browser application, component styling, client-side routing, stateful UI interactions, and the compiled bundle that is packaged into the current production image.
|
|
||||||
|
|
||||||
## Stack
|
|
||||||
|
|
||||||
- Angular 21
|
|
||||||
- TypeScript
|
|
||||||
- PrimeNG + PrimeIcons
|
|
||||||
- Transloco for i18n
|
|
||||||
- Vitest for unit tests
|
|
||||||
- Angular ESLint
|
|
||||||
|
|
||||||
## Local Command Surface
|
|
||||||
|
|
||||||
Use [`Justfile`](Justfile) when possible. It is the primary frontend command surface for both humans and agents.
|
|
||||||
|
|
||||||
```bash
|
|
||||||
just # List frontend recipes
|
|
||||||
just install # Install or update dependencies for local development
|
|
||||||
just install-ci # Install dependencies exactly as CI does
|
|
||||||
just dev # Start the Angular dev server
|
|
||||||
just test # Run the frontend test suite
|
|
||||||
just check # Run the standard local verification pass
|
|
||||||
just lint # Run the frontend linter
|
|
||||||
just build # Build the production bundle
|
|
||||||
```
|
|
||||||
|
|
||||||
The repository root exposes the same recipes through the `ui` namespace:
|
|
||||||
|
|
||||||
```bash
|
|
||||||
just ui install
|
|
||||||
just ui install-ci
|
|
||||||
just ui dev
|
|
||||||
just ui test
|
|
||||||
just ui check
|
|
||||||
just ui lint
|
|
||||||
```
|
|
||||||
|
|
||||||
## Running Locally
|
|
||||||
|
|
||||||
```bash
|
|
||||||
cd frontend
|
|
||||||
just install
|
|
||||||
just dev
|
|
||||||
```
|
|
||||||
|
|
||||||
The development server runs on port `4200` by default.
|
|
||||||
|
|
||||||
## Build and Test
|
|
||||||
|
|
||||||
```bash
|
|
||||||
just build
|
|
||||||
just check
|
|
||||||
just test
|
|
||||||
just coverage
|
|
||||||
just lint
|
|
||||||
```
|
|
||||||
|
|
||||||
The production output is written to `dist/grimmory/` and is consumed by the backend packaging flow when building the all-in-one production image.
|
|
||||||
|
|
||||||
Use `just ci-check` when you want the stricter CI-style flow from a clean install, including the severity-gated audit step.
|
|
||||||
|
|
||||||
## UI-Specific Notes
|
|
||||||
|
|
||||||
- This project uses standalone Angular components.
|
|
||||||
- Dependency injection should use `inject()`.
|
|
||||||
- Styling uses SCSS.
|
|
||||||
- UI strings live in `src/i18n/`.
|
|
||||||
- The current production bundle is still packaged into the backend jar during the root Docker build.
|
|
||||||
|
|
||||||
## More Detail
|
|
||||||
|
|
||||||
Frontend-specific contributor rules and conventions live in [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
||||||
Reference in New Issue
Block a user