SpringBoot_Coding_Challenges_With_Hints
SpringBoot_Coding_Challenges_With_Hints
Create REST endpoints to add and retrieve energy meter readings. Validate input (non-null, correct format). Use
in-memory or H2 database.
Hint: Use @RestController, @PostMapping and Spring Data JPA for in-memory storage. Use H2 and add validation
annotations.
Build a CRUD API for customer data. Use Spring Data JPA. Add input validation for required fields like name and email.
Hint: Create a Customer entity, use Spring Data JPA repositories, and add input validation using javax.validation.
Create a simple /health endpoint that returns the status of your service. Use Spring Actuator.
Hint: Use Spring Boot Actuator to expose /actuator/health endpoint. Customize if needed.
Add validation annotations to your request DTOs. Create a global exception handler using @ControllerAdvice.
Hint: Use @Valid and javax.validation annotations. Add @ControllerAdvice for uniform error handling.
Schedule a job that logs a message every 10 seconds using Spring's @Scheduled annotation.
Hint: Use @Scheduled(cron = ...) in a @Component class. Enable scheduling in your config.
Create a basic Spring Boot REST API that returns a welcome message.
Spring Boot Coding Challenges - With Hints
Design and implement billing logic using different strategies. Each strategy should calculate based on readings. Use
Strategy Pattern.
Hint: Apply Strategy pattern for billing logic. Inject strategy into the service layer. Write unit tests for each strategy.
Build APIs to enable/disable features per user. Store toggles in DB. Add caching.
Hint: Store toggles in DB and cache them using Caffeine/Redis. Create a filter or AOP interceptor for toggle evaluation.
Write a custom validator to check for invalid meter reading data (e.g., future timestamps).
Hint: Create a custom annotation and implement ConstraintValidator interface. Handle exceptions globally.
Use @ControllerAdvice to return structured error responses for various domain and validation errors.
Hint: Use @ControllerAdvice and @ExceptionHandler. Return ErrorResponse DTO with HTTP status.
Hint: Use Pageable in controller method and return Page<T>. Configure default sort and size.
Allow uploading meter readings in CSV format. Parse and store them.
Spring Boot Coding Challenges - With Hints
Hint: Use MultipartFile, parse CSV using Apache Commons CSV or OpenCSV, and store readings in DB.
Design a multi-tenant energy billing platform supporting multiple suppliers. Ensure tenant isolation using discriminator or
schemas.
Hint: Use a discriminator column or schema-per-tenant. Load tenant context per request and isolate data.
Consume meter readings from Kafka. On processing failure, redirect message to DLQ topic. Expose DLQ content via
REST.
Hint: Use Spring Kafka with error handler. On failure, send message to DLQ topic. Use @KafkaListener.
Dynamically select and load billing strategies based on supplier configuration. Use Factory or Strategy pattern.
Hint: Create a factory that returns the correct BillingStrategy based on plan name or config.
Hint: Use Spring Scheduler with retry logic. Store job status to ensure idempotency.
Secure your APIs using Spring Security. Implement roles like ADMIN and USER with different access rights.
Hint: Use Spring Security with method-level security. Assign roles and protect APIs accordingly.
Write an integration test using Testcontainers with a real PostgreSQL or Kafka instance.
Hint: Write integration tests using JUnit and Testcontainers for real DB/Kafka. Use @DynamicPropertySource.