This document provides essential context, commands, and guidelines for AI agents operating in this codebase. The project is a search aggregator for Usenet indexers, built with Spring Boot (Java 17) and a legacy AngularJS frontend.
- NEVER commit code to git. Do not run
git add,git commit, orgit pushunder any circumstances. - NEVER delete failing tests unless explicitly told to do so by the user.
- NEVER ignore failing tests. If tests fail after your changes, fix them. Do not claim they are unrelated unless they were already failing before you started.
- Root Directory:
C:\Users\strat\IdeaProjects\nzbhydra2 - Core Logic:
core/src/main/java - Tests:
core/src/test/java - Frontend:
core/ui-src(Legacy Gulp/Bower/AngularJS) - Java Version: 17
- Build System: Maven (but prefer IntelliJ MCP tools -- see below)
Important:
coreis the primary module for backend logic.otherfolder should be ignored unless explicitly instructed otherwise.- ALWAYS use absolute paths for file operations.
Always prefer IntelliJ MCP tools over Maven CLI commands. Maven is only a fallback when MCP tools are unavailable or insufficient.
DO NOT USE intellij_search_in_files_by_text AS IT'S BUGGY
- Use
intellij_build_projectto compile and check for errors after edits. - Use
intellij_get_file_problemsto inspect a specific file for errors and warnings.
- Use
intellij_get_run_configurationsto list available run configurations. - Use
intellij_execute_run_configurationto run a test by its configuration name. - If no run configuration exists for the test you need to run, ask the user to create one in IntelliJ. Do not silently fall back to Maven.
- Use
intellij_search_in_files_by_textandintellij_search_in_files_by_regexfor code search. - Use
intellij_find_files_by_name_keywordto locate files by name. - Use
intellij_get_symbol_infoto inspect symbol declarations and documentation. - Use
intellij_list_directory_treeto explore directory structure (prefer overls/dir).
- Use
intellij_rename_refactoringfor renaming symbols (variables, methods, classes). This is far safer than text find-and-replace.
Use these only when IntelliJ MCP tools are unavailable. Run from the project root.
- Full Build:
mvn clean install - Build Core Only:
mvn -pl core clean install - Compile:
mvn compile
- Run All Core Tests:
mvn -pl core test - Run a Single Test Class:
mvn -pl core test -Dtest=ExternalApiTest - Run a Single Test Method:
mvn -pl core test -Dtest=ExternalApiTest#shouldCache
Always use the Context7 MCP tools when you need:
- Code generation, setup, or configuration steps
- Library or API documentation (Spring Boot, Mockito, AssertJ, Jackson, OkHttp, etc.)
- Correct syntax or usage patterns for any dependency
Resolve the library ID first, then fetch the relevant docs. Do this automatically without the user needing to ask.
- Formatting:
- Indentation: 4 spaces (no tabs).
- Braces: Same line (K&R / Java standard).
- Line length: Aim for <120 chars, but readability comes first.
- Naming:
- Classes:
PascalCase(e.g.,ExternalApi). - Methods/Variables:
camelCase(e.g.,handleCachingSearch). - Constants:
UPPER_SNAKE_CASE.
- Classes:
- Imports:
- Avoid wildcard imports (
import java.util.*;). - Sort alphabetically.
- Remove unused imports.
- Avoid wildcard imports (
- Annotations:
- Use Lombok for boilerplate (
@Data,@AllArgsConstructor,@Builder). - Use Spring stereotypes (
@Service,@RestController,@Autowired). - Use field injection unless constructor is already being used.
- Use Lombok for boilerplate (
- Error Handling:
- Use custom exceptions (e.g.,
ExternalApiException) where appropriate. - Use
@ExceptionHandlerin Controllers. - Log errors with Slf4j (
logger.error(...)) with context.
- Use custom exceptions (e.g.,
- Frameworks: JUnit 5 (Jupiter), AssertJ, Mockito.
- Location: Mirror the package structure of the implementation in
src/test/java. - Naming:
- Class:
TargetClassTest. - Methods: Descriptive camelCase, starting with
should(e.g.,shouldReturnCachedResult).
- Class:
- Structure:
setUp()annotated with@BeforeEach.- Use
@InjectMocksfor the testee and@Mockfor dependencies. - Always assert expected outcomes (don't just run and check for no exception).
- Use
assertThat(actual).isEqualTo(expected)(AssertJ style).
- The frontend is legacy AngularJS located in
core/ui-src. - Do not manually build frontend resources. A Gulp watch instance runs via the IntelliJ run configuration named "default" and automatically rebuilds frontend assets on change. Just edit the source files.
- IMPORTANT: If frontend resource changes are not taking effect, check whether the "default" run configuration is running in IntelliJ. If it is not running, ask the user to start it before proceeding.
- After editing frontend files, you may run Gulp tasks to verify the UI source compiles correctly. Useful tasks:
gulp scripts-- compiles/concatenates JavaScript files.gulp less-- compiles LESS stylesheets to CSS.- Run these from the
core/ui-srcdirectory (e.g.,npx gulp scripts).
- Minimize frontend changes unless necessary.
- Explore: Use
intellij_list_directory_treeorintellij_find_files_by_name_keywordto locate files. - Read: Always read file content before editing to understand context (imports, existing methods).
- Plan: If modifying logic, identify the relevant test class first.
- Edit:
- Use
editorwritetools. - Maintain existing style (4 spaces).
- Do not remove comments unless they are obsolete.
- Use
- Verify:
- Use
intellij_build_projectorintellij_get_file_problemsto check for compilation errors. - Use
intellij_execute_run_configurationto run the relevant test. If no run config exists, ask the user to create one. - If a test fails, analyze the output, fix the code/test, and rerun.
- Do not finish if tests are failing (unless they were failing before you started).
- Use
- NEVER commit -- leave all git operations to the user.
- JSON/XML:
Jacksonfor JSON,JAXBfor XML. - HTTP:
OkHttp3for external requests. - Database: Spring Data JPA with H2 (embedded).
Flywayfor migrations. - Utilities:
Guava(Strings,Sets,Stopwatch) andApache Commons(IO,Lang3). Prefer these over custom implementations. - Logging: Slf4j + Logback. Use
logger.debugfor high-volume tracing,logger.infofor significant events. - Caching: Caffeine.
- Resilience: Failsafe.