A tiny Spring Boot ‘profile’ microservice — Stage‑0 HNG backend

I built a minimal Spring Boot service for my HNG Stage‑0 backend task that returns a profile object plus a fun cat fact. The goal was to deliver a clear, runnable microservice in a few files so reviewers can quickly run and inspect the code.

What it d…


This content originally appeared on DEV Community and was authored by Sherif sani

I built a minimal Spring Boot service for my HNG Stage‑0 backend task that returns a profile object plus a fun cat fact. The goal was to deliver a clear, runnable microservice in a few files so reviewers can quickly run and inspect the code.

What it does

  • Exposes GET /me
  • Returns a JSON payload with status, a small user profile (name, role, links), a timestamp, and a cat fact fetched from https://catfact.ninja/fact

Architecture (short)

  • ProfileController — handles /me and returns a ProfileResponse DTO.
  • ProfileService — builds the profile and fetches the external cat fact using Java HttpClient.
  • Profile (domain) and ProfileResponse (DTO) — simple POJOs for shape and serialization.
  • Spring Boot entrypoint and a single minimal unit test to ensure application context loads.

Why this shape?

  • Minimal surface area: reviewers can audit the domain, controller, and service quickly.
  • External call isolated in the service so it’s easy to mock or replace.
  • Small codebase is ideal for early-stage tasks and focused feedback.

How to run locally

  • From the project root (uses the included Maven wrapper):
./mvnw spring-boot:run

What I learned / next steps

  • Keep services focused and small for fast review cycles.
  • Inject HttpClient (or a wrapper) to make the external API call testable and mockable.
  • Add structured error handling and logging for robustness.
  • Add unit tests that mock the cat-fact API and an integration test for the controller.

check the repository: here


This content originally appeared on DEV Community and was authored by Sherif sani


Print Share Comment Cite Upload Translate Updates
APA

Sherif sani | Sciencx (2025-10-22T19:46:26+00:00) A tiny Spring Boot ‘profile’ microservice — Stage‑0 HNG backend. Retrieved from https://www.scien.cx/2025/10/22/a-tiny-spring-boot-profile-microservice-stage%e2%80%910-hng-backend/

MLA
" » A tiny Spring Boot ‘profile’ microservice — Stage‑0 HNG backend." Sherif sani | Sciencx - Wednesday October 22, 2025, https://www.scien.cx/2025/10/22/a-tiny-spring-boot-profile-microservice-stage%e2%80%910-hng-backend/
HARVARD
Sherif sani | Sciencx Wednesday October 22, 2025 » A tiny Spring Boot ‘profile’ microservice — Stage‑0 HNG backend., viewed ,<https://www.scien.cx/2025/10/22/a-tiny-spring-boot-profile-microservice-stage%e2%80%910-hng-backend/>
VANCOUVER
Sherif sani | Sciencx - » A tiny Spring Boot ‘profile’ microservice — Stage‑0 HNG backend. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/10/22/a-tiny-spring-boot-profile-microservice-stage%e2%80%910-hng-backend/
CHICAGO
" » A tiny Spring Boot ‘profile’ microservice — Stage‑0 HNG backend." Sherif sani | Sciencx - Accessed . https://www.scien.cx/2025/10/22/a-tiny-spring-boot-profile-microservice-stage%e2%80%910-hng-backend/
IEEE
" » A tiny Spring Boot ‘profile’ microservice — Stage‑0 HNG backend." Sherif sani | Sciencx [Online]. Available: https://www.scien.cx/2025/10/22/a-tiny-spring-boot-profile-microservice-stage%e2%80%910-hng-backend/. [Accessed: ]
rf:citation
» A tiny Spring Boot ‘profile’ microservice — Stage‑0 HNG backend | Sherif sani | Sciencx | https://www.scien.cx/2025/10/22/a-tiny-spring-boot-profile-microservice-stage%e2%80%910-hng-backend/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.