Overview
Weave is a Go + Vue3 application starter that is designed to be simple yet functional. It is supported by various technologies including gin, gorm, redis, postgres, vue, element-plus, websocket, and more. Weave provides server support features such as a RESTful API, MVC structure, Postgres storage, Swagger documentation, structured log, Prometheus monitor, PProf debug, graceful shutdown, authentication with JWT, request rate limit, OAuth login, Redis cache, RBAC support, and container application management with support for Docker and Kubernetes. On the frontend, Weave offers features such as Vue3 support, UI with element-plus, integration with charts using echarts, WebShell support, Windi CSS, OAuth login, web code editor with support for codemirror, Markdown preview and editor, and more.
Features
Server support features:
- Restful API built with gin
- MVC structure
- Postgres storage using gorm
- Swagger documentation with swag
- Structured log using logrus
- Prometheus monitor
- PProf debug
- Graceful shutdown
- Authentication with support for JWT
- Request rate limit at both server and user IP level
- OAuth Login and password hashing
- Redis cache
- RBAC support
- Container application management with Docker and Kubernetes
Frontend support features:
- Vue3 support
- UI with element-plus
- Build with vite
- Charts integration using echarts
- WebShell support
- Windi CSS
- OAuth Login
- Web code editor with codemirror
- Markdown preview and editor
Installation
Before starting, make sure you have golang, Docker, and Node.js installed in your development environment.
Run server
Environment:
- golang (1.18 or later)
Install dependencies:
go get -u github.com/swaggo/swag
go get -u github.com/gin-gonic/gin
go get -u github.com/jinzhu/gorm
go get github.com/gin-contrib/cors
go get github.com/swaggo/gin-swagger
go get github.com/swaggo/gin-swagger/swaggerFiles
go get github.com/swaggo/gin-swagger/swaggerFiles
go get github.com/sirupsen/logrus
go get github.com/go-redis/redis
go get github.com/prometheus/client_golang/prometheus
go get golang.org/x/time/rate
To run the server locally:
go run main.go
To run the server in Docker:
docker-compose up
For Windows, you can manually run the script in Makefile.
Test API
To test the API, visit http://localhost:8080/index and see more API documentation at http://localhost:8080/swagger/index.html#/
Register user and login
- Register user
- Login to get JWT token
- Only admin users can access any APIs, other users need to create RBAC policy
- Set the token in the Authorization header
Get users
To get users, make the following request:
GET /users
Run UI
Assuming you have installed Node.js, run the UI with mockjs.
If your frontend is deployed remotely, please change server.host
and server.https
in vite.config.js.
To run the UI:
make ui
Default admin user credentials: admin/123456 or demo user credentials: demo/123456
Only admin users can access all APIs, other users must configure RBAC.
Explore the UI at http://127.0.0.1:8081
To run the frontend in Docker:
docker-compose -f docker-compose.ui.yml up
Summary
Weave is a Go + Vue3 application starter that provides a range of features for building web applications. It offers server support features such as a RESTful API, database storage, logging, monitoring, authentication, rate limiting, and more. On the frontend, it offers UI components, chart integration, and tools for code editing and Markdown editing. The installation process involves setting up the server, testing the API, and running the UI locally or in Docker. Weave is a versatile tool for building web applications in Go and Vue3.