Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add Monolithic Application example, including frontend and back… #42

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
59 changes: 31 additions & 28 deletions README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,34 @@

[English](README.md) | 简体中文

| 项目名 | 说明 |
|------------------------------|----------------------------------|
| [auth/jwt](./auth/jwt) | JWT使用示例 |
| [blog](./blog) | 博客系统,简单的CRUD示例 |
| [casbin](./casbin) | JWT认证和Casbin鉴权的示例 |
| [chatroom](./chatroom) | 最简单的Websocket聊天室示例 |
| [config](./config) | 文件配置和远程配置中心使用示例 |
| [cqrs](./cqrs) | CQRS模式实现示例,主要是Kafka的使用。 |
| [errors](./errors) | 错误处理示例 |
| [event](./event) | 使用Kafka等MQ收发消息示例 |
| [header](./header) | 自定义HTTP的Header示例 |
| [helloworld](./helloworld) | RPC调用示例 |
| [http](./http) | HTTP相关应用的示例,如:CORS、上传文件等。 |
| [i18n](./i18n) | 国际化与本地化的示例 |
| [log](./log) | 日志使用示例 |
| [metadata](./metadata) | 元数据使用示例 |
| [metrics](./metrics) | 度量系统使用示例 |
| [middleware](./middleware) | 中间件使用示例 |
| [realtimemap](./realtimemap) | 实时公交地图,主要是MQTT、Websocket、RPC综合使用 |
| [registry](./registry) | 注册中心使用示例 |
| [selector](./selector) | 节点选择器使用示例 |
| [stream](./stream) | |
| [swagger](./swagger) | swagger api使用示例 |
| [tls](./tls) | TLS证书使用示例 |
| [traces](./traces) | 链路追踪系统使用示例 |
| [transaction](./transaction) | 数据库事务使用示例 |
| [validate](./validate) | Protobuf参数校验器使用示例 |
| [ws](./ws) | 最简单的Websocket示例 |
| 项目名 | 说明 |
| ---------------------------- | -------------------------------------------------- |
| [auth/jwt](./auth/jwt) | JWT 使用示例 |
| [blog](./blog) | 博客系统,简单的 CRUD 示例 |
| [casbin](./casbin) | JWT 认证和 Casbin 鉴权的示例 |
| [chatroom](./chatroom) | 最简单的 Websocket 聊天室示例 |
| [config](./config) | 文件配置和远程配置中心使用示例 |
| [cqrs](./cqrs) | CQRS 模式实现示例,主要是 Kafka 的使用。 |
| [errors](./errors) | 错误处理示例 |
| [event](./event) | 使用 Kafka 等 MQ 收发消息示例 |
| [header](./header) | 自定义 HTTP 的 Header 示例 |
| [helloworld](./helloworld) | RPC 调用示例 |
| [http](./http) | HTTP 相关应用的示例,如:CORS、上传文件等。 |
| [i18n](./i18n) | 国际化与本地化的示例 |
| [log](./log) | 日志使用示例 |
| [metadata](./metadata) | 元数据使用示例 |
| [metrics](./metrics) | 度量系统使用示例 |
| [middleware](./middleware) | 中间件使用示例 |
| [realtimemap](./realtimemap) | 实时公交地图,主要是 MQTT、Websocket、RPC 综合使用 |
| [registry](./registry) | 注册中心使用示例 |
| [selector](./selector) | 节点选择器使用示例 |
| [stream](./stream) | |
| [swagger](./swagger) | swagger api 使用示例 |
| [tls](./tls) | TLS 证书使用示例 |
| [traces](./traces) | 链路追踪系统使用示例 |
| [transaction](./transaction) | 数据库事务使用示例 |
| [validate](./validate) | Protobuf 参数校验器使用示例 |
| [ws](./ws) | 最简单的 Websocket 示例 |
| [monolithic](./monolithic) | 巨石系统(单体系统)应用实例,包含前后端。 |
| [ent orm](./orm/ent/) | Ent 的 CURD 完整应用实例。 |
| [gorm](./monolithic) | GORM 的 CURD 完整应用实例。 |
46 changes: 32 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
# examples
# Kratos examples

English | [简体中文](README-CN.md)

- blog is simple crud project.
- config is kratos config example.
- errors is kratos errors example, it is generated through proto-gen-go-errors.
- helloworld is helloworld example.
- http is transport/http some examples of usage.
- log is log example, including、logger、helper、filter、valuer, etc.
- metadata is metadata example.
- metrics is metrics example, in the example, prom is used to collect data.
- registry is registration and discovery examples,including Etcd, Consul, Nacos.
- traces is middleware/tracing example,middleware/tracing is implemented by opentelemetry.
- validate is middleware/validate example, the verification code is generated by proto-gen-validate.
- ws is implementation of transport interface with websocket example.
- swagger is implementation of server with embed swagger api.
| Project Name | Description |
| ---------------------------- | ----------------------------------------------------------------------- |
| [auth/jwt](./auth/jwt) | Examples of JWT usage |
| [blog](./blog) | Blog system, simple CRUD example |
| [casbin](./casbin) | Examples of JWT authentication and Casbin authentication |
| [chatroom](./chatroom) | The simplest Websocket chat room example |
| [config](./config) | Examples of file configuration and remote configuration Center usage |
| [cqrs](./cqrs) | Examples of CQRS pattern implementation, mainly the use of Kafka. |
| [errors](./errors) | Error handling example |
| [event](./event) | Example of sending and receiving messages using MQ like Kafka |
| [header](./header) | Example of a custom HTTP Header |
| [helloworld](./helloworld) | RPC Call example |
| [http](./http) | Examples of HTTP-related applications, such as CORS and uploading files |
| [i18n](./i18n) | Examples of internationalization and localization |
| [log](./log) | Log usage example |
| [metadata](./metadata) | Examples of metadata usage |
| [metrics](./metrics) | Measurement system usage examples |
| [middleware](./middleware) | Middleware usage Examples |
| [realtimemap](./realtimemap) | Real-time bus map, mainly MQTT, Websocket, RPC integrated use |
| [registry](./registry) | Registry center usage examples |
| [selector](./selector) | Examples of node selector usage |
| [stream](./stream) | |
| [swagger](./swagger) | swagger is implementation of server with embed swagger api |
| [tls](./tls) | Example of TLS certificate usage |
| [traces](./traces) | Example of Distributed Tracing system |
| [transaction](./transaction) | Sample database transaction usage |
| [validate](./validate) | Example of Protobuf parameter validator usage |
| [ws](./ws) | ws is implementation of transport interface with websocket example |
| [monolithic](./monolithic) | Monolithic Application example, including frontend and backends. |
| [ent orm](./orm/ent/) | CURD full application example of Ent. |
| [gorm](./monolithic) | CURD full application example of GORM. |
21 changes: 21 additions & 0 deletions monolithic/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# If you prefer the allow list template instead of the deny list, see community template:
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
#
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

# Go workspace file
go.work
21 changes: 21 additions & 0 deletions monolithic/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Bobo

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 4 additions & 0 deletions monolithic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Golang微服务框架Kratos的巨石应用实践

- 后端基于 golang微服务框架 [go-kratos](https://go-kratos.dev/)
- 前端基于 [VUE3](https://vuejs.org/) + [TypeScript](https://www.typescriptlang.org/)
35 changes: 35 additions & 0 deletions monolithic/backend/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Reference https://github.com/github/gitignore/blob/master/Go.gitignore
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
vendor/

# Compiled Object files, Static and Dynamic libs (Shared Objects)
*.o
*.a

# OS General
Thumbs.db
.DS_Store

# project
*.cert
*.key
*.log
bin/

# Develop tools
.vscode/
.idea/
*.swp
4 changes: 4 additions & 0 deletions monolithic/backend/.markdownlint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
line-length: false
no-hard-tabs: false
no-inline-html: false
10 changes: 10 additions & 0 deletions monolithic/backend/.yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# vim: ft=yaml
---
yaml-files:
- "*.yaml"
- "*.yml"
- ".yamllint"
extends: "default"
rules:
quoted-strings: "enable"
line-length: "disable"
95 changes: 95 additions & 0 deletions monolithic/backend/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Not Support Windows

.PHONY: help wire gen ent build api openapi init all

ifeq ($(OS),Windows_NT)
IS_WINDOWS:=1
endif

CURRENT_DIR := $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST)))))
ROOT_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))

SRCS_MK := $(foreach dir, app, $(wildcard $(dir)/*/*/Makefile))

# initialize develop environment
init: plugin cli

# install protoc plugin
plugin:
@go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
@go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
@go install github.com/go-kratos/kratos/cmd/protoc-gen-go-http/v2@latest
@go install github.com/go-kratos/kratos/cmd/protoc-gen-go-errors/v2@latest
@go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@latest
@go install github.com/google/gnostic/cmd/protoc-gen-openapi@latest
@go install github.com/envoyproxy/protoc-gen-validate@latest

# install cli tools
cli:
@go install github.com/go-kratos/kratos/cmd/kratos/v2@latest
@go install github.com/google/gnostic@latest
@go install github.com/bufbuild/buf/cmd/buf@latest
@go install entgo.io/ent/cmd/ent@latest
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest

# generate wire code
wire:
$(foreach dir, $(dir $(realpath $(SRCS_MK))),\
cd $(dir);\
make wire;\
)

# generate code by go:generate
gen:
$(foreach dir, $(dir $(realpath $(SRCS_MK))),\
cd $(dir);\
make gen;\
)

# generate ent code
ent:
$(foreach dir, $(dir $(realpath $(SRCS_MK))),\
cd $(dir);\
make ent;\
)

# generate protobuf api go code
api:
buf generate

# generate OpenAPI v3 docs.
openapi:
buf generate --path api/admin/service/v1 --template api/admin/service/v1/buf.openapi.gen.yaml

# build all service applications
build:
$(foreach dir, $(dir $(realpath $(SRCS_MK))),\
cd $(dir);\
make build;\
)

# generate & build all service applications
all:
$(foreach dir, $(dir $(realpath $(SRCS_MK))),\
cd $(dir);\
make app;\
)

# show help
help:
@echo ""
@echo "Usage:"
@echo " make [target]"
@echo ""
@echo 'Targets:'
@awk '/^[a-zA-Z\-_0-9]+:/ { \
helpMessage = match(lastLine, /^# (.*)/); \
if (helpMessage) { \
helpCommand = substr($$1, 0, index($$1, ":")-1); \
helpMessage = substr(lastLine, RSTART + 2, RLENGTH); \
printf "\033[36m%-22s\033[0m %s\n", helpCommand,helpMessage; \
} \
} \
{ lastLine = $$0 }' $(MAKEFILE_LIST)

.DEFAULT_GOAL := help
Loading
Loading