๐ ๏ธ Spring Boot REST API: Semi-Guided Exercise - SmartCatalog API โ Stream, String and Spring in Action #194
akash-coded
started this conversation in
Tasks
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
๐ ๏ธ Spring Boot REST API: Semi-Guided Exercise
Project Title: SmartCatalog API โ Stream, String & Spring in Action
๐ฏ Objective
Youโll build a production-style Spring Boot REST API that manages a catalog of products.
The app will have three service implementations:
You'll explore:
@Controller,@Service,@Repository)๐ง Background Story
Imagine you work at a startup building the backend for a retail app called SmartCatalog.
The CTO wants:
Youโll impress them by giving three clean implementations of the same logic โ loop-based, stream-based, and string-focused.
๐ Project Folder Structure
๐งฑ Step-by-Step Tasks
Step 1: Scaffold Spring Boot Project
Use [start.spring.io](https://start.spring.io):
com.examplesmartcatalogapplication.properties)Step 2: Model Class
Create a
Productmodel with:id: intname: Stringprice: doublecategory: Stringdescription: StringUse Lombok annotations for boilerplate:
Step 3: Repository (optional for now)
Optional: For now, use hardcoded list in each service instead of DB.
๐ Implement the Services
๐ฏ Common Interface
๐งต Service 1: Traditional Loops
Fill using basic loops and conditionals.
๐ Service 2: Stream API Style
Use
stream(),map(),filter(),reduce(),collect()etc.โ๏ธ Service 3: String-Focused Logic
Focus on operations like:
startsWith,contains๐ Controller
โ๏ธ
application.properties๐งช Postman Test Scenarios
/api/products/stream/api/products/traditional/api/products/names/api/products/total/api/products/expensive/api/products/descriptionsEdge Cases:
category=Unknown๐ฅ Pro Tips & Nuggets
@Qualifierto inject specific implementationsList.of()for small immutable lists in demos.orElse(null)instead of Optional for beginners๐งฉ Challenge Extensions (Optional)
ProductDTOand use it instead ofProductdirectly in APIโ Outcome
Youโll deeply understand:
Beta Was this translation helpful? Give feedback.
All reactions