Most tutorials teach Go APIs using frameworks.
I wanted to understand what really happens under the hood.
So I built a fully working blog API using only Goβs standard library (net/http), SQLite, and a simple deployment pipeline.
No frameworks. No magic. Just clean fundamentals.
π§ Why I Built This
As a developer coming from frameworks like Laravel, I kept asking:
- What does a framework actually do for me?
- Can I build a clean API without one?
- How does Go handle HTTP and concurrency at a low level?
This project is my answer.
βοΈ Tech Stack
-
Go (
net/http) β raw HTTP handling - SQLite (modernc.org/sqlite) β no external dependencies, pure Go
- sqlx β cleaner database interactions
- Nginx β reverse proxy
- systemd β process management
- GitHub Actions β CI/CD automation
π Project Structure
.
βββ main.go
βββ database/
β βββ db.go
βββ models/
β βββ post.go
βββ .github/
βββ workflows/
Key Idea:
Separate HTTP logic from database logic β even without a framework.
π API Endpoints
| Method | Endpoint | Description |
|---|---|---|
| GET | / |
Welcome message |
| GET | /posts |
List posts |
| POST | /posts |
Create post |
| GET | /posts/{id} |
Get one |
| PUT | /posts/{id} |
Update |
| DELETE | /posts/{id} |
Delete |
π₯ What Makes This Interesting?
1. No Router Library
Routing is handled manually:
- One handler per path
-
switch r.Methodhandles multiple HTTP verbs - URL params are extracted manually
This shows you what frameworks like Gin or Echo abstract away.
2. Manual JSON Handling
json.NewDecoder(r.Body).Decode(&post)
json.NewEncoder(w).Encode(post)
You control everything:
- Input validation
- Response format
- Error handling
3. Clean Separation of Concerns
Even without a framework:
Handler β Model β Database
- Handlers = HTTP logic
- Models = SQL queries
- Database = storage
4. SQLite Without CGO π€―
Using:
modernc.org/sqlite
Means:
- No C dependencies
- Easier deployment
- Works perfectly in CI/CD
5. Production-Style Deployment
This is where most tutorials stop β but this project goes further.
π Deployment Flow
git push origin main
β
GitHub Actions
β
SSH into VPS
β
git pull + build
β
systemctl restart
β
Live π
β‘ What I Learned
π§© 1. Frameworks Hide Complexity
Things Laravel does automatically:
- Routing
- Request parsing
- Validation
- ORM abstraction
In Go, you do it yourself β and thatβs how you really learn.
π§ 2. net/http Is More Powerful Than Expected
With just:
http.HandleFunc()
http.ListenAndServe()
You can build a complete API.
β οΈ 3. You Must Be Careful
No framework means:
- You handle errors manually
- You manage structure yourself
- You enforce best practices
π 4. DevOps Matters More Than Code
The biggest upgrade in this project wasnβt CRUD.
It was:
- systemd auto-restart
- Nginx reverse proxy
- CI/CD pipeline
Thatβs what makes it real-world ready.
π If I Improve This Further
Next steps I would take:
- Add middleware (logging, auth)
- Use a router (like chi or gin)
- Add validation layer
- Introduce environment configs
- Add Docker support
π‘ Final Thoughts
If you're learning Go:
π Donβt start with frameworks
π Start with net/http
Because once you understand this levelβ¦
You can use any framework with confidence.
π¨βπ» Source Code
(You can link your GitHub repo here)
π Letβs Connect
If you're also learning Go or building APIs, Iβd love to hear how you're approaching it.
β If this helped you, consider sharing it!
Top comments (0)