Thanks to visit codestin.com
Credit goes to github.com

Skip to content

micro/blog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Micro Blog

A microblogging app built with Go Micro

Overview

A minimalist microblogging platform built with Go Micro. Share your thoughts and engage with the community.

Features

  • Microservices-based architecture (Users, Posts, Comments, Web)
  • Minimalist web UI (feed, profiles, login, signup)
  • Edit and delete your own posts (author-only controls)
  • Tagging, clickable tags, and tag-based browsing (/tags/:tag)
  • REST API for all major features
  • GitHub Actions CI for Go tests
  • Licensed under AGPL v3

Contents

Services

The project consists of the following microservices:

  1. Users: User management (create, read, update, delete)
  2. Posts: Post management (create, read, delete, list, tag management)
  3. Comments: Comment management (create, read, delete, list)
  4. Web: REST API and web app that uses all other services

Web UI

A minimalist web interface for the blog, located in web/static/:

  • index.html: Main feed, create posts, view posts and comments
  • login.html: User login page
  • signup.html: User registration page
  • profile.html: User profile, posts, and comments

Everything is server side rendered

Tag Features

The blog allows you to:

  • Add tags to posts
  • Remove tags from posts
  • Click tags on a post to browse posts with that tag
  • Filter the feed to show posts with a specific tag at /tags/:tag
  • Browse all available tags (API) or filter via UI

Notes

  • Tag add/remove from the web UI will redirect you back to the post page on success.
  • API/JSON clients receive JSON responses.

Editing & Deleting Posts

  • Authors can edit or delete their own posts on the post page.
  • Delete prompts for confirmation and then returns you to the feed.

Getting Started

Prerequisites

  • Go 1.24 or higher
  • Micro v5 (master branch)

To install Micro CLI:

go install go-micro.dev/v5/cmd/micro@master

Make sure that $GOPATH/bin (or $HOME/go/bin) is in your PATH so you can use the micro command.

Launching Services

Clone and cd into the blog directory and run it

micro run

Browse to http://localhost:8089

API Endpoints

Posts

  • GET /posts: List all posts
  • GET /posts/:id: Get a post by ID
  • POST /posts: Create a new post
    {
      "title": "Post title",
      "content": "Post content"
    }
  • PATCH /posts/:id: Update a post (author only)
    {
      "title": "Updated title",
      "content": "Updated content"
    }
  • DELETE /posts/:id: Delete a post (author only)

Comments

  • GET /comments: List all comments (optionally filter by post_id query param)
  • POST /comments: Add a comment
    {
      "content": "Comment content",
      "post_id": "post_id"
    }

Users

  • GET /users: List all users
  • GET /users/:id: Get a user by ID
  • POST /users: Create a new user
    {
      "name": "User Name"
    }
  • POST /signup: Register a new user (and log in)
    {
      "name": "username",
      "password": "plaintextpassword"
    }
  • POST /login: Log in as a user
    {
      "name": "username",
      "password": "plaintextpassword"
    }
  • POST /logout: Log out the current user
  • GET /users/me: Get the current session user info

Tags

  • POST /posts/:id/tags: Add a tag to a post
    {
      "tag": "tagname"
    }
  • DELETE /posts/:id/tags/:tag: Remove a tag from a post
  • GET /tags: Get all available tags
  • GET /tags?post_id=:id: Get tags for a specific post
  • GET /posts/by-tag/:tag: Get posts with a specific tag
  • GET /tags/:tag: HTML page showing posts filtered by tag (same template as the main feed)

Project Structure

blog/
├── comments/           # Comments service
│   ├── handler/        # Request handlers
│   ├── main.go         # Entry point
│   └── proto/          # Protobuf definitions
├── posts/              # Posts service
│   ├── handler/
│   ├── main.go
│   └── proto/
├── users/              # Users service
│   ├── handler/
│   ├── main.go
│   └── proto/
└── web/                # REST API and static web UI
    ├── main.go         # REST API server
    └── static/         # Static web UI (index.html, login.html, signup.html, profile.html)

About

A microblog built with Go Micro

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •