saravanan-paramasivam/java-groq-assistant icon
public
Published on 7/14/2025
java_groq_assistant

java groq using ollama

Rules
Models
Context
relace Relace Instant Apply model icon

Relace Instant Apply

relace

40kinput·32koutput
anthropic Claude 3.7 Sonnet model icon

Claude 3.7 Sonnet

anthropic

200kinput·8.192koutput
anthropic Claude 3.5 Sonnet model icon

Claude 3.5 Sonnet

anthropic

200kinput·8.192koutput
mistral Codestral model icon

Codestral

mistral

voyage voyage-code-3 model icon

voyage-code-3

voyage

voyage Voyage AI rerank-2 model icon

Voyage AI rerank-2

voyage

gemini Gemini 2.0 Flash model icon

Gemini 2.0 Flash

gemini

1048kinput·8.192koutput
ollama qwen2.5-coder 1.5b model icon

qwen2.5-coder 1.5b

ollama

32kinput·8.192koutput
openai OpenAI GPT-4o Mini model icon

OpenAI GPT-4o Mini

OpenAI

128kinput·16.384koutput
# Spring Boot Java Coding Rules and Best Practices

A comprehensive checklist and guide for writing clean, maintainable, and scalable Spring Boot applications.

---
## 🚀 1. Project Structure and Organization

- Use the standard package structure: `com.yourcompany.projectname`
- Organize by layer: `controller`, `service`, `repository`, `model`, `config`, `dto`, `exception`, `util`
- For large apps, consider **package-by-feature** (e.g., `user`, `order`, `payment`)
- Class Naming: `PascalCase`  
- Variable/Method Naming: `camelCase`  
- Avoid abbreviations and acronyms

---
## 🔧 2. Spring Boot Configuration

- Use `@ConfigurationProperties` over `@Value` for structured config
- Externalize all configuration in `application.yml` or `application.properties`
- Use Spring Profiles (`dev`, `test`, `prod`)
- Validate config with `@Validated`
- Fail fast on startup misconfigurations

---
## 🧠 3. Dependency Injection and Bean Management

- Prefer **constructor injection**
- Avoid field injection (`@Autowired` on fields)
- Be explicit with component scanning (define `basePackages`)
- Use `@Qualifier` when multiple beans of the same type exist

---
## 🧾 4. DTOs and Entities

- Never expose entity objects in API responses
- Use DTOs for both request and response payloads
- Use `ModelMapper` or `MapStruct` to handle mapping
- Validate incoming DTOs using `javax.validation` annotations and `@Valid`

---
## 🧰 5. Service and Repository Layer

- Keep services stateless
- Push reusable logic to utility/helper classes
- Use `interface + implementation` pattern for services and repositories
- Define transaction boundaries with `@Transactional` at the service layer

---
## 📡 6. Controller Layer

- Use `@RestController` for REST APIs
- Handle exceptions globally with `@ControllerAdvice`
- Always return DTOs or wrapper responses
- Use `ResponseEntity` for custom status codes and headers

---
## 🧪 7. Testing

- Unit test services and utilities with **JUnit + Mockito**
- Use `@SpringBootTest` for integration tests
- Test repositories using `@DataJpaTest`
- Use `MockMvc` or `WebTestClient` to test REST endpoints
- Isolate DB with Testcontainers if possible

---
## 🛡️ 8. Security and Validation

- Enable and configure **Spring Security**
- Use input validation to prevent injection and data corruption
- Hash passwords using `BCryptPasswordEncoder`
- Protect endpoints with proper authentication and authorization
- Enable CSRF and configure CORS as required

---
## 🧹 9. Code Quality and Maintainability

- Follow Java code conventions: indentation, braces, spacing, naming
- Use a linter and formatter (e.g., Checkstyle, Spotless)
- Use **Lombok** with care:
  - Avoid `@Data` on JPA entities
  - Prefer `@Getter`, `@Setter`, `@Builder` as needed
- Log using SLF4J: `LoggerFactory.getLogger(...)`
- Avoid using `System.out.println`
- Create and use custom exceptions

---
## ⚡ 10. Performance and Optimization

- Avoid N+1 query problems using `join fetch`, `@EntityGraph`
- Use caching with `@Cacheable`, Redis, or Caffeine
- Perform long-running tasks with `@Async` or Spring Batch
- Configure connection pooling (HikariCP is default)
- Profile and monitor the application with **Actuator**

---
## 🧭 Checklist Summary

- [ ] Use constructor injection
- [ ] Separate DTOs from entities
- [ ] Validate all incoming request data
- [ ] Write unit & integration tests
- [ ] Configure Spring Security properly
- [ ] Externalize all environment-specific config
- [ ] Avoid field injection and circular dependencies
- [ ] Use proper exception handling
- [ ] Monitor and profile using Actuator
- [ ] Document REST APIs with Swagger/OpenAPI

---

No Docs configured

Prompts

Learn more

No Prompts configured

Context

Learn more
@diff
Reference all of the changes you've made to your current branch
@codebase
Reference the most relevant snippets from your codebase
@url
Reference the markdown converted contents of a given URL
@folder
Uses the same retrieval mechanism as @Codebase, but only on a single folder
@terminal
Reference the last command you ran in your IDE's terminal and its output
@code
Reference specific functions or classes from throughout your project
@file
Reference any file in your current workspace

No Data configured

MCP Servers

Learn more

GitHub

npx -y @modelcontextprotocol/server-github

Filesystem

npx -y @modelcontextprotocol/server-filesystem ${{ secrets.saravanan-paramasivam/java-groq-assistant/saravanan-paramasivam/filemcp/PATH }}

MySQL

npx -y @benborla29/mcp-server-mysql