Default WebApp template

Test project to build simple RESTful service based on OpenApi definitions defined in /api directory.


  • Configuration with Viper
  • Add support for flags (cobra?)
  • Version tags / Build info
  • Containerization
  • OpenApi code generation
  • REST server using echo.Echo
  • Middleware for REST endpoints
  • Picking structured logging library
  • Dummy Frontend SPA
  • Single Binary deployment with embedded SPA
  • Persistence storage
  • SearchStore capabilities

Directory layout

Directory Description
./.iac "infrastructure as code"
./api OpenAPI, gRPC contracts
./bin/<arch> Build output directory, grouped by architecture (eg: darwin, linux)
./cmd application main
./config application specific configuration
./internal project private libraries
./pkg project libraries
./scripts Shell scripts used in dev environment (env setup, automation etc)
./ui frontend as Single Page Application



  • Go 1.14+
  • Go Modules


  • Git (SCM)
  • Docker (containerization)
  • Unix based system (for scripts execution)
  • Javascript with React (for UI component development)
  • yarn (frontend package manager)
  • developer tools binaries installed on host


Image build
gomodroot=$(go list -m)
buildTime=$(date -u '+%Y-%m-%d %H:%M:%S %Z') && \
docker build \
  --build-arg VERSION=$(git describe --tags --always --dirty) \
  --build-arg GIT_COMMIT=$(git rev-list -1 HEAD) \
  --build-arg BUILD_TIME=$buildTime \
  --build-arg GO_MOD_ROOT=$gomodroot \
  -t macpla/webapp .
Docker run
docker run -p 8080:8080 --rm macpla/webapp
Local build
  1. build ui component (React App)
  1. build backend with embedded SPA.

optional steps

  • clean pack2 generated files
./scripts/ clean
  • openApi spec generation

Interacting with a Service

http://localhost:8080/ -- React landing Page

http://localhost:8080/api/v1/demoapp/.well-known/alive?full=1 -- backend health-check

Developer tools

deepmap/oapi-codegen - OpenAPI 3 client and server boilerplate generator for GO

mikefarah/yq - cli YAML preprocessor

openapi-generator-cli - all purpose node based OpenAPI generator used to generate frontend client

gobuffalo/packr/v2 - static files to Go embedding processor

Expand ▾ Collapse ▴



Package appbase is a template WebApp scaffolding backed with Go and React

Source Files


Path Synopsis
pkg/demoapp/rest Package restv1 provides primitives to interact the openapi HTTP API.
pkg/spa You can use the "packr clean" command to clean up this, and any other packr generated files.
pkg/spa/packrd You can use the "packr2 clean" command to clean up this, and any other packr generated files.