mirror of
https://github.com/imgfloat/server.git
synced 2026-02-04 19:29:26 +00:00
2.8 KiB
2.8 KiB
Repository Guidelines
Project Structure & Module Organization
- Java Spring Boot service under
src/main/java(controllers, services, repositories, models); configuration insrc/main/resources. - Frontend overlays and admin UI assets live in
src/main/resources/static/jsandsrc/main/resources/templates(Thymeleaf). - Tests are in
src/test/java; sample assets and previews are stored underassets/andpreviews/when running locally. - Marketplace seed content (if used) sits at the path pointed to
IMGFLOAT_MARKETPLACE_SCRIPTS_PATH, each withmetadata.json,source.js, optionallogo.png, andattachments/.
Build, Test, and Development Commands
make build/mvn compile: compile the application.make run: load.env(if present) and start the Spring Boot app on port 8080 with required env vars.make watch: recompile on source changes (needsentr); restart browser manually.make test/mvn test: run the full test suite.make package: clean build a runnable JAR.
Coding Style & Naming Conventions
- Java 17, Spring Boot 3.x. Follow standard Java conventions: 4-space indentation,
UpperCamelCasefor types,lowerCamelCasefor methods/fields, constants inUPPER_SNAKE_CASE. - Keep controllers thin, delegate logic to services, and favor immutable DTOs/records where possible.
- Place web assets next to related features (
static/jsmodules, matching templates). Use descriptive filenames (e.g.,broadcast/renderer.js). - Prefer constructor injection for Spring components; avoid field injection.
Testing Guidelines
- Use JUnit 5 with Mockito for unit tests; keep tests under
src/test/javamirroring package paths. - Name tests descriptively (
ClassNameTest, method names expressing behavior). - For changes touching overlays or asset handling, add tests for repository/service logic and handle edge cases (missing files, bad metadata).
- Run
make testbefore opening a PR; add targeted integration tests when altering controllers or WebSocket flows.
Commit & Pull Request Guidelines
- Commits: concise, present-tense summaries (
Fix script import domain validation). Group related changes; avoid noisy churn. - PRs: include a clear summary, linked issue (if any), test results, and screenshots/GIFs when UI changes affect admin or broadcast overlays.
- Call out any config/env changes (new required vars such as
IMGFLOAT_*) and migration steps.
Security & Configuration Tips
- Store secrets via environment variables (
.envonly for local dev). Required paths:IMGFLOAT_ASSETS_PATH,IMGFLOAT_PREVIEWS_PATH,IMGFLOAT_DB_PATH,IMGFLOAT_AUDIT_DB_PATH. - When seeding marketplace scripts, ensure
metadata.jsonis well-formed; attachment filenames must be unique per script. - Keep OAuth keys and token encryption keys (
IMGFLOAT_TOKEN_ENCRYPTION_KEY) in a secret manager for non-local environments.