Skip to content

Latest commit

 

History

History
107 lines (88 loc) · 4.51 KB

README_EN.md

File metadata and controls

107 lines (88 loc) · 4.51 KB

FormulaGo

English | 中文

Introduce

A high performance admin project framework with Hertz and Ent

  • High productivity: An enterprise management system can be built in a short time.
  • High performance: Uses the Hertz framework, the most powerful in Go. ByteDance has deployed tens of thousands of services using it.
  • Modularity: Referring to the DDD design concept, the module design is more concise and convenient.
  • Routing interfaces: Refer to the Google Open Platform and use Protobuf to define interface specifications.
  • Interface development, better expansion and Unit Test.

Demo website

Architecture

Does it look like an F1 car ? Go Backend Clean Architecture

Dependencies

  • Use Hertz as HTTP framework
  • Use Protobuf IDL to define HTTP interface
  • Use hz to generate code
  • Use Ent and MySQL(you also can use PostgresSQL)
  • Use Memory Cache and Redis (Config file configuration enabled)

Built-in features

  1. User management: The user is the system operator, and this function mainly completes the system user configuration.
  2. Menu management: Configure system menus, operation permissions, button permission identification, etc.
  3. Role management: Assign permissions in the role menu and set the permission division of roles.
  4. Dictionary management: Maintain some relatively fixed data that is often used in the system.
  5. Operation log: System normal operation log records and queries; System exception information logging and querying.
  6. Online users: Active user token status monitoring in the current system.
  7. File management: File upload, S3 (Aliyun OSS) multiple upload methods adapted.
  8. OAuth2.0 login: Support Google, Github, Wecom, etc.
  9. Common tools: Integrate common toolkits in pkg package.
  10. Develop tools: Provide convenient Struct to Protobuf conversion tools, Struct to Protobuf, Delete Struct Tag, etc.

Interface IDL

This project use Protobuf IDL to define HTTP interface. The specific admin interface define in admin.proto.

Code generation tool

This project use hz to generate code. The use of hz refers to hz.

  • hz install.
go install github.com/cloudwego/hertz/cmd/hz@latest
  • hz new: Create a new Hertz project.
hz new -I api -idl api/admin/admin.proto -model_dir api/model -module formulago --unset_omitempty
  • hz update: Update an existing project, while you update the IDL file.
  • The api.proto and base.proto are no need to update,because they generated by the proto file which has import them.
hz update -I api -idl api/admin/admin.proto -model_dir api/model --unset_omitempty

Binding and Validate

The use of binding and Validate refers to Binding and Validate.

Ent

ent - An Entity Framework For Go.

This project use Ent to operate MySQL(you also can use PostgresSQL) and refers to Ent.

Quick Start

  • Update the Database DSN to your own in Database config file.
  • Go to the root directory of your project, and run following command, will generate the schema for User under data/ent/schema/ directory:
  cd data
  go run -mod=mod entgo.io/ent/cmd/ent init User
  • Add fields to the User schema, run go generate to produce the ent operation files
  go generate ./ent

How to run

Modify the configuration file

  • Modify Prod configuration file and Dev configuration file to your own.
  • Note that the structure of Yaml should be consistent with the config struct definition.
  • While the running environment variable "IS_PROD" is true, the prod configuration file will be used, otherwise the dev configuration file will be used.

Run MySQL by Docker

cd formulago && docker-compose up

Run Project

cd formulago
go build -o formulago &&./formulago

# init Database Table data by http request
# Administrator account: admin/formulago
@router yourHost/api/initDatabase [GET]
enjoy it!

Feel free to contribute code or provide suggestions