After getting to the penultimate stage in HNG12 internship earlier this year, my perfectionist tendencies cropped up again and this time I want to get to the ultimate stage. First though I have to start from the scratch so stage 0 it is.
The goal for Stage 0 was straightforward:
π Build a small backend application that returns some personal info β and something extra (Cats facts).
π Project Overview
This project, called Cat Facts API Integration, fetches random cat facts from the public Cat Facts API and combines them with basic user information.
It includes three simple endpoints:
-
/
β Root welcome route -
/health
β Health check -
/me
β My personal info + a random cat fact
All built with FastAPI, httpx, and a bit of structured logging.
π§© Project Structure
HNG13_simple_rest_stage_0/
βββ app.py
βββ app.log
βββ requirements.txt
βββ README.md
`
The app includes:
-
FastAPI
for routing and documentation -
httpx
for making async API requests -
logging
for monitoring -
CORS middleware
for flexible frontend integration if need be
π§ Endpoints Documentation
Method | Endpoint | Description |
---|---|---|
GET |
/ |
Root endpoint that returns a welcome message. |
GET |
/health |
Confirms that the API is healthy and reachable. |
GET |
/me |
Returns user info (email, name, stack) along with a random cat fact. |
π§ͺ Example Response
GET /me
json
{
"status": "success",
"user": {
"email": "afariogun.john2002@gmail.com",
"name": "John Afariogun",
"stack": "Python/FastAPI"
},
"timestamp": "2025-10-15T10:00:00Z",
"fact": "Cats sleep for around 70% of their lives."
}
π§° Running the App Locally
To test this project on your system:
bash
git clone https://github.com/johnafariogun/HNG13_simple_rest_stage_0
cd HNG13_simple_rest_stage_0
pip install -r requirements.txt
Then start the server:
bash
python app.py
Visit these URLs in your browser:
- http://127.0.0.1:8080
- http://127.0.0.1:8080/me
- http://127.0.0.1:8080/docs β to explore the auto-generated FastAPI documentation
You can checkout (mine)[https://hng13simplereststage0-production.up.railway.app/me]
πΈ OpenAPI Documentation
FastAPI automatically provides Swagger UI for your routes:
π§ Navigate to
/docs
Youβll see your/
,/health
, and/me
routes neatly documented β no extra setup needed!
π Deployment
So I deployed this on Railway
You can check out how to deploy a fastapi app on railway at the official docs
π‘ What I Learned
- How to set up a simple FastAPI app
- How to call external APIs asynchronously using
httpx
- How to implement logging and error handling
- How to structure JSON responses neatly
- The power of automatic documentation in FastAPI
- How to deploy using Railway
π Conclusion
Stage 0 may look simple, but itβs where the foundation for cleaner, production-ready APIs begins.
This project taught me how small things β like handling timeouts, errors, and logs β make a huge difference when building real backend systems.
Next step? Stage 1 of HNG 13, probably focusing on testing, deployment, and CI/CD π
π¨βπ» Author: John Afariogun
Stack: Python / FastAPI
GitHub: @johnafariogun
Email: afariogun.john2002@gmail.com
`
Top comments (0)