blog

command module
v0.0.0-...-fd6360a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2026 License: GPL-3.0 Imports: 1 Imported by: 0

README ΒΆ

Go Report Card

πŸ“ 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

2️⃣ Configure Database

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

Documentation ΒΆ

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL