Spring Boot - REST API - ๐ฎ Mission: CodeQuest โ Become a Spring Boot API Wizard #187
akash-coded
started this conversation in
Tasks
Replies: 1 comment
-
**_`
`_** |
Beta Was this translation helpful? Give feedback.
0 replies
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.
-
๐ฎ Mission: CodeQuest โ Become a Spring Boot API Wizard
๐ BACKSTORY
NeoBoard is hiring backend engineers to power the galaxyโs most advanced task management system. You're selected to join the elite API Engineering Squad.
To graduate, you must build a Spring Boot-powered REST API โ clean, modular, and professional.
๐ ๏ธ YOUR TECH TOOLKIT
๐ LEVEL-UP: XP BONUS TASKS
โ Convert status string to an enum (
TaskStatus.PENDING,TaskStatus.DONE)โ Add endpoint
PUT /api/tasks/{id}to update task statusโ Use
ResponseEntity<?>with proper HTTP status codesโ Add simple validation (e.g., reject empty task title)
โ WHAT YOU NOW KNOW
โ Bootstrapping a Spring Boot API
โ Setting up controller, service, and model layers
โ Building and testing real HTTP endpoints
โ Coding using best practices followed in the industry
โ Organizing code like a backend engineer
You're now ready to teach and build real-world Spring Boot APIs with clarity and confidence.
Absolutely. Here's the **enhanced version** of the exercise with clear **approach, folder structure, file placement**, and **how to run** instructions โ all in a learner-friendly, gamified tone.๐ฎ Mission: CodeQuest โ Become a Spring Boot API Wizard
๐ BACKSTORY
NeoBoard is hiring backend engineers to power the galaxyโs most advanced task management system. You're selected to join the elite API Engineering Squad.
To graduate, you must build a Spring Boot-powered REST API โ clean, modular, and professional.
๐ ๏ธ YOUR TECH TOOLKIT
๐งญ OVERALL APPROACH
Your mission will follow this layered design pattern:
Each layer:
๐ PROJECT STRUCTURE
When you generate your Spring Boot project via [start.spring.io](https://start.spring.io):
๐ฆ
src/main/java/com/neoboard/taskapi/Create the following packages and place files accordingly:
๐งช FILE-WISE GUIDED BREAKDOWN
๐ข 1.
Task.java(MODEL)๐ Location:
com.neoboard.taskapi.model๐ข 2.
TaskService.java(SERVICE)๐ Location:
com.neoboard.taskapi.service๐ข 3.
TaskController.java(CONTROLLER)๐ Location:
com.neoboard.taskapi.controller๐ข 4.
TaskapiApplication.java(MAIN ENTRY POINT)๐ Location:
com.neoboard.taskapi๐ HOW TO RUN YOUR SPRING BOOT API
โ Inside Eclipse:
Right-click on
TaskapiApplication.javaSelect: Run As โ Java Application
Console shows:
โ By Terminal (if using Maven):
๐ HOW TO TEST YOUR API
Once running, your app will be available at:
http://localhost:8080/api/tasks๐งช Test Cases (Use Postman)
/api/tasks{"id":1,"title":"Fix bugs","status":"pending"}/api/tasks/api/tasks/1/api/tasks/1๐งผ BEST PRACTICES TO FOLLOW
@RestController@Controller+@ResponseBody/api/tasksnot/api/taskResponseEntity<?>"status"string โenum TaskStatus๐ LEVEL-UP: XP BONUS TASKS
TaskStatus.PENDING,TaskStatus.DONE)PUT /api/tasks/{id}to update task statusResponseEntity<?>with proper HTTP status codesโ WHAT YOU NOW KNOW
โ Bootstrapping a Spring Boot API
โ Setting up controller, service, and model layers
โ Building and testing real HTTP endpoints
โ Coding using best practices followed in the industry
โ Organizing code like a backend engineer
Itโs structured like a mission-based progression game, with each level introducing one or more Spring Boot API concepts. It includes:
Detailed explanation of concepts
Applications in real-world projects
Step-by-step code tasks
Embedded best practices and coding conventions
A compelling theme to sustain learner engagement
๐ฎ Mission: CodeQuest โ Become a Spring Boot API Wizard
๐ The Backstory
Youโve been hired as the Backend Engineer for NeoBoard, a futuristic digital task manager used by teams across the galaxy.
The mission? Build a Spring Boot-powered REST API from scratch.
Your journey includes:
Understanding key concepts
Implementing services step-by-step
Earning XP by building features
Reaching the final boss: a fully functioning REST API
๐งฉ The Game Map
๐งช XP Earned: 20
๐งฉ Level 6: Polish & Power Up
๐ฏ Tasks:
โ Add
PUT /api/tasks/{id}to update task statusโ Add response codes using
ResponseEntityโ Move strings like
"pending"to an enum calledTaskStatusโ Add validation: task ID should not be negative
โ Modularize packages:
controller,service,model๐ง Pro Tips Recap:
Use
@RestController+@RequestMapping("/api/xyz")Inject services using
@AutowiredAlways create a service layer, donโt dump logic in controllers
Stick to HTTP method conventions:
GET,POST,PUT,DELETEMaintain clean package structure (
model,service,controller)๐ The Final Boss
Youโve built a working REST API using Spring Boot.
You now understand:
Bootstrapping Spring apps
Writing clean model classes
Service and DI patterns
Building and testing REST APIs
๐ Bonus XP Challenges
Add in-memory DB support using H2
Add Swagger UI for API documentation
Create DTO classes to decouple model from API input
Add exception handling using
@ControllerAdviceExplore
@Validfor request validationLet me know if you'd like this in:
.docxprintable formatShared GitHub starter template
Auto-grading criteria sheet for classroom use
You're now ready to teach them Spring Boot APIs like a pro.
Absolutely. Here's a **creative, gamified, and comprehensive Spring Boot exercise** that both teaches and nudges learners toward building their first **real REST API**.Itโs structured like a mission-based progression game, with each level introducing one or more Spring Boot API concepts. It includes:
๐ฎ Mission: CodeQuest โ Become a Spring Boot API Wizard
๐ The Backstory
Youโve been hired as the Backend Engineer for NeoBoard, a futuristic digital task manager used by teams across the galaxy.
The mission? Build a Spring Boot-powered REST API from scratch.
Your journey includes:
๐งฉ The Game Map
๐ง Level 0: Spring Boot Bootcamp
๐ฏ Goal:
Understand what Spring Boot is and how to set it up.
๐ Concepts:
๐ Task:
neoboardSpring Webcom.neoboardtaskapiDownload, unzip, and import into Eclipse.
๐งช XP Earned: 0 (Warm-up)
๐งฉ Level 1: Define the Data Model
๐ฏ Goal:
Create a Java class (
Task) to represent a task.๐ Concepts:
๐
Task.java๐ง Pro Tip: Use
camelCasefor fields, PascalCase for class names.๐งช XP Earned: 10
๐งฉ Level 2: Service Layer Logic
๐ฏ Goal:
Create a service class to store and manage tasks.
๐ Concepts:
@Serviceto be injectable.๐
TaskService.java๐ง Pro Tip: Favor using
Listas abstraction, not concrete types likeArrayList๐งช XP Earned: 20
๐งฉ Level 3: Inject the Service
๐ฏ Goal:
Use
@Autowiredto injectTaskServiceinto the controller.๐ Concepts:
@Autowiredfor field or constructor-based injection.๐ง Best Practice:
Use constructor-based injection over field injection in large apps.
๐งฉ Level 4: The First API Controller
๐ฏ Goal:
Build REST endpoints using Spring annotations.
๐ Concepts:
@RestController@GetMapping,@PostMapping, etc.@RequestBody@PathVariable๐
TaskController.java๐ง Pro Tip: Keep controller methods thin. Let services do the logic.
๐งช XP Earned: 50
๐ฅ You can now access your API at:
GET /api/tasksPOST /api/tasksGET /api/tasks/{id}DELETE /api/tasks/{id}๐งฉ Level 5: Testing with Postman
๐ฏ Goal:
Simulate frontend using Postman to test your APIs.
http://localhost:8080/api/tasks{"id":1,"title":"Fix bugs","status":"pending"}http://localhost:8080/api/tasks๐งช XP Earned: 20
๐งฉ Level 6: Polish & Power Up
๐ฏ Tasks:
PUT /api/tasks/{id}to update task statusResponseEntity"pending"to an enum calledTaskStatuscontroller,service,model๐ง Pro Tips Recap:
@RestController+@RequestMapping("/api/xyz")@AutowiredGET,POST,PUT,DELETEmodel,service,controller)๐ The Final Boss
Youโve built a working REST API using Spring Boot.
You now understand:
๐ Bonus XP Challenges
@ControllerAdvice@Validfor request validationBeta Was this translation helpful? Give feedback.
All reactions