This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
The Spring Boot backend for WiseMapping — a REST API + persistence + auth layer that the separately-versioned frontend (wisemapping-frontend) consumes. Single-module Maven project under wise-api/. Java 27, Spring Boot 4.1.x, JPA/Hibernate.
The frontend is not in this repo. Local dev requires checking out https://github.com/wisemapping/wisemapping-frontend separately and pointing it at this API (see README "Option 2").
All commands below run against wise-api/pom.xml. The repo has no parent POM — invoke Maven with -f wise-api/pom.xml from the root, or cd wise-api first.
mvn -f wise-api/pom.xml package # full build (fat jar at wise-api/target/wisemapping-api.jar)
mvn -f wise-api/pom.xml package -DskipTests # skip tests
cd wise-api && mvn spring-boot:run # run locally on :8080 (HSQLDB in-memory by default)
# Tests (JUnit 5 via surefire)
cd wise-api && mvn test
cd wise-api && mvn test -Dtest=MindmapControllerTest # single class
cd wise-api && mvn test -Dtest=MindmapControllerTest#shouldCreateMap # single method
# Run with an external config override (preferred way to point at PostgreSQL/MySQL/SMTP/etc.)
java -jar wise-api/target/wisemapping-api.jar \
--spring.config.additional-location=path/to/app.yml
# Full stack via Docker (HSQLDB in-memory, builds fat jar first)
mvn -f wise-api/pom.xml package
docker compose up --build # uses distribution/app-postgresql/docker-compose.yml if invoked from there
# PostgreSQL stack
cd distribution/app-postgresql && docker compose up --buildDefault seed credentials in dev: test@wisemapping.org / test.
wise-api/src/main/resources/application.yml holds defaults for every feature. Don't edit it for environment-specific values — override via Spring's external config (--spring.config.additional-location=...) or environment variables. Example overlays live in config/database/ (e.g. app-postgresql.yaml).
Key namespaces (read application.yml before changing behavior):
spring.datasource— defaults to embedded HSQLDB. Switch topostgresql/mysql/mariadbby overriding driver/url/username/password; the matchingschema-*.sqlanddata-*.sqlundersrc/main/resources/are auto-applied. Reference overlays live underdistribution/app-{postgresql,mysql,mariadb}/app.yml.spring.security.oauth2.client— Google/Facebook OAuth2, plus a generic OpenID Connect provider under the registration idoidc(seedoc/oidc/README.md); client IDs/secrets are expected to be supplied via overlay. Configuringoidcdisables database email/password login, self-registration and password reset by design (LocalLoginPolicy), so every login goes through the identity provider.spring.ldap+app.security.ldap— LDAP auth (seedoc/ldap/README.md). Disabled by default.app.jwt— JWT signing key + expiration (used byJwtTokenUtil,JwtAuthController).app.site.*— base URLs the API embeds in emails and OAuth redirects.management.*— Actuator, Prometheus, OpenTelemetry. Spam detection, history cleanup, and inactive-user/inactive-map cleanup are scheduled jobs configured here too.
Layered Spring Boot app. Entry point: com.wisemapping.Application.
rest/—@RestControllerHTTP surface. One controller per top-level resource:AccountController,MindmapController,LabelController,AdminController,UserController,JwtAuthController,OAuth2Controller,AppController(the last serves the runtime config blob the frontend consumes at/api/restful/app/config— includinganalyticsAccount, OAuth URLs, recaptcha, registration flag). DTOs live inrest/model/.service/— Business logic.MindmapService(CRUD + history + collaboration),UserService,LabelService,MailerService,RecaptchaService,NotificationService. The spam pipeline is a separate cluster:SpamDetectionService,SpamDetectionBatchService,SpamUserSuspensionService, plus strategies underservice/spam/. History retention is implemented as a chain-of-responsibility:HistoryCleanupHandler→Phase1HistoryCleanupHandler→Phase2HistoryCleanupHandler, driven byHistoryPurgeService.security/— Spring Security wiring.AuthenticationProvider(DB) andAuthenticationProviderLDAPplug in based on config. JWT is the session mechanism (JwtTokenUtil); OAuth2 success funnels throughOAuth2AuthenticationSuccessHandler. Map-level authorization is AOP-based:MapPermissionsSecurityAdvice+ReadSecurityAdvise/UpdateSecurityAdviseintercept service methods and enforceMapAccessPermissionagainstCollaboration/CollaborationRolerecords. Don't bypass these by calling DAOs directly from controllers.model/— JPA entities (Mindmap,Account,Collaboration,MindmapLabel,MindMapHistory, etc.) plus enums likeCollaborationRole,SpamStrategyType,SuspensionReason.dao/— Repositories.mindmap/— Mind-map XML domain (parsing/serializing the on-disk format, validated againstmindmap.xsd).scheduler/—@Scheduledjobs (history purge, inactive-user/inactive-map cleanup, spam batch).filter/— Servlet filters;MindmapFilterinrest/handles per-request map context for permission advice.listener/,metrics/— JPA event listeners and Micrometer metrics; OTLP + Prometheus exporters are wired inpom.xml.config/—AppConfig(top-level beans),GlobalExceptionHandler(consistent JSON error responses),LdapProperties.
Cross-cutting things to know:
- Caching: Hibernate L2 cache via EHCache (
ehcache.xml). Adding a@Cacheableentity/region requires an entry there. - i18n: User-facing strings live in
messages_*.properties(resolved by SpringMessageSource). Email templates use Velocity (mail/). - Spam: Detection runs both on write (
SpamDetectionServiceinvoked fromMindmapServiceImpl) and as a scheduled batch. Keyword/domain lists ship inresources/spam/anddisposable-email-domains.txt. - Resilience4j: Used to circuit-break external calls (recaptcha, mail). Configured under
resilience4j.*inapplication.yml.
distribution/api/Dockerfile— image for the API jar.distribution/app/Dockerfile+nginx.conf+supervisord.conf— combined image (nginx serving the prebuilt frontend + the API behind it). This is what production uses.distribution/app-postgresql/docker-compose.yml— reference compose for PostgreSQL deployment, with a sample overlay atapp.yml.
The README directs production users to the published images on Docker Hub (wisemapping/wisemapping) rather than building locally.
Patterns observed across the existing code — match them when adding new files. These are not enforced by tooling, so they're easy to break by accident.
License header — every .java file starts with the WiseMapping Public License v1.0 block (Copyright [2007-2025] [wisemapping], links to LICENSE.md). Copy verbatim from any existing file (e.g. rest/MindmapController.java). New files without it will be inconsistent and may fail review.
Package layout & naming
- Controllers in
rest/, suffixController. DTOs returned/accepted by controllers live inrest/model/and are distinct from JPA entities inmodel/— never return entities from a controller. - Services follow an interface +
*Implsplit (MindmapService/MindmapServiceImpl). The interface is the injection target. - Exceptions extend
ClientException(→WiseMappingException); each carries aMSG_KEYconstant that resolves through the message bundle (see i18n below). - Nullability is annotated with
org.jetbrains.annotations.@NotNull/@Nullable(notjakarta.annotation, notjavax). Apply on parameters and return types.
Dependency injection — @Autowired field injection is the existing house style (see MindmapServiceImpl, GlobalExceptionHandler). Stay consistent within a file. Service classes are @Service("beanName") with an explicit qualifier name.
Transactions — @Transactional lives at the service layer (typically class-level on *Impl, with Propagation.REQUIRED). Do not put @Transactional on controllers or DAOs.
Authorization — Map-scoped operations are guarded by @PreAuthorize on service methods, evaluated by MapPermissionsSecurityAdvice against Collaboration records. New methods that touch a Mindmap must declare a @PreAuthorize rule; never enforce permissions inline in the controller.
Logging — SLF4J. Declare as private static final Logger logger = LoggerFactory.getLogger(Foo.class); (the field name is logger, not log or LOG). Use parameterized messages (logger.warn("msg {}", id)), never string concatenation. No System.out / printStackTrace.
i18n (user-facing strings)
- All messages shown to end users go through
src/main/resources/messages*.properties. The base bundle ismessages.properties(English defaults); per-locale files aremessages_<lang>.propertiesforar de en es fr hi it ja pt ru uk zh zh-CN. Adding a new key requires updating every locale file (English first, others can copy English until translated). - The integration point is
ClientExceptionsubclasses: each definesprivate static final String MSG_KEY = "..."matching a properties key, andGlobalExceptionHandlerresolves it viaMessageSourceusing the requestLocale. To add a user-visible error, write a newClientExceptionsubclass with aMSG_KEY, add the key to every bundle, and let the global handler render it. - Email templates are Velocity files under
resources/mail/and use the same bundle for substitutions. Don't hardcode strings in templates. - Server logs and exception messages passed to other services are not localized — keep those English.
Validation — input validation belongs in validator/ (@Component-based validators like MapInfoValidator, HtmlContentValidator). Throw ValidationException / HtmlContentValidationException with a MSG_KEY rather than returning error strings.
SQL & schema — schema lives in schema-{hsqldb,mysql,mariadb,postgresql}.sql and seed data in data-*.sql. A schema change must be applied to all four dialect files; CI runs against HSQLDB but production is PostgreSQL. schema-mariadb.sql / data-mariadb.sql should normally be kept in lockstep with the MySQL variants.
To ensure cross-platform consistency and resolve encoding/case-sensitivity issues (ref: Issue #69), follow these standards:
- Naming Convention: All table and column names must be lowercase. (Linux environments are case-sensitive; lowercase ensures compatibility with Hibernate's default naming strategy).
- MySQL Encoding: Always use
CHARACTER SET UTF8MB4for MySQL tables and string columns to support emojis and international characters. - Data Type Mapping Table:
| Logical Type | MySQL | PostgreSQL | HSQLDB | Typical Usage |
|---|---|---|---|---|
| Primary Key (Auto) | INTEGER ... AUTO_INCREMENT |
SERIAL |
INTEGER ... IDENTITY |
Database IDs (Collaborator, Mindmap, etc.) |
| Dates & Times | DATETIME |
TIMESTAMP |
DATETIME |
Creation, modification, and activation dates |
| Booleans | BOOL (TinyInt) |
BOOL |
BOOLEAN |
Flags (isPublic, suspended, allowSendEmail) |
| Large Text | MEDIUMTEXT |
TEXT |
LONGVARCHAR |
JSON settings, OAuth tokens, long descriptions |
| Large Binary | MEDIUMBLOB |
BYTEA |
LONGVARBINARY |
Compressed Mindmap XML and history snapshots |
| Standard String | VARCHAR(255) |
VARCHAR(255) |
VARCHAR(255) |
Titles, emails, names, and identifiers |
Note: MEDIUMTEXT/MEDIUMBLOB (16MB) is preferred over TEXT/BLOB (64KB) for MySQL to prevent truncation of large mindmaps or user settings.
Spam allowlist — trusted source domains live in resources/spam/popular-domain-whitelist.yml. Bare entries match the exact host; use "*.example.com" for subdomain wildcards (existing pattern). Group additions under a comment header by region/category.
Tests — JUnit 5 (junit-vintage-engine is excluded; don't import JUnit 4). Spring Boot test slices preferred over full-context tests when possible. Test class naming mirrors the SUT: FooService → FooServiceTest.
Documenting changes — a change is not done until it is documented.
- Changelog: every functional change (feature, bug fix, security fix, breaking change, behavior or configuration change an operator would notice) adds an entry under
## [Unreleased]→### 🔧 Backend (wisemapping-open-source)inCHANGELOG.md, in the matchingSecurity & Privacy/Features/Bug Fixes/Maintenancesubsection. Follow the existing style: a bold title, then what changed and why it matters to users or operators. Pure refactors and test-only changes need no entry. Use theupdate-changelogskill to regenerate the section before a release. - Docs: a change to configuration, deployment or authentication updates the doc that owns the topic (
doc/<topic>/README.md,distribution/<variant>/README.md, the comments inapplication.yml). Keep one source per topic and link to it rather than copying it.distribution/app/README.mdis the Docker Hub page: keep it short, link to the repo with absolute GitHub URLs, and paste it to Docker Hub by hand at release (no workflow syncs it). - Breaking changes (removed features, config keys, data migrations) also need upgrade instructions in the changelog entry.
doc/api-documentation/— REST API reference + backend specifics (telemetry, OpenAPI).doc/oidc/README.md— generic OpenID Connect login (Keycloak, Authentik, Okta...).doc/ldap/README.md— LDAP setup. Theapp.security.ldapblock inapplication.ymlis heavily commented and is the source of truth.