Mini project: ShopLite API skeleton
60 min · Beginner
Need help? Ask a tutor on WhatsApp (opens in a new tab)Every later module of this section adds one feature to the same project, so the skeleton you build now (folders, names, build and README) is the base the whole ShopLite REST API grows on.
What you'll build
You start a new repository, shoplite-api. Your Section 14 ShopLite projects stay as they are: their API design (resources, URLs, status codes) and the Section 13 business rules come over feature by feature in the next modules, now on Spring Boot. Generate the project with Spring Initializr, keep the main class in com.shoplite, and add one package per feature: product, category, customer, order, plus common for shared code. This layout is called package by feature.
The only endpoint so far is GET /api. It answers with the app's name and version as JSON, read from application.properties, so anyone can check which app and which version is running on an address. The project builds into one runnable jar, has a .gitignore that keeps build output and secrets out of Git, and a README that tells a stranger how to run it.
> .\mvnw clean package
...
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
...
[INFO] Building jar: C:\Users\asha\shoplite-api\target\shoplite-api-0.1.0.jar
...
[INFO] BUILD SUCCESS
> java -jar target/shoplite-api-0.1.0.jar
... : Starting ShopliteApiApplication v0.1.0 using Java 19.0.2 with PID 12500 (...)
... : Tomcat started on port 8080 (http) with context path '/'
... : Started ShopliteApiApplication in 4.933 seconds (process running for 6.165)
(in a second terminal)
> curl -i http://localhost:8080/api
HTTP/1.1 200
Content-Type: application/json
Content-Length: 41
Date: Fri, 16 Oct 2026 05:17:55 GMT
{"name":"shoplite-api","version":"0.1.0"}
> curl http://localhost:8080/api/products
{"timestamp":"2026-10-16T05:17:55.729Z","status":404,"error":"Not Found","path":"/api/products"}Requirements
- 1The project is generated by Spring Initializr: Maven, Java 17, Spring Boot 4.1.x, Jar, group
com.shoplite, artifactshoplite-api, dependency Spring Web. - 2The main class
ShopliteApiApplicationstays in the root packagecom.shoplite. - 3Packages
product,category,customer,orderandcommonexist undercom.shoplite, each with apackage-info.javasaying what it is for. - 4
application.propertiessetsspring.application.name=shoplite-apiandshoplite.api.version, filled from the pom's version. - 5
GET /apireturns{"name":"shoplite-api","version":"0.1.0"}with status 200, fromApiInfoControllerincom.shoplite.common. - 6
mvnw clean packagepasses thecontextLoadstest and buildstarget/shoplite-api-0.1.0.jar, which runs withjava -jar. - 7
.gitignoreexcludestarget/, IDE folders, logs and secret files;README.mdexplains the structure and how to run and package the app. - 8The code is pushed to a public GitHub repository named
shoplite-api.
Milestones
0/5 done · commit and push after each oneGenerate and run shoplite-api
mvnw spring-boot:runends withStarted ShopliteApiApplication, andcurl http://localhost:8080/gives a 404 JSON body.Add the feature packages
src/main/java/com/shoplitehasproduct,category,customer,orderandcommon, each with apackage-info.java.Name and version in application.properties
After
mvnw package, the jar'sapplication.propertiescontainsshoplite.api.version=0.1.0.GET /api returns the name and version
curl http://localhost:8080/apiprints{"name":"shoplite-api","version":"0.1.0"}.Package, document and push
java -jar target/shoplite-api-0.1.0.jaranswers/api, and the code is on GitHub with a README.
Build it in your own GitHub repository and push after each milestone. When everything works, mark the project as complete.
Extra challenges (optional)
Do any you like, each on its own branch, so your main project keeps working.
Add
"java"to the response: the Java version the app runs on, fromSystem.getProperty("java.version"), as a third record component.· easyRun the jar on port 9090 without changing any file, and update the README with that command.· easy
Write a test
ApiInfoControllerTeststhat starts the app with@SpringBootTest(webEnvironment = WebEnvironment.RANDOM_PORT)and checks that/apireturns version0.1.0.· medium
Solution
Opens when you add your repository link.
Finish up
Mark complete & continue
Next: Beans and the application context