A real world backend API built with golang + grpc
Go/GRPC codebase containing RealWorld examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.
This codebase was created to demonstrate a fully fledged fullstack application built with golang/grpc including CRUD operations, authentication, routing, pagination, and more.
Using grpc-gateway as reverse-proxy server which translates a RESTful JSON API into gRPC.
Using Go to implement realworld backend server.
Using MySQL to store data.
The app listens and serves on 0.0.0.0:3000
.
docker-compose
$ docker-compose up -d
local
$ go run server.go # run grpc server
$ go run gateway/gateway.go # run grpc-gateway server
docker-compose
$ docker-compose run app make unittest
local
$ make unittest
$ make e2etest
Users and Authentication
POST /user/login
: Existing user loginPOST /users
: Register a new userGET /user
: Get current userPUT /user
: Update current userProfiles
GET /profiles/{username}
: Get a profilePOST /profiles/{username}/follow
: Follow a userDELETE /profiles/{username}/follow
: Unfollow a userArticles
GET /articles/feed
: Get recent articles from users you followGET /articles
: Get recent articles globallyPOST /articles
: Create an articleGET /articles/{slug}
: Get an articlePUT /articles/{slug}
: Update an articleDELETE /articles/{slug}
: Delete an articleComments
GET /articles/{slug}/comments
: Get comments for an articlePOST /articles/{slug}/comments
: Create a comment for an articleDELETE /articles/{slug}/comments/{id}
: Delete a comment for an articleFavorites
POST /articles/{slug}/favorite
: Favorite an articleDELETE /articles/{slug}/favorite
: Unfavorite an articleDeafult
GET /tags
: Get tags
E2E test
┌─────────────────────────┬───────────────────┬───────────────────┐
│ │ executed │ failed │
├─────────────────────────┼───────────────────┼───────────────────┤
│ iterations │ 1 │ 0 │
├─────────────────────────┼───────────────────┼───────────────────┤
│ requests │ 31 │ 0 │
├─────────────────────────┼───────────────────┼───────────────────┤
│ test-scripts │ 46 │ 0 │
├─────────────────────────┼───────────────────┼───────────────────┤
│ prerequest-scripts │ 17 │ 0 │
├─────────────────────────┼───────────────────┼───────────────────┤
│ assertions │ 345 │ 0 │
├─────────────────────────┴───────────────────┴───────────────────┤
│ total run duration: 17.5s │
├─────────────────────────────────────────────────────────────────┤
│ total data received: 8.73KB (approx) │
├─────────────────────────────────────────────────────────────────┤
│ average response time: 33ms [min: 10ms, max: 150ms, s.d.: 31ms] │
└─────────────────────────────────────────────────────────────────┘