Skip to content

Commit

Permalink
feat: v0.2.1 (#152)
Browse files Browse the repository at this point in the history
* Update README.md

* optimize: improve birthDateGen

* refactor: change ids from i64 to string and modify redis db (#129)

* refactor: change ids from i64 to string

* fix: change redis db

* fix: use consts to set the limit of some profile and some trip

* fix: fix test

* test: fix user test

* fix: fix account id bug (#130)

* optimize: profile handler

* fix: fix delete and check profile bug (#131)

* feat: add limiter mw

* chore(deps): bump github.com/cloudwego/kitex from 0.4.4 to 0.5.1 (#119)

Bumps [github.com/cloudwego/kitex](https://github.com/cloudwego/kitex) from 0.4.4 to 0.5.1.
- [Release notes](https://github.com/cloudwego/kitex/releases)
- [Commits](cloudwego/kitex@v0.4.4...v0.5.1)

---
updated-dependencies:
- dependency-name: github.com/cloudwego/kitex
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* feat: add delayed double delete

* docs: fix wrong link

* feat: refactor car sim (#133)

* feat: add ChatGPT

* optimize: improve gpt service

* optimize: add proxy for gpt

* feat: add payment (#135)

* feat: Add k8s deployment files (#136)

* Create K8s

* Add files via upload

* Delete K8s

* Delete ingress.yaml

* Delete sc.yaml

* Delete test.yaml

* Update Makefile

* chore(deps): bump github.com/hashicorp/consul/api from 1.18.0 to 1.20.0 (#141)

Bumps [github.com/hashicorp/consul/api](https://github.com/hashicorp/consul) from 1.18.0 to 1.20.0.
- [Release notes](https://github.com/hashicorp/consul/releases)
- [Changelog](https://github.com/hashicorp/consul/blob/main/CHANGELOG.md)
- [Commits](hashicorp/consul@api/v1.18.0...api/v1.20.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/consul/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump github.com/cloudwego/hertz from 0.6.0 to 0.6.2 (#140)

Bumps [github.com/cloudwego/hertz](https://github.com/cloudwego/hertz) from 0.6.0 to 0.6.2.
- [Release notes](https://github.com/cloudwego/hertz/releases)
- [Commits](cloudwego/hertz@v0.6.0...v0.6.2)

---
updated-dependencies:
- dependency-name: github.com/cloudwego/hertz
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump gorm.io/driver/mysql from 1.4.5 to 1.5.0 (#139)

Bumps [gorm.io/driver/mysql](https://github.com/go-gorm/mysql) from 1.4.5 to 1.5.0.
- [Release notes](https://github.com/go-gorm/mysql/releases)
- [Commits](go-gorm/mysql@v1.4.5...v1.5.0)

---
updated-dependencies:
- dependency-name: gorm.io/driver/mysql
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump github.com/cloudwego/kitex from 0.5.1 to 0.5.2 (#138)

Bumps [github.com/cloudwego/kitex](https://github.com/cloudwego/kitex) from 0.5.1 to 0.5.2.
- [Release notes](https://github.com/cloudwego/kitex/releases)
- [Commits](cloudwego/kitex@v0.5.1...v0.5.2)

---
updated-dependencies:
- dependency-name: github.com/cloudwego/kitex
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Xinhao Yuan <llance_24@foxmail.com>

* chore(deps): bump gorm.io/gorm (#142)

Bumps [gorm.io/gorm](https://github.com/go-gorm/gorm) from 1.24.7-0.20230306060331-85eaf9eeda11 to 1.25.1.
- [Release notes](https://github.com/go-gorm/gorm/releases)
- [Commits](https://github.com/go-gorm/gorm/commits/v1.25.1)

---
updated-dependencies:
- dependency-name: gorm.io/gorm
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* optimize: improve cors

* chore(deps): bump github.com/spf13/viper from 1.15.0 to 1.16.0 (#147)

Bumps [github.com/spf13/viper](https://github.com/spf13/viper) from 1.15.0 to 1.16.0.
- [Release notes](https://github.com/spf13/viper/releases)
- [Commits](spf13/viper@v1.15.0...v1.16.0)

---
updated-dependencies:
- dependency-name: github.com/spf13/viper
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump github.com/cloudwego/hertz from 0.6.2 to 0.6.4 (#144)

Bumps [github.com/cloudwego/hertz](https://github.com/cloudwego/hertz) from 0.6.2 to 0.6.4.
- [Release notes](https://github.com/cloudwego/hertz/releases)
- [Commits](cloudwego/hertz@v0.6.2...v0.6.4)

---
updated-dependencies:
- dependency-name: github.com/cloudwego/hertz
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* style: update src

* chore(deps): bump github.com/minio/minio-go/v7 from 7.0.49 to 7.0.59 (#151)

Bumps [github.com/minio/minio-go/v7](https://github.com/minio/minio-go) from 7.0.49 to 7.0.59.
- [Release notes](https://github.com/minio/minio-go/releases)
- [Commits](minio/minio-go@v7.0.49...v7.0.59)

---
updated-dependencies:
- dependency-name: github.com/minio/minio-go/v7
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump gorm.io/gorm from 1.25.1 to 1.25.2 (#150)

Bumps [gorm.io/gorm](https://github.com/go-gorm/gorm) from 1.25.1 to 1.25.2.
- [Release notes](https://github.com/go-gorm/gorm/releases)
- [Commits](go-gorm/gorm@v1.25.1...v1.25.2)

---
updated-dependencies:
- dependency-name: gorm.io/gorm
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump aidanwoods.dev/go-paseto from 1.3.0 to 1.4.0 (#149)

Bumps [aidanwoods.dev/go-paseto](https://github.com/aidantwoods/go-paseto) from 1.3.0 to 1.4.0.
- [Release notes](https://github.com/aidantwoods/go-paseto/releases)
- [Commits](aidantwoods/go-paseto@v1.3.0...v1.4.0)

---
updated-dependencies:
- dependency-name: aidanwoods.dev/go-paseto
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* chore(deps): bump github.com/hertz-contrib/http2 from 0.1.5 to 0.1.7 (#143)

Bumps [github.com/hertz-contrib/http2](https://github.com/hertz-contrib/http2) from 0.1.5 to 0.1.7.
- [Release notes](https://github.com/hertz-contrib/http2/releases)
- [Commits](hertz-contrib/http2@v0.1.5...v0.1.7)

---
updated-dependencies:
- dependency-name: github.com/hertz-contrib/http2
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Xinhao Yuan <llance_24@foxmail.com>

* docs: update README

* docs: update README

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: Qing Zhou <claude-zq@qq.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Nihilism <114405451+Nihilism0@users.noreply.github.com>
  • Loading branch information
4 people authored Jul 31, 2023
1 parent 908fa2c commit 60b8938
Show file tree
Hide file tree
Showing 125 changed files with 5,888 additions and 2,016 deletions.
104 changes: 75 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,38 @@ FreeCar is a cloud-native time-sharing car rental system suite based on Hertz an

## Technology Stack

| Function | Implementation |
|--------------------------------------------|-----------------------|
| HTTP Framework | Hertz |
| RPC Framework | Kitex |
| Database | MongoDB, MySQL, Redis |
| Authentication | Paseto |
| Service Discovery and Configuration Center | Consul |
| Message Queue | RabbitMQ |
| Service Governance | OpenTelemetry |
| Current Limiting Fuse | Sentinel |
| Object Storage | Minio |
| Image Recognition | Baidu OCR |
| CI | GitHub Actions |
| Function | Implementation |
|----------------------------------|-----------------------|
| HTTP Framework | Hertz |
| RPC Framework | Kitex |
| Database | MongoDB, MySQL, Redis |
| Authentication | Paseto |
| Service and Configuration Center | Consul |
| Metrics Monitoring | Prometheus |
| Tracing | Jaeger |
| Message Queue | RabbitMQ |
| Service Governance | OpenTelemetry |
| Current Limiting Fuse | Sentinel |
| Object Storage | MinIO |
| Image Recognition | Baidu OCR |
| CI | GitHub Actions |

## Display

Small program terminal address [FreeCar-MP](https://github.com/CyanAsterisk/FreeCar-MP)
### Mini Program

Background management terminal address TODO
Mini program project address [FreeCar-MP](https://github.com/CyanAsterisk/FreeCar-MP)

![display.png](img/display.png)

### Admin

Admin project address [FreeCar-Admin](https://github.com/CyanAsterisk/FreeCar-Admin)

![data-analize.png](img/data-analize.png)

![back.png](img/back.png)

## Catalog Introduce

| Catalog | Introduction |
Expand All @@ -56,7 +66,7 @@ Background management terminal address TODO
|---------|----------------------------------------------------|
| API | Hertz-based gateway service |
| User | User Authentication Service |
| Blob | Services related to image and Minio object storage |
| Blob | Services related to image and MinIO object storage |
| Car | Car Service |
| Profile | Home Page and Image Recognition Service |
| Trip | Itinerary Services |
Expand Down Expand Up @@ -89,10 +99,10 @@ make api

```shell
make user
make blobs
make a car
make blob
make car
make profile
make a trip
make trip
```

### Jaeger
Expand All @@ -101,15 +111,43 @@ make a trip
![jaeger.jpg](img/jaeger.png)

![jaeger2.png](img/jaeger2.png)

### Prometheus

> Visit `http://127.0.0.1:3000/` on your browser
![prometheus.jpg](img/prometheus.png)

### MinIO

> Visit `http://127.0.0.1:9000/` on your browser
![minio.jpg](img/minio.png)

## K8s Deployment

```shell
cd deployment/freecar-k8s
make all
```

### Pod

![pod.png](img/pod.png)

### PVC

![pvc.png](img/pvc.png)

### Service

![service.png](img/service.png)

## Development Guide

It is very difficult to understand this project by directly reading the source code. Here is a development guide for developers to quickly understand and get started with this project, including frameworks such as Kitex and Hertz.
It is very difficult to understand this project by directly reading the source code. Here is a development guide for
developers to quickly understand and get started with this project, including frameworks such as Kitex and Hertz.

### Preparation

Expand All @@ -119,7 +157,7 @@ customization, please modify the contents of `docker-compose.yaml` and Nacos con
### IDL

Before development, we need to define the IDL file, among which hz provides developers with many
customized [api annotations](https://www.cloudwego.io/zh/docs/hertz/tutorials/toolkit/toolkit/#%E6%94%AF%E6%8C%81%E7%9A%84-api-%E6%B3%A8%E8%A7%A3).
customized [api annotations](https://www.cloudwego.io/zh/docs/hertz/tutorials/toolkit/usage/annotation/#%E6%94%AF%E6%8C%81%E7%9A%84-api-%E6%B3%A8%E8%A7%A3).

Sample code:

Expand All @@ -143,7 +181,8 @@ service UserService {

#### Kitex

First generate `kitex_gen` in the `shared` folder, and then rely on `kitex_gen` in the corresponding service folder to generate. Execute under the new service directory, only need to change the service name and IDL path each time.
First generate `kitex_gen` in the `shared` folder, and then rely on `kitex_gen` in the corresponding service folder to
generate. Execute under the new service directory, only need to change the service name and IDL path each time.

```shell
kitex -module github.com/CyanAsterisk/FreeCar ./../idl/rpc/user.thrift
Expand All @@ -152,7 +191,8 @@ kitex -service user -module github.com/CyanAsterisk/FreeCar -use github.com/Cyan

Note:

- Use `-module github.com/CyanAsterisk/FreeCar` This parameter is used to specify the Go module to which the generated code belongs to avoid path problems.
- Use `-module github.com/CyanAsterisk/FreeCar` This parameter is used to specify the Go module to which the generated
code belongs to avoid path problems.
- When the current service needs to call other services, it needs to rely on `kitex_gen`.

#### Hertz
Expand All @@ -170,7 +210,8 @@ Note:

### Business Development

After the code is generated, some necessary components need to be added to the project. Since the api layer does not need to be added again, the following mainly explains about Kitex-Server
After the code is generated, some necessary components need to be added to the project. Since the api layer does not
need to be added again, the following mainly explains about Kitex-Server
section, the code is located under `server/cmd`.

#### Config
Expand All @@ -179,20 +220,25 @@ Refer to `server/cmd/user/config` for the configuration structure of microservic

#### Initialize

Refer to `server/cmd/user/initialize` to provide the initialization function of the necessary components, among which `config.go` `registry.go` `flag.go` `logger.go` are required.
Refer to `server/cmd/user/initialize` to provide the initialization function of the necessary components, among
which `config.go` `registry.go` `flag.go` `logger.go` are required.

#### Pkg

Refer to `server/cmd/user/pkg` to provide calling functions of microservices, which are mainly used to implement the interfaces defined in `handler.go`.
Refer to `server/cmd/user/pkg` to provide calling functions of microservices, which are mainly used to implement the
interfaces defined in `handler.go`.

#### API

When writing the business logic of the gateway layer, you only need to update the IDL and the new microservice client code each time. If you need to add new components, you can add them directly. The project is highly pluggable, and the architecture is similar to the microservice layer.
When writing the business logic of the gateway layer, you only need to update the IDL and the new microservice client
code each time. If you need to add new components, you can add them directly. The project is highly pluggable, and the
architecture is similar to the microservice layer.

The business logic of the gateway layer is under `server/cmd/api/biz`, and most of the code will be automatically generated. If you need to add a new route separately, you need to go to `server/cmd/api/router.go`.
The business logic of the gateway layer is under `server/cmd/api/biz`, and most of the code will be automatically
generated. If you need to add a new route separately, you need to go to `server/cmd/api/router.go`.

Regarding the use of middleware, you only need to add middleware logic in `server/cmd/api/biz/router/api/middleware.go`.

## License

FreeCar is open source under the GNU General Public License version 3.0.
FreeCar is open source under the GNU General Public License version 3.0.
76 changes: 58 additions & 18 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,39 @@ FreeCar 是一个基于 Hertz 与 Kitex 的云原生分时汽车租赁系统套

## 技术栈

| 功能 | 实现 |
|-----------|---------------------|
| HTTP 框架 | Hertz |
| RPC 框架 | Kitex |
| 数据库 | MongoDB、MySQL、Redis |
| 身份鉴权 | Paseto |
| 服务发现与配置中心 | Consul |
| 消息队列 | RabbitMQ |
| 服务治理 | OpenTelemetry |
| 限流熔断 | Sentinel |
| 对象存储 | Minio |
| 图像识别 | 百度 OCR |
| CI | GitHub Actions |
| 功能 | 实现 |
|---------|---------------------|
| HTTP 框架 | Hertz |
| RPC 框架 | Kitex |
| 数据库 | MongoDB、MySQL、Redis |
| 身份鉴权 | Paseto |
| 服务与配置中心 | Consul |
| 消息队列 | RabbitMQ |
| 服务治理 | OpenTelemetry |
| 指标监控 | Prometheus |
| 链路追踪 | Jaeger |
| 限流熔断 | Sentinel |
| 对象存储 | MinIO |
| 图像识别 | 百度 OCR |
| CI | GitHub Actions |

## 页面展示

小程序端地址 [FreeCar-MP](https://github.com/CyanAsterisk/FreeCar-MP)
### 小程序端

后台管理端地址 TODO
小程序端地址 [FreeCar-MP](https://github.com/CyanAsterisk/FreeCar-MP)

![display.png](img/display.png)

### 后台管理系统

后台管理系统地址 [FreeCar-Admin](https://github.com/CyanAsterisk/FreeCar-Admin)

![data-analize.png](img/data-analize.png)

![back.png](img/back.png)


## 目录介绍

| 目录 | 介绍 |
Expand All @@ -56,7 +67,7 @@ FreeCar 是一个基于 Hertz 与 Kitex 的云原生分时汽车租赁系统套
|---------|----------------------|
| API | 基于 Hertz 的网关服务 |
| User | 用户认证服务 |
| Blob | 与图片和 Minio 对象存储相关的服务 |
| Blob | 与图片和 MinIO 对象存储相关的服务 |
| Car | 汽车服务 |
| Profile | 主页与图片识别服务 |
| Trip | 行程服务 |
Expand Down Expand Up @@ -101,12 +112,40 @@ make trip
![jaeger.jpg](img/jaeger.png)

![jaeger2.png](img/jaeger2.png)

### Prometheus

> 在浏览器上访问 `http://127.0.0.1:3000/`
![prometheus.jpg](img/prometheus.png)

### MinIO

> 在浏览器上访问 `http://127.0.0.1:9000/`
![minio.jpg](img/minio.png)

## K8s 部署

```shell
cd deployment/freecar-k8s
make all
```

### Pod

![pod.png](img/pod.png)

### PVC

![pvc.png](img/pvc.png)

### Service

![service.png](img/service.png)


## 开发指南

通过直接阅读源码来了解此项目是非常困难的,在此提供开发指南方便开发者快速了解并上手此项目包括 Kitex、Hertz 等框架。
Expand All @@ -118,7 +157,7 @@ make trip
### IDL

在开发之前我们需要定义好 IDL 文件,其中 hz
为开发者提供了许多定制化的 [api 注解](https://www.cloudwego.io/zh/docs/hertz/tutorials/toolkit/toolkit/#%E6%94%AF%E6%8C%81%E7%9A%84-api-%E6%B3%A8%E8%A7%A3)
为开发者提供了许多定制化的 [api 注解](https://www.cloudwego.io/zh/docs/hertz/tutorials/toolkit/usage/annotation/#%E6%94%AF%E6%8C%81%E7%9A%84-api-%E6%B3%A8%E8%A7%A3)

示例代码:

Expand All @@ -142,7 +181,8 @@ service UserService {

#### Kitex

首先在 `shared` 文件夹下生成 `kitex_gen`,再在相对应服务文件夹下依赖 `kitex_gen` 进行生成。在新增服务目录下执行,每次仅需更改服务名与 IDL 路径。
首先在 `shared` 文件夹下生成 `kitex_gen`,再在相对应服务文件夹下依赖 `kitex_gen` 进行生成。在新增服务目录下执行,每次仅需更改服务名与
IDL 路径。

```shell
kitex -module github.com/CyanAsterisk/FreeCar ./../idl/rpc/user.thrift
Expand Down
18 changes: 18 additions & 0 deletions deployment/freecar-k8s/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
generate:
kubectl apply -f $(basic).yaml

ingress:
make basic=ingress generate

dashboard:
make basic=dashboard generate
make basic=auth generate

all:
make dashboard
make -C consul make
make -C minio make
make -C mongodb make
make -C mysql make
make -C rabbitmq make
make -C redis make
12 changes: 12 additions & 0 deletions deployment/freecar-k8s/auth.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: service-controller-cluster-admin
subjects:
- kind: ServiceAccount
name: service-controller
namespace: kube-system
roleRef:
kind: ClusterRole
name: cluster-admin
apiGroup: rbac.authorization.k8s.io
4 changes: 4 additions & 0 deletions deployment/freecar-k8s/consul/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
make:
kubectl apply -f pv.yaml
kubectl apply -f pvc.yaml
kubectl apply -f consul.yaml
Loading

0 comments on commit 60b8938

Please sign in to comment.