
π Go Blog Engine
A modular, full stack blog application built in Go, following Clean Architecture principles.
This project demonstrates a well structured backend serving a server side rendered frontend, with clear separation of concerns, CLI tooling, and database migrations.
β¨ Features
- User authentication & authorization
- Admin panel for content management
- Article CRUD operations
- Server-side rendered HTML using Go templates
- PostgreSQL-backed persistence
- Database migrations with Goose
- CLI powered application commands
- Modular architecture with clear boundaries
π§± Architecture Overview
The application follows a layered, modular structure inspired by Clean Architecture:
βββ cmd/ # CLI commands (serve, migrate, seed)
βββ internal/
β βββ domain/ # Core business entities
β βββ repository/ # Data access layer
β βββ service/ # Business logic
β βββ handler/ # HTTP handlers
β βββ middleware/ # HTTP middleware
βββ templates/ # Server-side HTML templates
βββ static/ # CSS, JS, assets
βββ migrations/ # Goose migration files
βββ config/ # Configuration management
Design Principles
- Clear separation between domain, service, and infrastructure
- Dependency direction pointing inward (core independent from frameworks)
- CLI based application lifecycle management
- Explicit database migrations
- Minimal global state
π Tech Stack
- Language: Go (1.18+)
- Architecture: Modular ServiceβRepository pattern
- Database: PostgreSQL
- Migrations: Goose
- CLI Framework: Cobra
- Frontend: Go HTML Templates
- Styling: Bootstrap 4
- Client-side Enhancements: jQuery
π Getting Started
Prerequisites
- Go 1.18+
- PostgreSQL (running locally or via Docker)
π§ Installation & Setup
1οΈβ£ Clone the Repository
git clone https://github.com/realwebdev/blog.git
cd blog
Ensure PostgreSQL is running.
Update config.yml with your database credentials:
database:
host: localhost
port: 5432
user: postgres
password: postgres
name: blog
3οΈβ£ Run Database Migrations
Initialize the database schema:
go run main.go migrate up
4οΈβ£ Seed Database (Optional)
Populate the database with sample users and articles:
go run main.go seed
β οΈ Default admin password is password123 unless ADMIN_PASSWORD environment variable is set.
5οΈβ£ Start the Server
go run main.go serve
Visit:
http://localhost:8080
(or the port defined in your configuration)
π Authentication
- Role based access control
- Admin only content management
- Secure password handling (bcrypt recommended if implemented)
π¦ CLI Commands
| Command |
Description |
serve |
Start HTTP server |
migrate up |
Apply database migrations |
migrate down |
Roll back migrations |
seed |
Populate database with sample data |
π§ͺ Testing
If applicable:
go test ./...
(Add this section only if you have test coverage β otherwise omit or clarify scope.)
π Design Decisions
- Server-side rendering chosen for simplicity and SEO-friendliness.
- Goose for migration version control.
- Cobra to separate application lifecycle commands cleanly.
- Clean Architecture to ensure framework-independent core logic.
π§ Future Improvements
- API versioning
- REST/JSON API alongside SSR
- Integration tests
- Structured logging
- Dockerized deployment
- CI/CD pipeline
- Pagination & search
- Caching layer (Redis)
π¨βπ» Purpose
This project showcases:
- Backend architecture design in Go
- Database migration management
- Clean separation of business logic
- Full stack Go application development