0% found this document useful (0 votes)
6 views

SpringBoot_Coding_Challenges_With_Hints

The document outlines a series of Spring Boot coding challenges categorized by difficulty: easy, medium, and hard. Each challenge includes a brief description, hints for implementation, and suggests using various Spring features such as REST controllers, JPA, Actuator, and validation annotations. The challenges cover a range of topics including APIs for meter readings, customer data, billing systems, and security implementations.

Uploaded by

msrbharath
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

SpringBoot_Coding_Challenges_With_Hints

The document outlines a series of Spring Boot coding challenges categorized by difficulty: easy, medium, and hard. Each challenge includes a brief description, hints for implementation, and suggests using various Spring features such as REST controllers, JPA, Actuator, and validation annotations. The challenges cover a range of topics including APIs for meter readings, customer data, billing systems, and security implementations.

Uploaded by

msrbharath
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Spring Boot Coding Challenges - With Hints

Easy - Basic Meter Reading API

Challenge: Basic Meter Reading API

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.

Easy - Simple Customer API

Challenge: Simple Customer API

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.

Easy - Spring Boot Health Check

Challenge: Spring Boot Health Check

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.

Easy - DTO Validation

Challenge: DTO Validation

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.

Easy - Simple Scheduler

Challenge: Simple Scheduler

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.

Easy - Hello World REST App

Challenge: Hello World REST App

Create a basic Spring Boot REST API that returns a welcome message.
Spring Boot Coding Challenges - With Hints

Hint: Use @RestController with a GET endpoint returning a string.

Medium - Customer Billing Engine

Challenge: Customer Billing Engine

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.

Medium - Feature Toggle System

Challenge: Feature Toggle System

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.

Medium - Meter Reading Validation

Challenge: Meter Reading Validation

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.

Medium - Custom Exception Handling

Challenge: Custom Exception Handling

Use @ControllerAdvice to return structured error responses for various domain and validation errors.

Hint: Use @ControllerAdvice and @ExceptionHandler. Return ErrorResponse DTO with HTTP status.

Medium - REST API with Pagination and Sorting

Challenge: REST API with Pagination and Sorting

Create a pageable/sortable endpoint for meter readings or customers.

Hint: Use Pageable in controller method and return Page<T>. Configure default sort and size.

Medium - Upload and Parse CSV

Challenge: Upload and Parse CSV

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.

Hard - Multi-Tenant Billing System

Challenge: Multi-Tenant Billing System

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.

Hard - Kafka Consumer with Dead Letter Queue

Challenge: Kafka Consumer with Dead Letter Queue

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.

Hard - Dynamic Strategy Loader

Challenge: Dynamic Strategy Loader

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.

Hard - Task Scheduler with Retry and Idempotency

Challenge: Task Scheduler with Retry and Idempotency

Run billing tasks on a schedule. Ensure retry on failure and idempotency.

Hint: Use Spring Scheduler with retry logic. Store job status to ensure idempotency.

Hard - Role-Based Access Control

Challenge: Role-Based Access Control

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.

Hard - Testcontainers Integration Test

Challenge: Testcontainers Integration Test


Spring Boot Coding Challenges - With Hints

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.

You might also like