After being laid off, I was honestly just... bored.
I needed something to reignite my brain and keep me learning, so I decided to join the HNG.tech Internship 13. It’s known for its fast-paced learning environment — the kind that keeps you coding, debugging, and smiling at 2 a.m.
# The Task
The very first task was simple on the surface:
> Build an API endpoint using any (or favourite) stack that returns a JSON response.
But this wasn’t just about returning "Hello World"
.
The goal was to **show structure, clarity, and logic — the kind of detail that proves you can write maintainable code.
# The Flow
Here’s how I approached it — more like a layout of how everything connects:
- Auto-create the database The app first checks if a database exists.
- If not, it creates one automatically.
- This means after environment and dependencies setup no other tweaking is needed.
- Run Migrations if Missing Once the database is ready, it checks for tables.
- If migrations haven’t been run, it triggers them automatically.
- Think of it as Laravel saying, “Relax, I got this.”
- Seed Initial User Data After migrations, it seeds one user records.
- This only happens, if the tables are newly created.
- This enable user data to be fetched from either the database (if it already exists) or a hardcoded array inside the service.
- Service-Based Structure Instead of mixing logic in the controller, everything was handled by a Service class that communicates through an Interface.
- This keeps the controller clean and focused on HTTP flow.
- The service handles all the database logic, data preparation, and checks.
- API Response Design
I used a base
ApiResponse
class that structures every response.
- No hardcoded keys like
meta
ordata
. - Just clean, human-readable JSON output.
- Rate Limiting for Safety To avoid abuse, I added Laravel’s built-in throttle middleware directly to the route.
- By default, it allows 60 requests per minute.
- You can always tweak this later based on your needs.
# The Result
A simple endpoint — /api/me
— that returns user info, but beneath it lies a thoughtful system that:
- Creates what’s missing,
- Seeds what’s needed,
- Responds cleanly,
- And protects itself automatically.
# My Reflection
It might sound like a small API task, but the process reminded me of why I love backend engineering — it’s like solving tiny puzzles that make systems feel alive.
From being laid off to joining HNG13, this task became my way to stretch my brain again.
I’m now even more motivated to keep going deeper with each new challenge.
# Tech Stack
- Laravel 12+
- PHP 8+
- MySQL
- RESTful API principles
# What I Learnt
This task reminded me why I love creating solutions. I learnt more about how to structure a simple feature properly — from automating database setup and seeding to integrating an external API smoothly. It showed me how clean organization between controllers, services, and responses makes everything flow better. Most importantly, it reignited my excitement for coding after the layoff — turning a small task into something that feels alive and purposeful.
*# Link *
GitHub: the api repository
Live Endpoint: Live Api
Top comments (0)